@ -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 ( ) {
/ / w a i t f o r s c r o l l i n g a n d u p d a t i n g t h e a c t i o n s t o s e t t l e
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 )
/ / I f t h e f i l e l i s t i s m o u n t e d w i t h a f i l e I d s p e c i f i e d
/ / t h e n w e n e e d t o o p e n t h e s i d e b a r i n i t i a l l y
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 ( ) {
/ / I f t h e S i d e b a r i s c l o s e d a n d i f o p e n F i l e i s f a l s e , r e m o v e t h e f i l e i d f r o m t h e U R L
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
}
@ -282,7 +298,7 @@ export default defineComponent({
. at ( 0 )
/ / S o m e f i l e t y p e s d o n o t h a v e a d e f a u l t a c t i o n ( e . g . t h e y c a n o n l y b e d o w n l o a d e d )
/ / S o i f t h e r e i s a n e n a b l e d d e f a u l t a c t i o n , s o e x e c u t e i t
defaultAction ? . exec ( node , this . currentView , this . currentFolder . path )
defaultAction ? . exec ( node , this . currentView , this . currentFolderpath )
} ,
onDragOver ( event : DragEvent ) {