Fix download queue related TypeErrors

With the changes from df006bb348, the requested download queue data changed not matching the previously used type.
The unnecessary cast then hid the tsc issues during compilation
This commit is contained in:
schroda
2024-07-11 17:41:38 +02:00
parent f33b0d70ba
commit bc01a945db
7 changed files with 49 additions and 42 deletions

View File

@@ -13,7 +13,11 @@ import { ChapterOffset, TranslationKey } from '@/typings.ts';
import { makeToast } from '@/components/util/Toast.tsx';
import { requestManager } from '@/lib/requests/RequestManager.ts';
import { getMetadataServerSettings } from '@/lib/metadata/metadataServerSettings.ts';
import { ChapterListFieldsFragment, ChapterType } from '@/lib/graphql/generated/graphql.ts';
import {
ChapterListFieldsFragment,
ChapterType,
DownloadStatusFieldsFragment,
} from '@/lib/graphql/generated/graphql.ts';
import { CHAPTER_LIST_FIELDS } from '@/lib/graphql/fragments/ChapterFragments.ts';
import { MangaIdInfo } from '@/lib/data/Mangas.ts';
@@ -79,6 +83,8 @@ export const actionToTranslationKey: {
},
};
export type ChapterDownloadStatus = DownloadStatusFieldsFragment['queue'][number];
export type ChapterIdInfo = Pick<ChapterType, 'id'>;
export type ChapterMangaInfo = Pick<ChapterType, 'mangaId'>;
export type ChapterDownloadInfo = ChapterIdInfo & Pick<ChapterType, 'isDownloaded'>;

View File

@@ -6,12 +6,21 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { DownloadType } from '@/lib/graphql/generated/graphql.ts';
import { ChapterBookmarkInfo, ChapterDownloadInfo, ChapterReadInfo, Chapters } from '@/lib/data/Chapters.ts';
import {
ChapterBookmarkInfo,
ChapterDownloadInfo,
ChapterDownloadStatus,
ChapterReadInfo,
Chapters,
} from '@/lib/data/Chapters.ts';
export type ChapterWithMetaType = {
chapter: ChapterDownloadInfo & ChapterReadInfo & ChapterBookmarkInfo;
downloadChapter: DownloadType | undefined;
export type ChapterWithMetaType<
Chapter extends ChapterDownloadInfo & ChapterReadInfo & ChapterBookmarkInfo = ChapterDownloadInfo &
ChapterReadInfo &
ChapterBookmarkInfo,
> = {
chapter: Chapter;
downloadChapter: ChapterDownloadStatus | undefined;
};
export class ChaptersWithMeta {