mirror of
https://github.com/bitwarden/android.git
synced 2026-10-22 02:53:19 -05:00
PM-32721: bug: Sort password history before persisting (#6709)
This commit is contained in:
1 parent
6332081356
commit
d926ce98b5
2 files changed
+10
-7
No files matched your search
+5
-2
@@ -163,13 +163,16 @@ private fun VaultAddEditState.ViewState.Content.toPasswordHistory(
|
||||
)
|
||||
|
||||
return listOf(
|
||||
common.originalCipher?.passwordHistory.orEmpty(),
|
||||
newPasswordHistory,
|
||||
common.originalCipher?.passwordHistory.orEmpty(),
|
||||
newHiddenFieldHistory,
|
||||
)
|
||||
.flatten()
|
||||
// Ensure that they are in the correct order before saving.
|
||||
.sortedByDescending { it.lastUsedDate }
|
||||
// Only persist the 5 most recent items.
|
||||
.take(5)
|
||||
.ifEmpty { null }
|
||||
?.takeLast(5)
|
||||
}
|
||||
|
||||
private fun getPasswordHistory(
|
||||
|
||||
+5
-5
@@ -18,8 +18,8 @@ import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockSdkFido2Cre
|
||||
import com.x8bit.bitwarden.ui.vault.feature.addedit.VaultAddEditState
|
||||
import com.x8bit.bitwarden.ui.vault.feature.addedit.model.UriItem
|
||||
import com.x8bit.bitwarden.ui.vault.model.VaultCardBrand
|
||||
import com.x8bit.bitwarden.ui.vault.model.VaultCollection
|
||||
import com.x8bit.bitwarden.ui.vault.model.VaultCardExpirationMonth
|
||||
import com.x8bit.bitwarden.ui.vault.model.VaultCollection
|
||||
import com.x8bit.bitwarden.ui.vault.model.VaultIdentityTitle
|
||||
import com.x8bit.bitwarden.ui.vault.model.VaultLinkedFieldType
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
@@ -202,11 +202,11 @@ class VaultAddItemStateExtensionsTest {
|
||||
),
|
||||
passwordHistory = listOf(
|
||||
PasswordHistoryView(
|
||||
password = "old_password",
|
||||
password = "password",
|
||||
lastUsedDate = FIXED_CLOCK.instant(),
|
||||
),
|
||||
PasswordHistoryView(
|
||||
password = "password",
|
||||
password = "old_password",
|
||||
lastUsedDate = FIXED_CLOCK.instant(),
|
||||
),
|
||||
PasswordHistoryView(
|
||||
@@ -1104,11 +1104,11 @@ class VaultAddItemStateExtensionsTest {
|
||||
fields = emptyList(),
|
||||
passwordHistory = listOf(
|
||||
PasswordHistoryView(
|
||||
password = "old_password",
|
||||
password = "password",
|
||||
lastUsedDate = FIXED_CLOCK.instant(),
|
||||
),
|
||||
PasswordHistoryView(
|
||||
password = "password",
|
||||
password = "old_password",
|
||||
lastUsedDate = FIXED_CLOCK.instant(),
|
||||
),
|
||||
PasswordHistoryView(
|
||||
|
||||
Reference in new issue
Block a user