Skip to content

Commit 2d31132

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]>
1 parent 46c2498 commit 2d31132

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

src/actions/openInLibreSignAction.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55
import { registerFileAction, FileAction, getSidebar } from '@nextcloud/files'
6+
import { emit } from '@nextcloud/event-bus'
67
import { getCapabilities } from '@nextcloud/capabilities'
78
import { loadState } from '@nextcloud/initial-state'
89
import { translate as t } from '@nextcloud/l10n'
910
import { showError } from '@nextcloud/dialogs'
1011
import { spawnDialog } from '@nextcloud/vue/functions/dialog'
1112
import axios from '@nextcloud/axios'
1213
import { generateOcsUrl } from '@nextcloud/router'
14+
import { getClient, getDefaultPropfind, getRootPath, resultToNode } from '@nextcloud/files/dav'
1315
import EditNameDialog from '../Components/Common/EditNameDialog.vue'
1416

1517
// eslint-disable-next-line import/no-unresolved
@@ -41,6 +43,25 @@ function promptEnvelopeName() {
4143
})
4244
}
4345

46+
async function emitEnvelopeNodeCreated(envelopePath) {
47+
const client = getClient()
48+
const propfindPayload = getDefaultPropfind()
49+
const rootPath = getRootPath()
50+
51+
const result = await client.stat(`${rootPath}${envelopePath}`, {
52+
details: true,
53+
data: propfindPayload,
54+
})
55+
emit('files:node:created', resultToNode(result.data))
56+
57+
const parentPath = envelopePath.substring(0, envelopePath.lastIndexOf('/')) || '/'
58+
const parentResult = await client.stat(`${rootPath}${parentPath}`, {
59+
details: true,
60+
data: propfindPayload,
61+
})
62+
emit('files:node:updated', resultToNode(parentResult.data))
63+
}
64+
4465
export const action = new FileAction({
4566
id: 'open-in-libresign',
4667
displayName: () => t('libresign', 'Open in LibreSign'),
@@ -107,6 +128,8 @@ export const action = new FileAction({
107128

108129
window.OCA.Libresign.pendingEnvelope = envelopeData
109130

131+
await emitEnvelopeNodeCreated(envelopePath)
132+
110133
const sidebar = getSidebar()
111134
const firstNode = nodes[0]
112135
await sidebar.open(firstNode, 'libresign')

0 commit comments

Comments
 (0)