A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
chore: code smells
aminnausin1f5b064e33f8
diff --git a/resources/css/app.css b/resources/css/app.cssindex 80099508..730024c8 100755--- a/resources/css/app.css+++ b/resources/css/app.css@@ -71,15 +71,15 @@--font-dm-sans: 'DM Sans', sans-serif;--font-klee-one: 'Klee One', 'DM Sans', sans-serif;--font-sans: 'Figtree', ui-sans-serif, system-ui, sans-serif;+--mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;+ --font-mono: var(--mono);--font-jetbrains-mono: 'JetBrains Mono', var(--mono);--font-geist-mono: 'Geist Mono', var(--mono);--font-commit-mono: 'Commit Mono', var(--mono);- --font-mono: var(--mono);- --font-klee-one-mono: 'Klee One', var(--font-commit-mono);- /* --font-lyrics: 'Ma Shan Zheng', var(--mono); */- /* --font-lyrics: 'Ma Shan Zheng', 'Klee One', var(--font-commit-mono); */--font-lyrics: 'Klee One', var(--font-commit-mono);+ --font-lyrics-cn: 'Ma Shan Zheng', var(--mono);+ --font-lyrics-mixed: 'Ma Shan Zheng', 'Klee One', var(--font-commit-mono);/* Aspect ratios */--aspect-video: 16 / 9;diff --git a/resources/js/components/video/plugins/lyrics/VideoLyrics.vue b/resources/js/components/video/plugins/lyrics/VideoLyrics.vueindex d5f5f668..862233ad 100644--- a/resources/js/components/video/plugins/lyrics/VideoLyrics.vue+++ b/resources/js/components/video/plugins/lyrics/VideoLyrics.vue@@ -69,7 +69,7 @@ const toPercentageTime = (seconds: number): number => {const handleClick = (id: string, seconds: number, play?: boolean) => {if (seconds === activeTime.value) focusScroll(document.getElementById(id));- const isAtTime = Math.abs((props.player?.currentTime ?? NaN) - seconds) < 0.01;+ const isAtTime = Math.abs((props.player?.currentTime ?? Number.NaN) - seconds) < 0.01;if (play && isAtTime && props.isPaused) {emit('play');@@ -159,7 +159,7 @@ const resetComponent = () => {activeTime.value = lyrics.value[0].percentage;}- if (!!lyricItems.value.at(0)?.percentage) {+ if (lyricItems.value.at(0)?.percentage) {isFocusedScroll.value = true;activeIndex.value = 0;} else {diff --git a/resources/js/service/sort/baseSort.ts b/resources/js/service/sort/baseSort.tsindex e7bbf995..da8632a5 100644--- a/resources/js/service/sort/baseSort.ts+++ b/resources/js/service/sort/baseSort.ts@@ -28,17 +28,12 @@ export function sortObjectNew<T extends { id?: any }>(keys: SortKey<T>[], direct// Loops through keys and returns the first non 0 sort result (so same episode number will be skipped and move on to comparing seasons)for (const { key, compareFn, nullsLast } of keys) {// Sort null values to end of list- if (key && nullsLast) {- const aNull = a[key] == null;- const bNull = b[key] == null;- if (aNull && !bNull) return 1;- if (!aNull && bNull) return -1;- if (aNull && bNull) return 0;- }+ const nullCheck = nullCompare(a, b, key, nullsLast);+ if (nullCheck !== undefined) return nullCheck;- const valueA = key ? (a[key] ?? '') : undefined;- const valueB = key ? (b[key] ?? '') : undefined;+ const valueA = parseKeyedValue(a, key);+ const valueB = parseKeyedValue(b, key);let result: number;@@ -55,8 +50,8 @@ export function sortObjectNew<T extends { id?: any }>(keys: SortKey<T>[], direct}function defaultCompare(a: any, b: any): number {- const numA = typeof a === 'number' || (typeof a === 'string' && a.trim() !== '' && !Number.isNaN(Number(a))) ? Number(a) : NaN;- const numB = typeof b === 'number' || (typeof b === 'string' && b.trim() !== '' && !Number.isNaN(Number(b))) ? Number(b) : NaN;+ const numA = typeof a === 'number' || (typeof a === 'string' && a.trim() !== '' && !Number.isNaN(Number(a))) ? Number(a) : Number.NaN;+ const numB = typeof b === 'number' || (typeof b === 'string' && b.trim() !== '' && !Number.isNaN(Number(b))) ? Number(b) : Number.NaN;if (!Number.isNaN(numA) && !Number.isNaN(numB)) {return numA - numB;@@ -70,3 +65,18 @@ function defaultCompare(a: any, b: any): number {return CompareStrategies.stringInsensitive(a, b);}++function nullCompare<T>(a: T, b: T, key?: keyof T, nullsLast?: boolean): number | undefined {+ if (key && nullsLast) {+ const aNull = a[key] == null;+ const bNull = b[key] == null;++ if (aNull && !bNull) return 1;+ if (!aNull && bNull) return -1;+ if (aNull && bNull) return 0;+ }+}++function parseKeyedValue<T>(obj: T, key?: keyof T, defaultValue: unknown = '') {+ return key ? (obj[key] ?? defaultValue) : undefined;+}