Fix for offline mode
🏗️ Build and Test JellyTau / Run Tests (pull_request) Successful in 4m21s
Traceability Validation / Check Requirement Traces (pull_request) Successful in 20s
🏗️ Build and Test JellyTau / Android Compile Check (pull_request) Successful in 4m54s

This commit is contained in:
2026-07-03 19:37:34 +02:00
parent c58cc0cf46
commit 2d141e5bf4
13 changed files with 790 additions and 143 deletions
+13 -1
View File
@@ -36,7 +36,10 @@ function createHomeStore() {
try {
const repo = auth.getRepository();
const [resume, nextUp, latest, recentAudio, resumeMovies] = await Promise.all([
// Use allSettled so one failing section (e.g. Next Up is online-only and
// rejects offline) doesn't wipe out the whole homepage. Each section falls
// back to an empty list; cached sections (resume/latest/recent) still show.
const settled = await Promise.allSettled([
repo.getResumeItems(undefined, 12),
repo.getNextUpEpisodes(undefined, 12),
repo.getLatestItems("", 16),
@@ -44,6 +47,15 @@ function createHomeStore() {
repo.getResumeMovies(12),
]);
const valueOr = <T>(i: number, fallback: T): T =>
settled[i].status === "fulfilled" ? (settled[i] as PromiseFulfilledResult<T>).value : fallback;
const resume = valueOr(0, [] as typeof initialState.resumeItems);
const nextUp = valueOr(1, [] as typeof initialState.nextUpItems);
const latest = valueOr(2, [] as typeof initialState.latestItems);
const recentAudio = valueOr(3, [] as typeof initialState.recentlyPlayedAudio);
const resumeMovies = valueOr(4, [] as typeof initialState.resumeMovies);
// Use resume items or latest as hero items
const hero = resume.length >= 3 ? resume.slice(0, 5) : latest.slice(0, 5);