Skip to content

Commit 939bf15

Browse files
committed
fix: Preserve selectedNodeId during file fetch and send correct identifier
Fix issue where selectedNodeId was being reset to 0 when addFile() called getAllFiles(). The getAllFiles method resets selectedNodeId when the file doesn't exist in the store yet, causing problems when adding new files from the Nextcloud Files app. Also update payload logic in saveWithVisibleElements and updateSignatureRequest to send either fileId (for existing LibreSign files) or nodeId (for new Nextcloud files) based on whether file.id exists. This ensures the backend receives the correct identifier type for each scenario. Signed-off-by: Vitor Mattos <[email protected]>
1 parent a37e37f commit 939bf15

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/store/files.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ export const useFilesStore = function(...args) {
5050
? { file_id: file.id, force_fetch: true }
5151
: { 'nodeIds[]': [nodeId], force_fetch: true }
5252

53+
const savedSelectedNodeId = this.selectedNodeId
5354
const fetchedFiles = await this.getAllFiles(filter)
5455
fileData = fetchedFiles[nodeId] || { ...file, signers: [] }
56+
this.selectedNodeId = savedSelectedNodeId
5557
}
5658

5759
if (fileData.signers) {
@@ -531,9 +533,13 @@ export const useFilesStore = function(...args) {
531533

532534
if (uuid || file.uuid) {
533535
config.data.uuid = uuid || file.uuid
534-
} else {
536+
} else if (file.id) {
537+
config.data.file = {
538+
fileId: file.id,
539+
}
540+
} else if (file.nodeId) {
535541
config.data.file = {
536-
fileId: fileId || this.getFile().id,
542+
nodeId: file.nodeId,
537543
}
538544
}
539545

@@ -571,9 +577,13 @@ export const useFilesStore = function(...args) {
571577

572578
if (uuid || file.uuid) {
573579
config.data.uuid = uuid || file.uuid
574-
} else {
580+
} else if (file.id) {
581+
config.data.file = {
582+
fileId: file.id,
583+
}
584+
} else if (file.nodeId) {
575585
config.data.file = {
576-
fileId: fileId || this.getFile().id,
586+
nodeId: file.nodeId,
577587
}
578588
}
579589
const { data } = await axios(config)

0 commit comments

Comments
 (0)