chore(files): Provide old node on moved

Signed-off-by: Christopher Ng <chrng8@gmail.com>
This commit is contained in:
Christopher Ng 2024-09-13 17:31:25 -07:00
parent 26aa322e44
commit fb87dc331b
2 changed files with 4 additions and 4 deletions

View file

@ -46,7 +46,6 @@ import { showError, showSuccess } from '@nextcloud/dialogs'
import { emit } from '@nextcloud/event-bus'
import { FileType, NodeStatus } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import { dirname } from '@nextcloud/paths'
import { defineComponent, inject } from 'vue'
import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'
@ -244,6 +243,7 @@ export default defineComponent({
return
}
const oldNode = this.source.clone()
const oldName = this.source.basename
const oldEncodedSource = this.source.encodedSource
if (oldName === newName) {
@ -272,8 +272,8 @@ export default defineComponent({
emit('files:node:updated', this.source)
emit('files:node:renamed', this.source)
emit('files:node:moved', {
node: this.source,
oldSource: `${dirname(this.source.source)}/${oldName}`,
newNode: this.source,
oldNode,
})
showSuccess(t('files', 'Renamed "{oldName}" to "{newName}"', { oldName, newName }))

View file

@ -16,7 +16,7 @@ declare module '@nextcloud/event-bus' {
'files:node:deleted': Node
'files:node:updated': Node
'files:node:renamed': Node
'files:node:moved': { node: Node, oldSource: string }
'files:node:moved': { newNode: Node, oldNode: Node }
'files:filter:added': IFileListFilter
'files:filter:removed': string