@@ -180,15 +180,15 @@ import Vue, { defineComponent } from 'vue'
180180
181181import  { emit , subscribe , unsubscribe  } from  ' @nextcloud/event-bus' 
182182import  { loadState  } from  ' @nextcloud/initial-state' 
183- import  { File  as  NcFile , Node , davRemoteURL , davRootPath , davGetRootPath  } from  ' @nextcloud/files' 
183+ import  { File  as  NcFile , Node , davRemoteURL , davRootPath , davGetRootPath ,  sortNodes  } from  ' @nextcloud/files' 
184184import  { showError  } from  ' @nextcloud/dialogs' 
185185import  axios  from  ' @nextcloud/axios' 
186186
187187import  isFullscreen  from  ' @nextcloud/vue/dist/Mixins/isFullscreen.js' 
188188import  isMobile  from  ' @nextcloud/vue/dist/Mixins/isMobile.js' 
189189
190190import  { canDownload  } from  ' ../utils/canDownload.ts' 
191- import  { extractFilePaths , sortCompare ,  extractFilePathFromSource  } from  ' ../utils/fileUtils.ts' 
191+ import  { extractFilePaths , extractFilePathFromSource  } from  ' ../utils/fileUtils.ts' 
192192import  getSortingConfig  from  ' ../services/FileSortingConfig.ts' 
193193import  cancelableRequest  from  ' ../utils/CancelableRequest.js' 
194194import  Error  from  ' ../components/Error.vue' 
@@ -770,7 +770,23 @@ export default defineComponent({
770770				//  sort like the files list 
771771				//  TODO: implement global sorting API 
772772				//  https://github.com/nextcloud/server/blob/a83b79c5f8ab20ed9b4d751167417a65fa3c42b8/apps/files/lib/Controller/ApiController.php#L247 
773- 				this .fileList  =  filteredFiles .sort ((a , b ) =>  sortCompare (a, b, this .sortingConfig .key , this .sortingConfig .asc )) 
773+ 				const  url  =  this .currentFile .source  ??  this .currentFile .davPath  
774+ 				const  nodes  =  filteredFiles .map ( 
775+ 					file  =>  new  NcFile ({ 
776+ 						source:  davRemoteURL +  davGetRootPath () +  file .filename , 
777+ 						fileid:  file .fileid , 
778+ 						displayname:  file .displayname , 
779+ 						mime:  file .mime , 
780+ 						mtime:  new  Date (file .lastmod ), 
781+ 						owner:  this .currentFile .ownerId , 
782+ 						root:  url .includes (' remote.php/dav' ?  davGetRootPath () :  undefined , 
783+ 					}), 
784+ 				) 
785+ 				const  sortedNodes  =  sortNodes (nodes, { 
786+ 					sortingMode:  this .sortingConfig .key , 
787+ 					sortingOrder:  this .sortingConfig .asc  ?  ' asc' :  ' desc'  
788+ 				}) 
789+ 				this .fileList  =  sortedNodes .map (node  =>  filteredFiles .find (file  =>  file .filename  ===  node .path )) 
774790
775791				//  store current position 
776792				this .currentIndex  =  this .fileList .findIndex (file  =>  file .filename  ===  fileInfo .filename ) 
0 commit comments