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:
@@ -5,15 +5,10 @@
|
||||
* TRACES: UR-004, UR-011 | DR-006, DR-015
|
||||
*/
|
||||
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { commands } from '$lib/api/bindings';
|
||||
import type { CacheConfig } from '$lib/api/bindings';
|
||||
import { auth } from '$lib/stores/auth';
|
||||
|
||||
interface PreloadResult {
|
||||
queuedCount: number;
|
||||
alreadyDownloaded: number;
|
||||
skipped: number;
|
||||
}
|
||||
|
||||
interface PreloadOptions {
|
||||
/** Enable debug logging */
|
||||
debug?: boolean;
|
||||
@@ -39,10 +34,8 @@ export async function preloadUpcomingTracks(options: PreloadOptions = {}): Promi
|
||||
|
||||
if (debug) console.log('[Preload] Triggering preload for user:', userId);
|
||||
|
||||
const result = await invoke<PreloadResult>('player_preload_upcoming', {
|
||||
userId,
|
||||
downloadBasePath: '/downloads' // This parameter is currently unused in the backend
|
||||
});
|
||||
// downloadBasePath is currently unused in the backend
|
||||
const result = await commands.playerPreloadUpcoming(userId, '/downloads');
|
||||
|
||||
if (debug) {
|
||||
console.log('[Preload] Result:', {
|
||||
@@ -66,27 +59,13 @@ export async function preloadUpcomingTracks(options: PreloadOptions = {}): Promi
|
||||
/**
|
||||
* Update smart cache configuration
|
||||
*/
|
||||
export async function updateCacheConfig(config: {
|
||||
queuePrecacheEnabled?: boolean;
|
||||
queuePrecacheCount?: number;
|
||||
albumAffinityEnabled?: boolean;
|
||||
albumAffinityThreshold?: number;
|
||||
storageLimit?: number;
|
||||
wifiOnly?: boolean;
|
||||
}): Promise<void> {
|
||||
await invoke('player_set_cache_config', { config });
|
||||
export async function updateCacheConfig(config: CacheConfig): Promise<void> {
|
||||
await commands.playerSetCacheConfig(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current cache configuration
|
||||
*/
|
||||
export async function getCacheConfig(): Promise<{
|
||||
queuePrecacheEnabled: boolean;
|
||||
queuePrecacheCount: number;
|
||||
albumAffinityEnabled: boolean;
|
||||
albumAffinityThreshold: number;
|
||||
storageLimit: number;
|
||||
wifiOnly: boolean;
|
||||
}> {
|
||||
return await invoke('player_get_cache_config');
|
||||
export async function getCacheConfig(): Promise<CacheConfig> {
|
||||
return await commands.playerGetCacheConfig();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user