many changes
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
// Image cache service - Handles lazy caching of thumbnails with LRU eviction
|
||||
// TRACES: UR-007 | DR-016
|
||||
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { convertFileSrc } from "@tauri-apps/api/core";
|
||||
@@ -75,52 +76,6 @@ export async function getCachedImageUrl(
|
||||
return serverImageUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronous version that returns server URL immediately
|
||||
* and triggers background caching. Useful for initial render.
|
||||
*
|
||||
* @param serverUrl - The Jellyfin server base URL
|
||||
* @param itemId - The Jellyfin item ID
|
||||
* @param imageType - The image type (Primary, Backdrop, etc.)
|
||||
* @param options - Image options
|
||||
* @returns The server image URL
|
||||
*/
|
||||
export function getImageUrlSync(
|
||||
serverUrl: string,
|
||||
itemId: string,
|
||||
imageType: string = "Primary",
|
||||
options: {
|
||||
maxWidth?: number;
|
||||
maxHeight?: number;
|
||||
quality?: number;
|
||||
tag?: string;
|
||||
} = {}
|
||||
): string {
|
||||
const tag = options.tag || "default";
|
||||
|
||||
// Build server URL
|
||||
const params = new URLSearchParams();
|
||||
if (options.maxWidth) params.set("maxWidth", options.maxWidth.toString());
|
||||
if (options.maxHeight) params.set("maxHeight", options.maxHeight.toString());
|
||||
if (options.quality) params.set("quality", options.quality.toString());
|
||||
if (options.tag) params.set("tag", options.tag);
|
||||
|
||||
const serverImageUrl = `${serverUrl}/Items/${itemId}/Images/${imageType}?${params.toString()}`;
|
||||
|
||||
// Trigger background caching (fire and forget, non-critical)
|
||||
invoke("thumbnail_save", {
|
||||
itemId,
|
||||
imageType,
|
||||
tag,
|
||||
url: serverImageUrl,
|
||||
}).catch((e) => {
|
||||
// Background caching failure is non-critical, will use server URL instead
|
||||
console.debug(`[imageCache] Failed to save thumbnail for ${itemId}:`, e);
|
||||
});
|
||||
|
||||
return serverImageUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get thumbnail cache statistics
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user