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
-11
@@ -4,28 +4,26 @@
|
||||
* Functions to control autoplay in the backend.
|
||||
*/
|
||||
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { commands } from "$lib/api/bindings";
|
||||
import type { PlayItemRequest, AutoplaySettings } from "$lib/api/bindings";
|
||||
import { auth } from "$lib/stores/auth";
|
||||
|
||||
export interface AutoplaySettings {
|
||||
enabled: boolean;
|
||||
countdownSeconds: number;
|
||||
maxEpisodes: number;
|
||||
}
|
||||
export type { AutoplaySettings };
|
||||
|
||||
export async function getAutoplaySettings(): Promise<AutoplaySettings> {
|
||||
return invoke("player_get_autoplay_settings");
|
||||
return commands.playerGetAutoplaySettings();
|
||||
}
|
||||
|
||||
export async function setAutoplaySettings(
|
||||
settings: AutoplaySettings
|
||||
): Promise<AutoplaySettings> {
|
||||
return invoke("player_set_autoplay_settings", { settings });
|
||||
return commands.playerSetAutoplaySettings(auth.getUserId() ?? "", settings);
|
||||
}
|
||||
|
||||
export async function cancelAutoplayCountdown(): Promise<void> {
|
||||
return invoke("player_cancel_autoplay_countdown");
|
||||
await commands.playerCancelAutoplayCountdown();
|
||||
}
|
||||
|
||||
export async function playNextEpisode(item: any): Promise<void> {
|
||||
return invoke("player_play_next_episode", { item });
|
||||
export async function playNextEpisode(item: PlayItemRequest): Promise<void> {
|
||||
await commands.playerPlayNextEpisode(item);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user