Skip to content

Commit ad5ab8d

Browse files
committed
fix(files): discard stale drafts after signed states
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> (cherry picked from commit e66bc69) Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent cd00ac4 commit ad5ab8d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/store/files.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { useFilesSortingStore } from './filesSorting.js'
1818
import { useFiltersStore } from './filters.js'
1919
import { useIdentificationDocumentStore } from './identificationDocument.js'
2020
import { useSidebarStore } from './sidebar.js'
21+
import { FILE_STATUS } from '../constants.js'
2122

2223
/** @typedef {import('../types/index').IdentifyMethodRecord} SignerMethodRecord */
2324
/** @typedef {import('../types/index').FileSettings} FileSettings */
@@ -248,6 +249,13 @@ const _filesStore = defineStore('files', () => {
248249
}
249250
: file
250251

252+
const shouldDiscardDraftForServerState = (file) => {
253+
const status = Number(file?.status)
254+
return status === FILE_STATUS.PARTIAL_SIGNED
255+
|| status === FILE_STATUS.SIGNED
256+
|| status === FILE_STATUS.SIGNING_IN_PROGRESS
257+
}
258+
251259
const syncPublicFile = (fileId) => {
252260
if (!fileId) {
253261
return null
@@ -348,6 +356,9 @@ const _filesStore = defineStore('files', () => {
348356
}
349357

350358
const key = file.id ?? null
359+
if (shouldDiscardDraftForServerState(file)) {
360+
clearRequestDraft(key)
361+
}
351362
const existingFile = apiFiles.value[key] || files.value[key]
352363
const resolvedDetailsLoaded = detailsLoaded
353364
?? file.detailsLoaded

0 commit comments

Comments
 (0)