Skip to content

Commit

Permalink
Use sourceId instead of title
Browse files Browse the repository at this point in the history
  • Loading branch information
crxssed7 committed Feb 17, 2024
1 parent 71a6cf0 commit e762e5d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/util/comparison.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function selectMostSimilarChapter(original: Chapter, options: Chapter[]):
function consolidateAndSortChapters(chapterList: Chapter[]): Chapter[] {
const grouped: { [index: string]: Chapter[] } = {};
chapterList.forEach((chapter: Chapter) => {
const key = chapter.chapterNumber === '' ? chapter.title : chapter.chapterNumber;
const key = chapter.chapterNumber === '' ? chapter.sourceId : chapter.chapterNumber;

if (grouped[key] === undefined) {
grouped[key] = [];
Expand Down Expand Up @@ -86,15 +86,15 @@ export function getNumberUnreadChapters(chapterList: Chapter[]): number {
let highestRead = 0;
let highestReleased = 0;
let previousChapNumber = 0;
let cumulativeGaps = 1
let cumulativeGaps = 1;

const chapters = consolidateAndSortChapters(chapterList);

chapters.forEach((chapter: Chapter, index: number) => {
let absoluteNumber = cumulativeGaps + index;
const chapterNumber = parseFloat(chapter.chapterNumber)
const chapterNumber = parseFloat(chapter.chapterNumber);

const gap = Math.ceil(chapterNumber - previousChapNumber) - 1
const gap = Math.ceil(chapterNumber - previousChapNumber) - 1;
if (gap > 1) {
// A gap between chapters was found. Account for this in the absolute numbers
absoluteNumber += gap;
Expand Down

0 comments on commit e762e5d

Please sign in to comment.