Skip to content

Commit 18777af

Browse files
committed
feat(files): sort local files first - used when filtering + local search
Signed-off-by: Ferdinand Thiessen <[email protected]>
1 parent 3978e05 commit 18777af

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

apps/files/src/views/FilesList.vue

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ import { getCapabilities } from '@nextcloud/capabilities'
155155
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
156156
import { Node, Permission, sortNodes, getFileListActions } from '@nextcloud/files'
157157
import { translate as t } from '@nextcloud/l10n'
158-
import { join, dirname, normalize } from 'path'
158+
import { join, dirname, normalize, relative } from 'path'
159159
import { showError, showSuccess, showWarning } from '@nextcloud/dialogs'
160160
import { ShareType } from '@nextcloud/sharing'
161161
import { UploadPicker, UploadStatus } from '@nextcloud/upload'
@@ -356,12 +356,28 @@ export default defineComponent({
356356
return this.isAscSorting ? results : results.reverse()
357357
}
358358
359-
return sortNodes(this.dirContentsFiltered, {
359+
const nodes = sortNodes(this.dirContentsFiltered, {
360360
sortFavoritesFirst: this.userConfig.sort_favorites_first,
361361
sortFoldersFirst: this.userConfig.sort_folders_first,
362362
sortingMode: this.sortingMode,
363363
sortingOrder: this.isAscSorting ? 'asc' : 'desc',
364364
})
365+
366+
// TODO upstream this
367+
if (this.currentView.id === 'files') {
368+
nodes.sort((a, b) => {
369+
const aa = relative(a.source, this.currentFolder!.source) === '..'
370+
const bb = relative(b.source, this.currentFolder!.source) === '..'
371+
if (aa && bb) {
372+
return 0
373+
} else if (aa) {
374+
return -1
375+
}
376+
return 1
377+
})
378+
}
379+
380+
return nodes
365381
},
366382
367383
/**

0 commit comments

Comments
 (0)