fix: Make Last used date of Password history optional #84

This commit is contained in:
Artem Chepurnoy 2024-01-19 10:13:35 +02:00
parent 09c885ec0a
commit ff752c6988
No known key found for this signature in database
GPG Key ID: FAC37D0CF674043E
7 changed files with 12 additions and 11 deletions

View File

@ -300,7 +300,7 @@ data class DSecret(
@optics
data class PasswordHistory(
val password: String,
val lastUsedDate: Instant,
val lastUsedDate: Instant?,
) {
companion object;

View File

@ -163,7 +163,7 @@ data class BitwardenCipher(
@Serializable
data class PasswordHistory(
val password: String,
val lastUsedDate: Instant,
val lastUsedDate: Instant? = null,
) {
val id = "$password|timestamp=$lastUsedDate"
}

View File

@ -1,6 +1,5 @@
package com.artemchep.keyguard.feature.home.vault.component
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.ContentCopy
import androidx.compose.material.icons.outlined.Password
@ -43,10 +42,10 @@ fun VaultPasswordHistoryValueItem(
fontFamily = if (item.monospace) monoFontFamily else null,
)
},
text = if (item.title.isNotBlank()) {
text = if (!item.date.isNullOrBlank()) {
// composable
{
Text(item.title)
Text(item.date)
}
} else {
null

View File

@ -11,7 +11,7 @@ sealed interface VaultPasswordHistoryItem {
data class Value(
override val id: String,
val title: String,
val date: String?,
val value: String,
val monospace: Boolean,
val selected: Boolean,

View File

@ -199,9 +199,11 @@ fun vaultViewPasswordHistoryScreenState(
passwordHistory
.sortedByDescending { it.lastUsedDate }
.map { password ->
val date = password.lastUsedDate
?.let(dateFormatter::formatDateTime)
TempPasswordHistory(
src = password,
date = dateFormatter.formatDateTime(password.lastUsedDate),
date = date,
actions = buildContextItems {
section {
this += copyFactory.FlatItemAction(
@ -255,7 +257,7 @@ fun vaultViewPasswordHistoryScreenState(
.partially1(password.id)
VaultPasswordHistoryItem.Value(
id = password.id,
title = passwordWrapper.date,
date = passwordWrapper.date,
value = password.password,
dropdown = passwordWrapper.actions,
monospace = true,
@ -302,5 +304,5 @@ fun vaultViewPasswordHistoryScreenState(
private data class TempPasswordHistory(
val src: DSecret.Login.PasswordHistory,
val actions: List<ContextItem>,
val date: String,
val date: String?,
)

View File

@ -12,5 +12,5 @@ data class PasswordHistoryEntity(
val password: String,
@JsonNames("lastUsedDate")
@SerialName("LastUsedDate")
val lastUsedDate: Instant,
val lastUsedDate: Instant? = null,
)

View File

@ -10,7 +10,7 @@ data class PasswordHistoryRequest(
@SerialName("password")
val password: String,
@SerialName("lastUsedDate")
val lastUsedDate: Instant,
val lastUsedDate: Instant?,
)
fun PasswordHistoryRequest.Companion.of(