Skip to content

Commit 07e5c96

Browse files
committed
fix: update Files list when envelope is created
When creating an envelope in the Files app by selecting multiple PDFs, the envelope folder was created but the Files list did not refresh to show the newly created folder. This commit adds event emissions to notify the Files app: - files:node:created event for the envelope folder - files:node:updated event for the parent directory This ensures the Files list is updated immediately after envelope creation without requiring a page refresh. Signed-off-by: Vitor Mattos <[email protected]> [skip ci] Signed-off-by: Vitor Mattos <[email protected]>
1 parent 7fe7176 commit 07e5c96

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/actions/openInLibreSignAction.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { showError } from '@nextcloud/dialogs'
1010
import { spawnDialog } from '@nextcloud/vue/functions/dialog'
1111
import axios from '@nextcloud/axios'
1212
import { generateOcsUrl } from '@nextcloud/router'
13+
import { getClient, getDefaultPropfind, getRootPath, resultToNode } from '@nextcloud/files/dav'
1314
import EditNameDialog from '../Components/Common/EditNameDialog.vue'
1415

1516
// eslint-disable-next-line import/no-unresolved
@@ -41,6 +42,25 @@ function promptEnvelopeName() {
4142
})
4243
}
4344

45+
async function emitEnvelopeNodeCreated(envelopePath) {
46+
const client = getClient()
47+
const propfindPayload = getDefaultPropfind()
48+
const rootPath = getRootPath()
49+
50+
const result = await client.stat(`${rootPath}${envelopePath}`, {
51+
details: true,
52+
data: propfindPayload,
53+
})
54+
emit('files:node:created', resultToNode(result.data))
55+
56+
const parentPath = envelopePath.substring(0, envelopePath.lastIndexOf('/')) || '/'
57+
const parentResult = await client.stat(`${rootPath}${parentPath}`, {
58+
details: true,
59+
data: propfindPayload,
60+
})
61+
emit('files:node:updated', resultToNode(parentResult.data))
62+
}
63+
4464
export const action = new FileAction({
4565
id: 'open-in-libresign',
4666
displayName: () => t('libresign', 'Open in LibreSign'),
@@ -89,11 +109,13 @@ export const action = new FileAction({
89109
settings: {
90110
path: envelopePath,
91111
},
92-
}).then((response) => {
112+
}).then(async (response) => {
93113
const envelopeData = response.data?.ocs?.data
94114

95115
window.OCA.Libresign.pendingEnvelope = envelopeData
96116

117+
await emitEnvelopeNodeCreated(envelopePath)
118+
97119
window.OCA.Files.Sidebar.close()
98120

99121
window.OCA.Files.Sidebar.setActiveTab('libresign')

0 commit comments

Comments
 (0)