Skip to content

Commit

Permalink
feat: Reset route if neither the Viewer of the Sidebar is open
Browse files Browse the repository at this point in the history
When the viewer or the sidebar is opened, we add the fileid to the route.

When both of them are closed, we do not remove the fileid from the route.

This means that, upon reload, the sidebar will be opened even though it was closed previously.

This PR ensure that the fileid is removed from the route when both the Sidebar and the Viewer are closed.

Signed-off-by: Louis Chemineau <louis@chmn.me>

[skip ci]
  • Loading branch information
artonge authored and backportbot[bot] committed Sep 15, 2024
1 parent 124b565 commit 962c703
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions apps/files/src/components/FilesListVirtual.vue
Original file line number Diff line number Diff line change
Expand Up @@ -231,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: {
Expand Down Expand Up @@ -258,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
}
Expand All @@ -289,7 +298,7 @@ export default defineComponent({
.at(0)
// Some file types do not have a default action (e.g. they can only be downloaded)
// So if there is an enabled default action, so execute it
defaultAction?.exec(node, this.currentView, this.currentFolder.path)
defaultAction?.exec(node, this.currentView, this.currentFolderpath)
},
onDragOver(event: DragEvent) {
Expand Down

0 comments on commit 962c703

Please sign in to comment.