removed unnecessary hasPersonalVaultItems method

This commit is contained in:
Andre Rosado committed 2025-12-18 13:15:38 +00:00
1 parent 2734ac4b3d
commit 02c6dbd959
3 files changed
-106

No files matched your search

@@ -166,11 +166,4 @@ interface VaultRepository :
* `null` if the item cannot be found.
*/
fun getVaultListItemStateFlow(itemId: String): StateFlow<DataState<CipherListView?>>
/**
* Checks if there are any personal vault items (items without an organization ID) in the vault.
*
* @return `true` if there are personal vault items, `false` otherwise.
*/
fun hasPersonalVaultItems(): Boolean
}
@@ -550,9 +550,4 @@ class VaultRepositoryImpl(
organizationKeys = organizationKeys,
)
}
override fun hasPersonalVaultItems(): Boolean {
val vaultData = vaultSyncManager.vaultDataStateFlow.value.data ?: return false
return vaultData.decryptCipherListResult.successes.any { it.organizationId.isNullOrEmpty() }
}
}
@@ -1390,100 +1390,6 @@ class VaultRepositoryTest {
}
}
@Test
fun `hasPersonalVaultItems returns false when vault data is loading`() {
mutableVaultDataStateFlow.value = DataState.Loading
val result = vaultRepository.hasPersonalVaultItems()
assertEquals(false, result)
}
@Test
fun `hasPersonalVaultItems returns false when all items belong to organizations`() {
mutableVaultDataStateFlow.value = DataState.Loaded(
data = VaultData(
decryptCipherListResult = DecryptCipherListResult(
successes = listOf(
createMockCipherListView(number = 1, organizationId = "org-1"),
createMockCipherListView(number = 2, organizationId = "org-2"),
),
failures = emptyList(),
),
collectionViewList = emptyList(),
folderViewList = emptyList(),
sendViewList = emptyList(),
),
)
val result = vaultRepository.hasPersonalVaultItems()
assertEquals(false, result)
}
@Test
fun `hasPersonalVaultItems returns true when there are items without organization ID`() {
mutableVaultDataStateFlow.value = DataState.Loaded(
data = VaultData(
decryptCipherListResult = DecryptCipherListResult(
successes = listOf(
createMockCipherListView(number = 1, organizationId = null),
createMockCipherListView(number = 2, organizationId = "org-2"),
),
failures = emptyList(),
),
collectionViewList = emptyList(),
folderViewList = emptyList(),
sendViewList = emptyList(),
),
)
val result = vaultRepository.hasPersonalVaultItems()
assertEquals(true, result)
}
@Test
fun `hasPersonalVaultItems returns true when there are items with empty organization ID`() {
mutableVaultDataStateFlow.value = DataState.Loaded(
data = VaultData(
decryptCipherListResult = DecryptCipherListResult(
successes = listOf(
createMockCipherListView(number = 1, organizationId = ""),
createMockCipherListView(number = 2, organizationId = "org-2"),
),
failures = emptyList(),
),
collectionViewList = emptyList(),
folderViewList = emptyList(),
sendViewList = emptyList(),
),
)
val result = vaultRepository.hasPersonalVaultItems()
assertEquals(true, result)
}
@Test
fun `hasPersonalVaultItems returns false when successes list is empty`() {
mutableVaultDataStateFlow.value = DataState.Loaded(
data = VaultData(
decryptCipherListResult = DecryptCipherListResult(
successes = emptyList(),
failures = emptyList(),
),
collectionViewList = emptyList(),
folderViewList = emptyList(),
sendViewList = emptyList(),
),
)
val result = vaultRepository.hasPersonalVaultItems()
assertEquals(false, result)
}
//region Helper functions
/**