Update downloadable check in chapter list
Check for single chapter card was never updated and the downloadable condition was incorrectly changed with 6c01c222c3
This commit is contained in:
@@ -38,6 +38,7 @@ import {
|
|||||||
ChapterReadInfo,
|
ChapterReadInfo,
|
||||||
ChapterScanlatorInfo,
|
ChapterScanlatorInfo,
|
||||||
} from '@/lib/data/Chapters.ts';
|
} from '@/lib/data/Chapters.ts';
|
||||||
|
import { ChaptersWithMeta } from '@/lib/data/ChaptersWithMeta.ts';
|
||||||
|
|
||||||
type TChapter = ChapterIdInfo &
|
type TChapter = ChapterIdInfo &
|
||||||
ChapterMangaInfo &
|
ChapterMangaInfo &
|
||||||
@@ -182,7 +183,10 @@ export const ChapterCard: React.FC<IProps> = (props: IProps) => {
|
|||||||
chapter={chapter}
|
chapter={chapter}
|
||||||
allChapters={allChapters}
|
allChapters={allChapters}
|
||||||
handleSelection={() => onSelect(true)}
|
handleSelection={() => onSelect(true)}
|
||||||
canBeDownloaded={!chapter.isDownloaded && !dc}
|
canBeDownloaded={ChaptersWithMeta.isDownloadable({
|
||||||
|
chapter,
|
||||||
|
downloadChapter: dc,
|
||||||
|
})}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Menu>
|
</Menu>
|
||||||
|
|||||||
@@ -50,11 +50,12 @@ export class ChaptersWithMeta {
|
|||||||
return chapters.filter(({ chapter }) => !Chapters.isDownloaded(chapter));
|
return chapters.filter(({ chapter }) => !Chapters.isDownloaded(chapter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static isDownloadable<Chapter extends ChapterWithMetaType>({ chapter, downloadChapter }: Chapter): boolean {
|
||||||
|
return !Chapters.isDownloaded(chapter) && (!downloadChapter || downloadChapter?.state === DownloadState.Error);
|
||||||
|
}
|
||||||
|
|
||||||
static getDownloadable<Chapter extends ChapterWithMetaType>(chapters: Chapter[]): Chapter[] {
|
static getDownloadable<Chapter extends ChapterWithMetaType>(chapters: Chapter[]): Chapter[] {
|
||||||
return chapters.filter(
|
return chapters.filter(this.isDownloadable);
|
||||||
({ chapter, downloadChapter }) =>
|
|
||||||
!Chapters.isDownloaded(chapter) && (!downloadChapter || downloadChapter?.state === DownloadState.Error),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static getBookmarked<Chapter extends ChapterWithMetaType>(chapters: Chapter[]): Chapter[] {
|
static getBookmarked<Chapter extends ChapterWithMetaType>(chapters: Chapter[]): Chapter[] {
|
||||||
|
|||||||
Reference in New Issue
Block a user