fix: Make Last used date of Password history optional #84
This commit is contained in:
parent
09c885ec0a
commit
ff752c6988
|
@ -300,7 +300,7 @@ data class DSecret(
|
|||
@optics
|
||||
data class PasswordHistory(
|
||||
val password: String,
|
||||
val lastUsedDate: Instant,
|
||||
val lastUsedDate: Instant?,
|
||||
) {
|
||||
companion object;
|
||||
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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?,
|
||||
)
|
||||
|
|
|
@ -12,5 +12,5 @@ data class PasswordHistoryEntity(
|
|||
val password: String,
|
||||
@JsonNames("lastUsedDate")
|
||||
@SerialName("LastUsedDate")
|
||||
val lastUsedDate: Instant,
|
||||
val lastUsedDate: Instant? = null,
|
||||
)
|
||||
|
|
|
@ -10,7 +10,7 @@ data class PasswordHistoryRequest(
|
|||
@SerialName("password")
|
||||
val password: String,
|
||||
@SerialName("lastUsedDate")
|
||||
val lastUsedDate: Instant,
|
||||
val lastUsedDate: Instant?,
|
||||
)
|
||||
|
||||
fun PasswordHistoryRequest.Companion.of(
|
||||
|
|
Loading…
Reference in New Issue