mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-20 14:37:43 +01:00
Fixed Sorting
This commit is contained in:
parent
81515528cb
commit
893e9e0ae6
1 changed files with 28 additions and 16 deletions
|
@ -87,6 +87,11 @@ export function progressResponsesToEntries(responses: ProgressResponse[]) {
|
|||
}
|
||||
|
||||
const item = items[v.tmdbId];
|
||||
// Update the item only if the new update is more recent than the current one
|
||||
if (new Date(v.updatedAt).getTime() > item.updatedAt) {
|
||||
item.updatedAt = new Date(v.updatedAt).getTime();
|
||||
}
|
||||
|
||||
if (item.type === "movie") {
|
||||
item.progress = {
|
||||
duration: Number(v.duration),
|
||||
|
@ -95,6 +100,12 @@ export function progressResponsesToEntries(responses: ProgressResponse[]) {
|
|||
}
|
||||
|
||||
if (item.type === "show" && v.season.id && v.episode.id) {
|
||||
if (
|
||||
!item.seasons[v.season.id] ||
|
||||
(item.episodes[v.episode.id] &&
|
||||
new Date(v.updatedAt).getTime() >
|
||||
item.episodes[v.episode.id].updatedAt)
|
||||
) {
|
||||
item.seasons[v.season.id] = {
|
||||
id: v.season.id,
|
||||
number: v.season.number ?? 0,
|
||||
|
@ -112,6 +123,7 @@ export function progressResponsesToEntries(responses: ProgressResponse[]) {
|
|||
updatedAt: new Date(v.updatedAt).getTime(),
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return items;
|
||||
|
|
Loading…
Reference in a new issue