Skip to content

Commit

Permalink
fix: #147 prioritize anilist over local progress
Browse files Browse the repository at this point in the history
  • Loading branch information
ch0nker committed Sep 7, 2024
1 parent c3aec5c commit c89f553
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/modules/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,14 @@ export const getProgress = (animeEntry: Media): number | undefined => {
const animeId = (animeEntry.id || animeEntry?.mediaListEntry?.id) as number;
const lastWatched = getLastWatchedEpisode(animeId);

if(lastWatched !== undefined && lastWatched.data !== undefined) {
const progress = (parseInt(lastWatched.data.episode ?? "0")) - ((lastWatched.duration as number * 0.85) > lastWatched.time ? 1 : 0);
return Number.isNaN(progress) ? 0 : progress;
const anilistProgress = animeEntry.mediaListEntry == null ? 0 : animeEntry.mediaListEntry.progress;

if(anilistProgress === 0 && lastWatched !== undefined && lastWatched.data !== undefined) {
const localProgress = (parseInt(lastWatched.data.episode ?? "0")) - ((lastWatched.duration as number * 0.85) > lastWatched.time ? 1 : 0);
return Number.isNaN(localProgress) ? 0 : localProgress;
}

return animeEntry.mediaListEntry == null ? 0 : animeEntry.mediaListEntry.progress;
return anilistProgress;
}

/**
Expand Down

0 comments on commit c89f553

Please sign in to comment.