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 @@
|
||||
//
|
||||
// TRACES: UR-005, UR-019, UR-025 | DR-028, DR-047
|
||||
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { commands } from "$lib/api/bindings";
|
||||
import { auth } from "$lib/stores/auth";
|
||||
|
||||
/**
|
||||
@@ -42,13 +42,7 @@ export async function reportPlaybackStart(
|
||||
// Update local DB with context (always works, even offline)
|
||||
if (userId) {
|
||||
try {
|
||||
await invoke("storage_update_playback_context", {
|
||||
userId,
|
||||
itemId,
|
||||
positionTicks,
|
||||
contextType,
|
||||
contextId,
|
||||
});
|
||||
await commands.storageUpdatePlaybackContext(userId, itemId, positionTicks, contextType, contextId);
|
||||
} catch (e) {
|
||||
console.error("[PlaybackReporting] Failed to update playback context:", e);
|
||||
}
|
||||
@@ -79,11 +73,7 @@ export async function reportPlaybackProgress(
|
||||
// Update local DB only (progress updates are frequent, don't report to server)
|
||||
if (userId) {
|
||||
try {
|
||||
await invoke("storage_update_playback_progress", {
|
||||
userId,
|
||||
itemId,
|
||||
positionTicks,
|
||||
});
|
||||
await commands.storageUpdatePlaybackProgress(userId, itemId, positionTicks);
|
||||
} catch (e) {
|
||||
console.error("[PlaybackReporting] Failed to update local progress:", e);
|
||||
}
|
||||
@@ -107,11 +97,7 @@ export async function reportPlaybackStopped(itemId: string, positionSeconds: num
|
||||
// Update local DB first (always works, even offline)
|
||||
if (userId) {
|
||||
try {
|
||||
await invoke("storage_update_playback_progress", {
|
||||
userId,
|
||||
itemId,
|
||||
positionTicks,
|
||||
});
|
||||
await commands.storageUpdatePlaybackProgress(userId, itemId, positionTicks);
|
||||
} catch (e) {
|
||||
console.error("[PlaybackReporting] Failed to update local progress:", e);
|
||||
}
|
||||
@@ -143,7 +129,7 @@ export async function markAsPlayed(itemId: string): Promise<void> {
|
||||
// Update local DB first
|
||||
if (userId) {
|
||||
try {
|
||||
await invoke("storage_mark_played", { userId, itemId });
|
||||
await commands.storageMarkPlayed(userId, itemId);
|
||||
} catch (e) {
|
||||
console.error("[PlaybackReporting] Failed to mark as played in local DB:", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user