You've already forked pages
forked from didirus/AstralRinth
fix: remove client side sorting of files (#4240)
* fix: remove default sorting on files page * fix: lint
This commit is contained in:
@@ -143,7 +143,7 @@ const codeExtensions = Object.freeze([
|
||||
'go',
|
||||
])
|
||||
|
||||
const textExtensions = Object.freeze(['txt', 'md', 'log', 'cfg', 'conf', 'properties', 'ini'])
|
||||
const textExtensions = Object.freeze(['txt', 'md', 'log', 'cfg', 'conf', 'properties', 'ini', 'sk'])
|
||||
const imageExtensions = Object.freeze(['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp'])
|
||||
const supportedArchiveExtensions = Object.freeze(['zip'])
|
||||
const units = Object.freeze(['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'])
|
||||
|
||||
@@ -393,13 +393,13 @@ const fetchDirectoryContents = async (): Promise<DirectoryResponse> => {
|
||||
|
||||
if (currentPage.value === 1) {
|
||||
return {
|
||||
items: applyDefaultSort(data.items),
|
||||
items: data.items,
|
||||
total: data.total,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
items: [...(directoryData.value?.items || []), ...applyDefaultSort(data.items)],
|
||||
items: [...(directoryData.value?.items || []), ...data.items],
|
||||
total: data.total,
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -727,15 +727,6 @@ const handleCreateError = (error: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
const applyDefaultSort = (items: DirectoryItem[]) => {
|
||||
return items.sort((a: any, b: any) => {
|
||||
if (a.type === 'directory' && b.type !== 'directory') return -1
|
||||
if (a.type !== 'directory' && b.type === 'directory') return 1
|
||||
|
||||
return a.name.localeCompare(b.name)
|
||||
})
|
||||
}
|
||||
|
||||
const handleSort = (field: string) => {
|
||||
if (sortMethod.value === field) {
|
||||
sortDesc.value = !sortDesc.value
|
||||
|
||||
Reference in New Issue
Block a user