Skip to content

Commit ff0ce0e

Browse files
authored
Merge pull request #6313 from LibreSign/fix/files-list-update-on-envelope-creation
fix: update Files list when envelope is created
2 parents 46c2498 + 2d31132 commit ff0ce0e

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)