From 02c6dbd9593bad7302d0f5debe8df2e8c54aae63 Mon Sep 17 00:00:00 2001 From: Andre Rosado Date: Thu, 18 Dec 2025 13:15:38 +0000 Subject: [PATCH] removed unnecessary hasPersonalVaultItems method --- .../data/vault/repository/VaultRepository.kt | 7 -- .../vault/repository/VaultRepositoryImpl.kt | 5 - .../vault/repository/VaultRepositoryTest.kt | 94 ------------------- 3 files changed, 106 deletions(-) diff --git a/app/src/main/kotlin/com/x8bit/bitwarden/data/vault/repository/VaultRepository.kt b/app/src/main/kotlin/com/x8bit/bitwarden/data/vault/repository/VaultRepository.kt index a525e84aae..bef061f6c0 100644 --- a/app/src/main/kotlin/com/x8bit/bitwarden/data/vault/repository/VaultRepository.kt +++ b/app/src/main/kotlin/com/x8bit/bitwarden/data/vault/repository/VaultRepository.kt @@ -166,11 +166,4 @@ interface VaultRepository : * `null` if the item cannot be found. */ fun getVaultListItemStateFlow(itemId: String): StateFlow> - - /** - * 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 } diff --git a/app/src/main/kotlin/com/x8bit/bitwarden/data/vault/repository/VaultRepositoryImpl.kt b/app/src/main/kotlin/com/x8bit/bitwarden/data/vault/repository/VaultRepositoryImpl.kt index 15d6819fd7..9c3a6dabc8 100644 --- a/app/src/main/kotlin/com/x8bit/bitwarden/data/vault/repository/VaultRepositoryImpl.kt +++ b/app/src/main/kotlin/com/x8bit/bitwarden/data/vault/repository/VaultRepositoryImpl.kt @@ -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() } - } } diff --git a/app/src/test/kotlin/com/x8bit/bitwarden/data/vault/repository/VaultRepositoryTest.kt b/app/src/test/kotlin/com/x8bit/bitwarden/data/vault/repository/VaultRepositoryTest.kt index 964c51d09e..d8ea30e139 100644 --- a/app/src/test/kotlin/com/x8bit/bitwarden/data/vault/repository/VaultRepositoryTest.kt +++ b/app/src/test/kotlin/com/x8bit/bitwarden/data/vault/repository/VaultRepositoryTest.kt @@ -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 /**