Fix progress not restoring correctly

This commit is contained in:
mrjvs 2023-11-20 19:08:40 +01:00
parent b69c1a4518
commit 2ce42fdb85

View File

@ -31,10 +31,14 @@ export interface BookmarkResponse {
export interface ProgressResponse { export interface ProgressResponse {
tmdbId: string; tmdbId: string;
seasonId?: string; season: {
seasonNumber?: number; id?: string;
episodeNumber?: number; number?: number;
episodeId?: string; };
episode: {
id?: string;
number?: number;
};
meta: { meta: {
title: string; title: string;
year: number; year: number;
@ -82,21 +86,21 @@ export function progressResponsesToEntries(responses: ProgressResponse[]) {
}; };
} }
if (item.type === "show" && v.seasonId && v.episodeId) { if (item.type === "show" && v.season.id && v.episode.id) {
item.seasons[v.seasonId] = { item.seasons[v.season.id] = {
id: v.seasonId, id: v.season.id,
number: v.seasonNumber ?? 0, number: v.season.number ?? 0,
title: "", title: "",
}; };
item.episodes[v.episodeId] = { item.episodes[v.episode.id] = {
id: v.seasonId, id: v.episode.id,
number: v.episodeNumber ?? 0, number: v.episode.number ?? 0,
title: "", title: "",
progress: { progress: {
duration: v.duration, duration: v.duration,
watched: v.watched, watched: v.watched,
}, },
seasonId: v.seasonId, seasonId: v.season.id,
updatedAt: new Date(v.updatedAt).getTime(), updatedAt: new Date(v.updatedAt).getTime(),
}; };
} }