feat: add gamepad navigation and music library improvements
Continuous Integration / build_web (push) Failing after 0s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped

- add TV/gamepad spatial navigation, focus ring and back/select controls
- cache artwork persistently and add music cover placeholders
- add compact songs list, shuffle-all queue and library error recovery
- polish remote control layout and optimistic seek timeline
This commit is contained in:
1xDed committed 2026-12-01 04:24:56 +03:00
1 parent 04ab9f767b
commit 5f5803c9f8
24 files changed
+1199 -245

No files matched your search

+82
View File
@@ -0,0 +1,82 @@
const CACHE_NAME = "blink-images-v1";
const MAX_MEMORY_ENTRIES = 400;
const MAX_CACHE_ENTRIES = 800;
const memory = new Map<string, string>();
const pending = new Map<string, Promise<string | null>>();
let cachePuts = 0;
const remember = (src: string, objectUrl: string) => {
if (memory.size >= MAX_MEMORY_ENTRIES) {
const oldest = memory.keys().next().value;
if (oldest) {
const oldUrl = memory.get(oldest);
memory.delete(oldest);
if (oldUrl) URL.revokeObjectURL(oldUrl);
}
}
memory.set(src, objectUrl);
};
const trimCache = async (cache: Cache) => {
cachePuts += 1;
if (cachePuts % 50 !== 0) return;
const keys = await cache.keys();
if (keys.length <= MAX_CACHE_ENTRIES) return;
for (const key of keys.slice(0, keys.length - MAX_CACHE_ENTRIES)) {
await cache.delete(key);
}
};
const cacheable = (src: string) =>
src.startsWith("http://") || src.startsWith("https://");
/**
* Resolve an image through the WebView Cache API. The browser's HTTP cache
* only has `Cache-Control: public` for Jellyfin images (no max-age), so pages
* often refetch every poster. A named cache keeps decoded responses around.
*/
const loadImage = async (src: string): Promise<string | null> => {
if (!cacheable(src)) return null;
try {
if ("caches" in window) {
const cache = await caches.open(CACHE_NAME);
let response = await cache.match(src);
if (!response) {
response = await fetch(src, {
mode: "cors",
credentials: "omit",
});
if (!response.ok) return null;
await cache.put(src, response.clone());
void trimCache(cache);
}
const blob = await response.blob();
const objectUrl = URL.createObjectURL(blob);
remember(src, objectUrl);
return objectUrl;
}
const response = await fetch(src, {
mode: "cors",
credentials: "omit",
});
if (!response.ok) return null;
const blob = await response.blob();
const objectUrl = URL.createObjectURL(blob);
remember(src, objectUrl);
return objectUrl;
} catch {
return null;
}
};
export const getCachedImageUrl = (src: string): Promise<string | null> => {
const hit = memory.get(src);
if (hit) return Promise.resolve(hit);
const inFlight = pending.get(src);
if (inFlight) return inFlight;
const request = loadImage(src).finally(() => pending.delete(src));
pending.set(src, request);
return request;
};
+1 -1
View File
@@ -92,7 +92,7 @@ export const SORT_BY_OPTIONS: Array<{
],
},
{
title: "Название трека",
title: "Название",
value: ItemSortBy.Name,
compatibleViewTypes: [
BaseItemKind.Audio,
+17 -5
View File
@@ -17,11 +17,23 @@ export const getLibraryQueryOptions = (
queryKey: ["library", "currentLib", id],
queryFn: async () => {
if (!api || !userId) throw Error("API or User ID is not defined");
const result = await getLibraryApi(api).getItem({
userId: userId,
itemId: id,
});
return result.data;
try {
const result = await getLibraryApi(api).getItem({
userId: userId,
itemId: id,
});
return result.data;
} catch (error) {
// Jellyfin 12 no longer returns virtual library folders from
// /Items/{id}; resolve them from the media folder list instead.
if ((error as { response?: { status?: number } })?.response?.status !== 404) {
throw error;
}
const folders = await getLibraryApi(api).getMediaFolders();
const folder = folders.data.Items?.find((item) => item.Id === id);
if (folder) return folder;
throw error;
}
},
enabled: !!api && !!userId,
});
+2
View File
@@ -174,5 +174,7 @@ export const getLibraryItemsQueryOptions = (
},
staleTime: 5_000,
gcTime: 5 * 60_000,
retry: 1,
retryDelay: 500,
});
};