Skip to content

Commit a42a311

Browse files
Fix tags issue (#829)
* feat: add keepass csv importer * feat: spotless * fix: support for comma seperator tags
1 parent b2aa431 commit a42a311

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

app/src/main/java/com/yogeshpaliyal/keypass/ui/nav/BottomNavViewModel.kt

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,12 @@ class BottomNavViewModel @Inject constructor(
3333

3434
viewModelScope.launch {
3535
tagsDb.collect {
36-
tagsList = it
36+
tagsList = it.flatMap { it.split(",") }.map { it.trim() }.toSet().toList()
3737
postListUpdate()
3838
}
3939
}
4040
}
4141

42-
/**
43-
* Set the currently selected menu item.
44-
*
45-
* @return true if the currently selected item has changed.
46-
*/
47-
fun setNavigationMenuItemChecked(id: Int): Boolean {
48-
var updated = false
49-
NavigationModel.navigationMenuItems.forEachIndexed { index, item ->
50-
val shouldCheck = item.id == id
51-
if (item.checked != shouldCheck) {
52-
NavigationModel.navigationMenuItems[index] = item.copy(checked = shouldCheck)
53-
updated = true
54-
}
55-
}
56-
if (updated) postListUpdate()
57-
return updated
58-
}
59-
6042
private fun postListUpdate() {
6143
val newList = if (tagsList.isNullOrEmpty().not()) {
6244
NavigationModel.navigationMenuItems + NavigationModelItem.NavDivider("Tags") + (

common/src/main/java/com/yogeshpaliyal/common/db/DbDao.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ interface DbDao {
3535
"SELECT * FROM account " +
3636
"WHERE " +
3737
"CASE WHEN :tag IS NOT NULL " +
38-
"THEN tags = :tag " +
38+
"THEN (tags LIKE '%'||:tag||'%' ) " +
3939
"ELSE 1 END " +
4040
"AND ((username LIKE '%'||:query||'%' ) " +
4141
"OR (title LIKE '%'||:query||'%' ) " +
@@ -57,7 +57,7 @@ interface DbDao {
5757
"SELECT * FROM account " +
5858
"WHERE " +
5959
"CASE WHEN :tag IS NOT NULL " +
60-
"THEN tags = :tag " +
60+
"THEN (tags LIKE '%'||:tag||'%' ) " +
6161
"ELSE 1 END " +
6262
"AND ((username LIKE '%'||:query||'%' ) " +
6363
"OR (title LIKE '%'||:query||'%' ) " +

0 commit comments

Comments
 (0)