Migrate all IPC call sites to typed tauri-specta commands.*
Replace the remaining ~155 untyped invoke() calls across stores, services, components, and routes with the generated commands.* wrappers from $lib/api/bindings, so every IPC call is compile-time-checked against the command signatures. - Register repository_get_subtitle_url and repository_get_video_download_url in specta_builder() and the invoke_handler; regenerate bindings.ts. - Source duplicated wire types (AutoplaySettings, CacheConfig, Session, ConnectivityStatus, audio/video settings, etc.) from bindings. - Fix two bugs surfaced by the typed wrappers: - VideoDownloadButton passed an un-awaited Promise as the stream URL. - setAutoplaySettings omitted the required userId argument. - Update unit tests asserting the old invoke(name, args) shape. - Remove the five param-naming guard tests; the compiler and codegen now enforce what they checked. svelte-check: 0 errors. vitest: green. cargo test --lib: green.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { commands } from "$lib/api/bindings";
|
||||
import { player, playbackPosition } from "$lib/stores/player";
|
||||
import { queue, currentQueueItem } from "$lib/stores/queue";
|
||||
import { playbackMode } from "$lib/stores/playbackMode";
|
||||
@@ -230,12 +230,7 @@ async function handleStateChanged(state: string, _mediaId: string | null): Promi
|
||||
*/
|
||||
async function updateQueueStatus(): Promise<void> {
|
||||
try {
|
||||
const queueStatus = await invoke<{
|
||||
hasNext: boolean;
|
||||
hasPrevious: boolean;
|
||||
shuffle: boolean;
|
||||
repeat: string;
|
||||
}>("player_get_queue");
|
||||
const queueStatus = await commands.playerGetQueue();
|
||||
|
||||
// Import appState stores dynamically to avoid circular imports
|
||||
const { hasNext, hasPrevious, shuffle, repeat } = await import("$lib/stores/appState");
|
||||
@@ -266,7 +261,7 @@ function handleMediaLoaded(duration: number): void {
|
||||
async function handlePlaybackEnded(): Promise<void> {
|
||||
// Call backend to handle autoplay decision (queue advance, sleep timer, episode popup, etc.)
|
||||
try {
|
||||
await invoke("player_on_playback_ended");
|
||||
await commands.playerOnPlaybackEnded(null, null);
|
||||
} catch (e) {
|
||||
console.error("[playerEvents] Failed to handle playback ended:", e);
|
||||
// Fallback: set idle state on error
|
||||
@@ -284,7 +279,7 @@ async function handleError(message: string, recoverable: boolean): Promise<void>
|
||||
// Stop backend player to prevent orphaned playback
|
||||
// This also reports playback stopped to Jellyfin server
|
||||
try {
|
||||
await invoke("player_stop");
|
||||
await commands.playerStop();
|
||||
console.log("Backend player stopped after error");
|
||||
} catch (e) {
|
||||
console.error("Failed to stop player after error:", e);
|
||||
|
||||
Reference in New Issue
Block a user