fix svelte-check errors in /listen page: use meta_updated for sort, untrack data props
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { untrack } from 'svelte';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { audioStore } from '$lib/audio.svelte';
|
import { audioStore } from '$lib/audio.svelte';
|
||||||
import type { PageData } from './$types';
|
import type { PageData } from './$types';
|
||||||
|
|
||||||
let { data }: { data: PageData } = $props();
|
let { data }: { data: PageData } = $props();
|
||||||
|
|
||||||
let q = $state(data.q);
|
let q = $state(untrack(() => data.q));
|
||||||
let sort = $state(data.sort);
|
let sort = $state(untrack(() => data.sort));
|
||||||
|
|
||||||
function parseGenres(genres: string[] | string | null | undefined): string[] {
|
function parseGenres(genres: string[] | string | null | undefined): string[] {
|
||||||
if (!genres) return [];
|
if (!genres) return [];
|
||||||
@@ -35,8 +36,8 @@
|
|||||||
list = [...list].sort((a, b) => (a.book.title ?? '').localeCompare(b.book.title ?? ''));
|
list = [...list].sort((a, b) => (a.book.title ?? '').localeCompare(b.book.title ?? ''));
|
||||||
} else if (sort === 'recent') {
|
} else if (sort === 'recent') {
|
||||||
list = [...list].sort((a, b) => {
|
list = [...list].sort((a, b) => {
|
||||||
const da = a.book.updated ?? a.book.created ?? '';
|
const da = a.book.meta_updated ?? '';
|
||||||
const db = b.book.updated ?? b.book.created ?? '';
|
const db = b.book.meta_updated ?? '';
|
||||||
return db.localeCompare(da);
|
return db.localeCompare(da);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user