Skip to content

Commit

Permalink
Merge pull request #955 from nextcloud-libraries/fix/stable4-eslint
Browse files Browse the repository at this point in the history
[stable4] fix: Make eslint happy
  • Loading branch information
susnux committed Aug 25, 2023
2 parents ce973bc + 51f8308 commit 30ad3db
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions lib/components/FilePicker/FileList.vue
Expand Up @@ -104,9 +104,10 @@ const sortBySize = ref<ISortingOptions>(undefined)
const sortByModified = ref<ISortingOptions>(undefined)
const ordering = {
ascending: <T>(a: T, b: T, fn: (a: T, b: T) => number) => fn(a, b),
descending: <T>(a: T, b: T, fn: (a: T, b: T) => number) => fn(b, a),
none: <T>(a: T, b: T, fn: (a: T, b: T) => number) => 0,
ascending: <T, >(a: T, b: T, fn: (a: T, b: T) => number) => fn(a, b),
descending: <T, >(a: T, b: T, fn: (a: T, b: T) => number) => fn(b, a),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
none: <T, >(a: T, b: T, fn: (a: T, b: T) => number) => 0,
}
const byName = (a: Node, b: Node) => (a.attributes?.displayName || a.basename).localeCompare(b.attributes?.displayName || b.basename, getCanonicalLocale())
Expand All @@ -133,17 +134,16 @@ const toggleSortByModified = () => toggleSorting(sortByModified)
* Files sorted by columns
*/
const sortedFiles = computed(() => [...props.files].sort(
(a, b) =>
// Folders always come above the files
(b.type === FileType.Folder ? 1 : 0) - (a.type === FileType.Folder ? 1 : 0) ||
// Favorites above other files
// (b.attributes?.favorite || false) - (a.attributes?.favorite || false) ||
// then sort by name / size / modified
ordering[sortByName.value || 'none'](a, b, byName) ||
ordering[sortBySize.value || 'none'](a, b, bySize) ||
ordering[sortByModified.value || 'none'](a, b, byDate)
)
)
(a, b) =>
// Folders always come above the files
(b.type === FileType.Folder ? 1 : 0) - (a.type === FileType.Folder ? 1 : 0)
// Favorites above other files
// (b.attributes?.favorite || false) - (a.attributes?.favorite || false) ||
// then sort by name / size / modified
|| ordering[sortByName.value || 'none'](a, b, byName)
|| ordering[sortBySize.value || 'none'](a, b, bySize)
|| ordering[sortByModified.value || 'none'](a, b, byDate),
))
/**
* Contains the selectable files, filtering out directories if `allowPickDirectory` is not set
Expand Down
2 changes: 1 addition & 1 deletion lib/components/FilePicker/FileListRow.vue
Expand Up @@ -36,7 +36,7 @@
</tr>
</template>
<script setup lang="ts">
import { type Node, formatFileSize } from '@nextcloud/files'
import { type Node, formatFileSize, FileType } from '@nextcloud/files'
import { NcCheckboxRadioSwitch } from '@nextcloud/vue'
import { computed } from 'vue'
import { t } from '../../utils/l10n'
Expand Down

0 comments on commit 30ad3db

Please sign in to comment.