diff options
author | Louis <louis@chmn.me> | 2024-09-16 14:21:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-16 14:21:19 +0200 |
commit | 139b2cdb6d7a91b74b1db4e74328631a5af0c3f6 (patch) | |
tree | 13cbb1a03f6ec0f4bb5c8f4c9227488597392c8b /apps | |
parent | e4074b6d54f699bb0f2453744179c757a85a9495 (diff) | |
parent | f44c76e61d87606e0e96c58125a9f97d5d930992 (diff) | |
download | nextcloud-server-139b2cdb6d7a91b74b1db4e74328631a5af0c3f6.tar.gz nextcloud-server-139b2cdb6d7a91b74b1db4e74328631a5af0c3f6.zip |
Merge pull request #48000 from nextcloud/backport/47920/stable30
[stable30] feat: Reset route if neither the Viewer of the Sidebar is open
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/src/components/FilesListVirtual.vue | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/apps/files/src/components/FilesListVirtual.vue b/apps/files/src/components/FilesListVirtual.vue index 814cbd54104..a6e0862aabe 100644 --- a/apps/files/src/components/FilesListVirtual.vue +++ b/apps/files/src/components/FilesListVirtual.vue @@ -65,6 +65,7 @@ import type { UserConfig } from '../types' import { getFileListHeaders, Folder, View, getFileActions, FileType } from '@nextcloud/files' import { showError } from '@nextcloud/dialogs' import { translate as t } from '@nextcloud/l10n' +import { subscribe, unsubscribe } from '@nextcloud/event-bus' import { defineComponent } from 'vue' import { action as sidebarAction } from '../actions/sidebarAction.ts' @@ -200,8 +201,12 @@ export default defineComponent({ handler() { // wait for scrolling and updating the actions to settle this.$nextTick(() => { - if (this.fileId && this.openFile) { - this.handleOpenFile(this.fileId) + if (this.fileId) { + if (this.openFile) { + this.handleOpenFile(this.fileId) + } else { + this.unselectFile() + } } }) }, @@ -214,6 +219,8 @@ export default defineComponent({ const mainContent = window.document.querySelector('main.app-content') as HTMLElement mainContent.addEventListener('dragover', this.onDragOver) + subscribe('files:sidebar:closed', this.unselectFile) + // If the file list is mounted with a fileId specified // then we need to open the sidebar initially if (this.fileId) { @@ -224,6 +231,8 @@ export default defineComponent({ beforeDestroy() { const mainContent = window.document.querySelector('main.app-content') as HTMLElement mainContent.removeEventListener('dragover', this.onDragOver) + + unsubscribe('files:sidebar:closed', this.unselectFile) }, methods: { @@ -251,15 +260,22 @@ export default defineComponent({ } }, + unselectFile() { + // If the Sidebar is closed and if openFile is false, remove the file id from the URL + if (!this.openFile && OCA.Files.Sidebar.file === '') { + window.OCP.Files.Router.goToRoute( + null, + { ...this.$route.params, fileid: String(this.currentFolder.fileid ?? '') }, + this.$route.query, + ) + } + }, + /** * Handle opening a file (e.g. by ?openfile=true) * @param fileId File to open */ handleOpenFile(fileId: number|null) { - if (!this.openFile) { - return - } - if (fileId === null || this.openFileId === fileId) { return } |