diff --git a/src/actions/openInLibreSignAction.js b/src/actions/openInLibreSignAction.js index aff1150789..6a45cc32ea 100644 --- a/src/actions/openInLibreSignAction.js +++ b/src/actions/openInLibreSignAction.js @@ -3,6 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ import { registerFileAction, FileAction, getSidebar } from '@nextcloud/files' +import { emit } from '@nextcloud/event-bus' import { getCapabilities } from '@nextcloud/capabilities' import { loadState } from '@nextcloud/initial-state' import { translate as t } from '@nextcloud/l10n' @@ -10,6 +11,7 @@ import { showError } from '@nextcloud/dialogs' import { spawnDialog } from '@nextcloud/vue/functions/dialog' import axios from '@nextcloud/axios' import { generateOcsUrl } from '@nextcloud/router' +import { getClient, getDefaultPropfind, getRootPath, resultToNode } from '@nextcloud/files/dav' import EditNameDialog from '../Components/Common/EditNameDialog.vue' // eslint-disable-next-line import/no-unresolved @@ -41,6 +43,25 @@ function promptEnvelopeName() { }) } +async function emitEnvelopeNodeCreated(envelopePath) { + const client = getClient() + const propfindPayload = getDefaultPropfind() + const rootPath = getRootPath() + + const result = await client.stat(`${rootPath}${envelopePath}`, { + details: true, + data: propfindPayload, + }) + emit('files:node:created', resultToNode(result.data)) + + const parentPath = envelopePath.substring(0, envelopePath.lastIndexOf('/')) || '/' + const parentResult = await client.stat(`${rootPath}${parentPath}`, { + details: true, + data: propfindPayload, + }) + emit('files:node:updated', resultToNode(parentResult.data)) +} + export const action = new FileAction({ id: 'open-in-libresign', displayName: () => t('libresign', 'Open in LibreSign'), @@ -107,6 +128,8 @@ export const action = new FileAction({ window.OCA.Libresign.pendingEnvelope = envelopeData + await emitEnvelopeNodeCreated(envelopePath) + const sidebar = getSidebar() const firstNode = nodes[0] await sidebar.open(firstNode, 'libresign')