fix: Multiple validation

This commit is contained in:
J-Jamet
2025-10-13 11:48:12 +02:00
parent cc936b9304
commit 4fe6b2e115
5 changed files with 45 additions and 34 deletions

View File

@@ -6,7 +6,7 @@ KeePassDX(4.2.0)
* Change Passkey Backup Eligibility & Backup State #2135 #2150
* Search settings #2112 #2181 #2187
* Autofill refactoring #765 #2196
* Small fixes #2157 #2164 #2171 #2122 #2180
* Small fixes #2157 #2164 #2171 #2122 #2180 #2209
KeePassDX(4.1.9)
* Fix landscape UI #2198 #2200 (@chenxiaolong)

View File

@@ -461,6 +461,7 @@ class EntryEditActivity : DatabaseLockActivity(),
result: ActionRunnable.Result
) {
super.onDatabaseActionFinished(database, actionTask, result)
mEntryEditViewModel.unlockAction()
when (actionTask) {
ACTION_DATABASE_CREATE_ENTRY_TASK,
ACTION_DATABASE_UPDATE_ENTRY_TASK -> {

View File

@@ -39,6 +39,9 @@ class EntryEditViewModel: NodeEditViewModel() {
var backPressedAlreadyApproved = false
var warningOverwriteDataAlreadyApproved = false
// Useful to not relaunch a current action
private var actionLocked: Boolean = false
val templatesEntry : LiveData<TemplatesEntry?> get() = _templatesEntry
private val _templatesEntry = MutableLiveData<TemplatesEntry?>()
@@ -213,45 +216,52 @@ class EntryEditViewModel: NodeEditViewModel() {
_requestEntryInfoUpdate.value = EntryUpdate(database, mEntry, mParent)
}
fun unlockAction() {
actionLocked = false
}
fun saveEntryInfo(database: ContextualDatabase?, entry: Entry?, parent: Group?, entryInfo: EntryInfo) {
IOActionTask(
scope = viewModelScope,
action = {
removeTempAttachmentsNotCompleted(entryInfo)
entry?.let { oldEntry ->
// Create a clone
var newEntry = Entry(oldEntry)
if (actionLocked.not()) {
actionLocked = true
IOActionTask(
scope = viewModelScope,
action = {
removeTempAttachmentsNotCompleted(entryInfo)
entry?.let { oldEntry ->
// Create a clone
var newEntry = Entry(oldEntry)
// Build info
newEntry.setEntryInfo(database, entryInfo)
// Build info
newEntry.setEntryInfo(database, entryInfo)
// Encode entry properties for template
_onTemplateChanged.value?.let { template ->
newEntry =
database?.encodeEntryWithTemplateConfiguration(newEntry, template)
?: newEntry
}
// Encode entry properties for template
_onTemplateChanged.value?.let { template ->
newEntry =
database?.encodeEntryWithTemplateConfiguration(newEntry, template)
?: newEntry
}
// Delete temp attachment if not used
mTempAttachments.forEach { tempAttachmentState ->
val tempAttachment = tempAttachmentState.attachment
database?.attachmentPool?.let { binaryPool ->
if (!newEntry.getAttachments(binaryPool).contains(tempAttachment)) {
database.removeAttachmentIfNotUsed(tempAttachment)
// Delete temp attachment if not used
mTempAttachments.forEach { tempAttachmentState ->
val tempAttachment = tempAttachmentState.attachment
database?.attachmentPool?.let { binaryPool ->
if (!newEntry.getAttachments(binaryPool).contains(tempAttachment)) {
database.removeAttachmentIfNotUsed(tempAttachment)
}
}
}
}
// Return entry to save
EntrySave(oldEntry, newEntry, parent)
// Return entry to save
EntrySave(oldEntry, newEntry, parent)
}
},
onActionComplete = { entrySave ->
entrySave?.let {
_onEntrySaved.value = it
}
}
},
onActionComplete = { entrySave ->
entrySave?.let {
_onEntrySaved.value = it
}
}
).execute()
).execute()
}
}
private fun removeTempAttachmentsNotCompleted(entryInfo: EntryInfo) {

View File

@@ -3,4 +3,4 @@
* Setting to close database after a Passkey selection #2187
* Warning when overwriting existing Passkey #2124
* Autofill refactoring #765 #2196
* Small fixes #2171 #2150 #2159 #2122 #2180
* Small fixes #2171 #2150 #2159 #2122 #2180 #2209

View File

@@ -3,4 +3,4 @@
* Paramètre de fermeture de la base après une sélection de Passkey #2187
* Mise en garde lors de l'écrasement d'un Passkey existant #21124
* Refonte du remplissage automatique #765 #2196
* Petites corrections #2171 #2150 #2159 #2122 #2180
* Petites corrections #2171 #2150 #2159 #2122 #2180 #2209