Handle ".5" chapters as full chapter numbers for missing chapter detection

Chapter numbers can change from e.g. "1" to "2.1" and in that case missing chapters were detected.
However, with these weird chapter numbers it's not clear if a chapter is actually missing or not, thus, they should not cause a missing chapter warning
This commit is contained in:
schroda
2025-01-11 13:58:46 +01:00
parent 6c8df33a13
commit 64e06b2966

View File

@@ -230,10 +230,13 @@ export class ReaderControls {
return; return;
} }
const missingChapters = Math.abs(currentChapter.chapterNumber - chapterToOpen.chapterNumber); const missingChapters = Math.max(
0,
Math.trunc(currentChapter.chapterNumber) - Math.trunc(chapterToOpen.chapterNumber) - 1,
);
const isSameScanlator = const isSameScanlator =
!shouldInformAboutScanlatorChange || currentChapter.scanlator === chapterToOpen.scanlator; !shouldInformAboutScanlatorChange || currentChapter.scanlator === chapterToOpen.scanlator;
const isContinuousChapter = !shouldInformAboutMissingChapter || missingChapters <= 1; const isContinuousChapter = !shouldInformAboutMissingChapter || !missingChapters;
const showWarning = !isSameScanlator || !isContinuousChapter; const showWarning = !isSameScanlator || !isContinuousChapter;
if (!showWarning) { if (!showWarning) {
@@ -260,7 +263,7 @@ export class ReaderControls {
const continuousChapter = isContinuousChapter const continuousChapter = isContinuousChapter
? '' ? ''
: t(offsetToTranslationKeys[offset].chapter_number, { : t(offsetToTranslationKeys[offset].chapter_number, {
count: missingChapters - 1, count: missingChapters,
nextChapter: `#${chapterToOpen.chapterNumber} ${chapterToOpen.name}`, nextChapter: `#${chapterToOpen.chapterNumber} ${chapterToOpen.name}`,
currentChapter: `#${currentChapter.chapterNumber} ${currentChapter.name}`, currentChapter: `#${currentChapter.chapterNumber} ${currentChapter.name}`,
}); });