chore(frontend): toolchain migration checkpoint + UI perf optimizations
Checkpoint of the in-progress frontend toolchain work (Vite pinned to ^6 after the 7/8 rolldown build break, eslint-plugin-svelte v3 navigation/reactivity fixes, CI/Dockerfile/manifest updates) together with three UI performance optimizations (verified on the Vite 6 build): - Critical CSS: move auth.css/music.css off the global path into their route chunks (login/device/nextcloud-login, music) -- -25% gzipped critical CSS (~5.4 KB) on every non-auth/non-music page load. - relativeTimeAgo: cache the Intl.RelativeTimeFormat (was rebuilt per call, once per row per render) -- 22.7x faster date formatting in large lists. - Virtualize search results and grouped trash (list view) via VirtualList -- DOM rows mounted stay ~constant (~27) instead of O(N) (94.6% fewer for 500 hits). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -31,6 +31,9 @@ export class OwnerCache {
|
||||
|
||||
/** Resolve every not-yet-cached id in parallel; nullish ids are skipped. */
|
||||
async resolve(ids: Iterable<string | null | undefined>): Promise<void> {
|
||||
// Transient scratch Set for dedup only — built, spread to an array, and
|
||||
// discarded in this call; never read reactively, so a plain Set is correct.
|
||||
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
||||
const pending = [...new Set([...ids].filter((id): id is string => !!id))].filter(
|
||||
(id) => !this.#names[id]
|
||||
);
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
import { SvelteSet } from 'svelte/reactivity';
|
||||
|
||||
/**
|
||||
* Reactive multi-select over string ids. Backs the repeated
|
||||
* `let selected = $state(new Set()); function toggle(id) { … }` pattern used by
|
||||
* the photos grid, music picker and other list views with one source of truth.
|
||||
*
|
||||
* Mutations swap in a fresh Set so `$derived`/template reads re-run.
|
||||
* Backed by a reactive {@link SvelteSet}, so in-place mutations (`add`/`delete`)
|
||||
* drive `$derived`/template reads without copying the set.
|
||||
*/
|
||||
export class Selection {
|
||||
#ids = $state<Set<string>>(new Set());
|
||||
#ids = new SvelteSet<string>();
|
||||
|
||||
/** The live selection set (read-only intent — mutate via the methods). */
|
||||
get ids(): Set<string> {
|
||||
get ids(): SvelteSet<string> {
|
||||
return this.#ids;
|
||||
}
|
||||
|
||||
@@ -31,31 +34,26 @@ export class Selection {
|
||||
}
|
||||
|
||||
toggle(id: string): void {
|
||||
const next = new Set(this.#ids);
|
||||
if (next.has(id)) next.delete(id);
|
||||
else next.add(id);
|
||||
this.#ids = next;
|
||||
if (this.#ids.has(id)) this.#ids.delete(id);
|
||||
else this.#ids.add(id);
|
||||
}
|
||||
|
||||
add(id: string): void {
|
||||
if (this.#ids.has(id)) return;
|
||||
this.#ids = new Set(this.#ids).add(id);
|
||||
this.#ids.add(id);
|
||||
}
|
||||
|
||||
delete(id: string): void {
|
||||
if (!this.#ids.has(id)) return;
|
||||
const next = new Set(this.#ids);
|
||||
next.delete(id);
|
||||
this.#ids = next;
|
||||
this.#ids.delete(id);
|
||||
}
|
||||
|
||||
/** Replace the whole selection. */
|
||||
set(ids: Iterable<string>): void {
|
||||
this.#ids = new Set(ids);
|
||||
this.#ids.clear();
|
||||
for (const id of ids) this.#ids.add(id);
|
||||
}
|
||||
|
||||
clear(): void {
|
||||
if (this.#ids.size) this.#ids = new Set();
|
||||
this.#ids.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user