diff --git a/src/components/dialog/DialogDownloadsPopup.vue b/src/components/dialog/DialogDownloadsPopup.vue index 46afdbb3e4..1be6b9878e 100644 --- a/src/components/dialog/DialogDownloadsPopup.vue +++ b/src/components/dialog/DialogDownloadsPopup.vue @@ -94,6 +94,7 @@ import type { DownloadProgressItems } from 'src/types'; import { watchImmediate } from '@vueuse/core'; import { storeToRefs } from 'pinia'; import { useScrollbar } from 'src/composables/useScrollbar'; +import { sorter } from 'src/helpers/general'; import { useCurrentStateStore } from 'src/stores/current-state'; import { useTemplateRef } from 'vue'; @@ -108,7 +109,7 @@ const { downloadProgress } = storeToRefs(currentState); const filteredDownloads = (status: 'complete' | 'error' | 'loaded') => Object.entries(downloadProgress.value || {}) .filter(([, item]) => item[status]) - .sort((a, b) => a[1].filename.localeCompare(b[1].filename)) + .sort((a, b) => sorter.compare(a[1].filename, b[1].filename)) .map(([, item]) => item); const downloadPopup = useTemplateRef('downloadPopup'); diff --git a/src/components/form-inputs/SelectInput.vue b/src/components/form-inputs/SelectInput.vue index aa4109bbdd..ebcfb237b8 100644 --- a/src/components/form-inputs/SelectInput.vue +++ b/src/components/form-inputs/SelectInput.vue @@ -31,6 +31,7 @@ import { storeToRefs } from 'pinia'; import { useLocale } from 'src/composables/useLocale'; import { RESOLUTIONS } from 'src/constants/settings'; import { errorCatcher } from 'src/helpers/error-catcher'; +import { sorter } from 'src/helpers/general'; import { configuredScenesAreAllUUIDs } from 'src/helpers/obs'; import { getRules } from 'src/helpers/settings'; import { localeOptions } from 'src/i18n'; @@ -120,7 +121,7 @@ const listOptions = computed(() => { }); } else if (props.list === 'appLanguages') { return [...filteredLocaleAppLang.value] - .sort((a, b) => a.englishName.localeCompare(b.englishName)) + .sort((a, b) => sorter.compare(a.englishName, b.englishName)) .map((language) => { return { label: diff --git a/src/helpers/general.ts b/src/helpers/general.ts index af5217ee33..d3f0aa43d2 100644 --- a/src/helpers/general.ts +++ b/src/helpers/general.ts @@ -39,3 +39,8 @@ export const isVersionValid = ( return true; }; + +export const sorter = new Intl.Collator(undefined, { + numeric: true, + sensitivity: 'base', +}); diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index 2db9dc2690..6812f631e6 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -65,6 +65,7 @@ import { import { errorCatcher } from 'src/helpers/error-catcher'; import { setElementFont } from 'src/helpers/fonts'; import { getFileUrl, watchExternalFolder } from 'src/helpers/fs'; +import { sorter } from 'src/helpers/general'; import { downloadBackgroundMusic, downloadSongbookVideos, @@ -320,7 +321,7 @@ const updateWatchFolderRef = async ({ watchFolderMedia.value[day].push(watchedItemMap); watchFolderMedia.value[day].sort((a, b) => - a.title.localeCompare(b.title), + sorter.compare(a.title, b.title), ); if (jwStore.mediaSort[currentCongregation.value]?.[day]?.length) { diff --git a/src/pages/MediaCalendarPage.vue b/src/pages/MediaCalendarPage.vue index dcde979435..8d820afc5e 100644 --- a/src/pages/MediaCalendarPage.vue +++ b/src/pages/MediaCalendarPage.vue @@ -491,6 +491,7 @@ import { getTempDirectory, getThumbnailUrl, } from 'src/helpers/fs'; +import { sorter } from 'src/helpers/general'; import { addJwpubDocumentMediaToFiles, downloadFileIfNeeded, @@ -1544,12 +1545,7 @@ const dropEnd = (event: DragEvent) => { type: file.type, }; }) - .sort((a, b) => - a?.path?.localeCompare(b?.path, undefined, { - numeric: true, - sensitivity: 'base', - }), - ); + .sort((a, b) => sorter.compare(a?.path, b?.path)); let noLocalDroppedFiles = droppedStuff.filter((file) => file.path).length === 0; if (noLocalDroppedFiles && droppedStuff.length > 0) { diff --git a/src/types/jw/publications.d.ts b/src/types/jw/publications.d.ts index e9eba5422a..d1b028d9a1 100644 --- a/src/types/jw/publications.d.ts +++ b/src/types/jw/publications.d.ts @@ -148,17 +148,21 @@ export interface PublicationFetcher { } export interface ImageSizes { - lg: string; - md: string; - sm: string; - xl: string; + lg?: string; + md?: string; + sm?: string; + xl?: string; + xs?: string; } export interface ImageTypeSizes { - lsr: ImageSizes; - pnr: ImageSizes; - sqr: ImageSizes; - wss: ImageSizes; + lsr?: ImageSizes; + lss?: ImageSizes; + pnr?: ImageSizes; + sqr?: ImageSizes; + sqs?: ImageSizes; + wsr?: ImageSizes; + wss?: ImageSizes; } export interface JwVideoCategoryListings {