mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 07:05:35 +03:00
BIT-2433: Filter trash from search results (#3361)
This commit is contained in:
parent
2226c8d59e
commit
fc78037fb0
2 changed files with 38 additions and 9 deletions
|
@ -102,15 +102,18 @@ private fun CipherView.filterBySearchType(
|
||||||
searchTypeData: SearchTypeData.Vault,
|
searchTypeData: SearchTypeData.Vault,
|
||||||
): Boolean =
|
): Boolean =
|
||||||
when (searchTypeData) {
|
when (searchTypeData) {
|
||||||
SearchTypeData.Vault.All -> true
|
SearchTypeData.Vault.All -> deletedDate == null
|
||||||
is SearchTypeData.Vault.Cards -> type == CipherType.CARD
|
is SearchTypeData.Vault.Cards -> type == CipherType.CARD && deletedDate == null
|
||||||
is SearchTypeData.Vault.Collection -> searchTypeData.collectionId in this.collectionIds
|
is SearchTypeData.Vault.Collection -> {
|
||||||
is SearchTypeData.Vault.Folder -> folderId == searchTypeData.folderId
|
searchTypeData.collectionId in this.collectionIds && deletedDate == null
|
||||||
SearchTypeData.Vault.NoFolder -> folderId == null
|
}
|
||||||
is SearchTypeData.Vault.Identities -> type == CipherType.IDENTITY
|
|
||||||
is SearchTypeData.Vault.Logins -> type == CipherType.LOGIN
|
is SearchTypeData.Vault.Folder -> folderId == searchTypeData.folderId && deletedDate == null
|
||||||
is SearchTypeData.Vault.SecureNotes -> type == CipherType.SECURE_NOTE
|
SearchTypeData.Vault.NoFolder -> folderId == null && deletedDate == null
|
||||||
is SearchTypeData.Vault.VerificationCodes -> login?.totp != null
|
is SearchTypeData.Vault.Identities -> type == CipherType.IDENTITY && deletedDate == null
|
||||||
|
is SearchTypeData.Vault.Logins -> type == CipherType.LOGIN && deletedDate == null
|
||||||
|
is SearchTypeData.Vault.SecureNotes -> type == CipherType.SECURE_NOTE && deletedDate == null
|
||||||
|
is SearchTypeData.Vault.VerificationCodes -> login?.totp != null && deletedDate == null
|
||||||
is SearchTypeData.Vault.Trash -> deletedDate != null
|
is SearchTypeData.Vault.Trash -> deletedDate != null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -257,6 +257,32 @@ class SearchTypeDataExtensionsTest {
|
||||||
assertEquals(listOf(match1, match2), result)
|
assertEquals(listOf(match1, match2), result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `CipherViews filterAndOrganize should return list without deleted items`() {
|
||||||
|
val match1 = createMockCipherView(number = 1, isDeleted = true).copy(name = "match1")
|
||||||
|
val match2 = createMockCipherView(number = 2).copy(name = "match2")
|
||||||
|
val match3 = createMockCipherView(number = 3, isDeleted = true).copy(name = "match3")
|
||||||
|
val ciphers = listOf(match1, match2, match3)
|
||||||
|
val result = ciphers.filterAndOrganize(
|
||||||
|
searchTypeData = SearchTypeData.Vault.Logins,
|
||||||
|
searchTerm = "match",
|
||||||
|
)
|
||||||
|
assertEquals(listOf(match2), result)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `CipherViews filterAndOrganize should return list with only deleted items`() {
|
||||||
|
val match1 = createMockCipherView(number = 1, isDeleted = true).copy(name = "match1")
|
||||||
|
val match2 = createMockCipherView(number = 2).copy(name = "match2")
|
||||||
|
val match3 = createMockCipherView(number = 3, isDeleted = true).copy(name = "match3")
|
||||||
|
val ciphers = listOf(match1, match2, match3)
|
||||||
|
val result = ciphers.filterAndOrganize(
|
||||||
|
searchTypeData = SearchTypeData.Vault.Trash,
|
||||||
|
searchTerm = "match",
|
||||||
|
)
|
||||||
|
assertEquals(listOf(match1, match3), result)
|
||||||
|
}
|
||||||
|
|
||||||
@Suppress("MaxLineLength")
|
@Suppress("MaxLineLength")
|
||||||
@Test
|
@Test
|
||||||
fun `CipherViews toViewState should return empty state with no message when search term is blank`() {
|
fun `CipherViews toViewState should return empty state with no message when search term is blank`() {
|
||||||
|
|
Loading…
Reference in a new issue