Skip to content

Commit c89f553

Browse files
committed
fix: #147 prioritize anilist over local progress
1 parent c3aec5c commit c89f553

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/modules/utils.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,14 @@ export const getProgress = (animeEntry: Media): number | undefined => {
229229
const animeId = (animeEntry.id || animeEntry?.mediaListEntry?.id) as number;
230230
const lastWatched = getLastWatchedEpisode(animeId);
231231

232-
if(lastWatched !== undefined && lastWatched.data !== undefined) {
233-
const progress = (parseInt(lastWatched.data.episode ?? "0")) - ((lastWatched.duration as number * 0.85) > lastWatched.time ? 1 : 0);
234-
return Number.isNaN(progress) ? 0 : progress;
232+
const anilistProgress = animeEntry.mediaListEntry == null ? 0 : animeEntry.mediaListEntry.progress;
233+
234+
if(anilistProgress === 0 && lastWatched !== undefined && lastWatched.data !== undefined) {
235+
const localProgress = (parseInt(lastWatched.data.episode ?? "0")) - ((lastWatched.duration as number * 0.85) > lastWatched.time ? 1 : 0);
236+
return Number.isNaN(localProgress) ? 0 : localProgress;
235237
}
236238

237-
return animeEntry.mediaListEntry == null ? 0 : animeEntry.mediaListEntry.progress;
239+
return anilistProgress;
238240
}
239241

240242
/**

0 commit comments

Comments
 (0)