Update typings
This commit is contained in:
@@ -25,7 +25,8 @@ import { NavbarToolbar } from '@/components/navbar/DefaultNavBar';
|
||||
import DownloadStateIndicator from '@/components/molecules/DownloadStateIndicator';
|
||||
import EmptyView from '@/components/util/EmptyView';
|
||||
import NavbarContext from '@/components/context/NavbarContext';
|
||||
import { ChapterType, DownloadType } from '@/lib/graphql/generated/graphql.ts';
|
||||
import { DownloadType } from '@/lib/graphql/generated/graphql.ts';
|
||||
import { TChapter } from '@/typings.ts';
|
||||
|
||||
const DownloadQueue: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
@@ -55,7 +56,7 @@ const DownloadQueue: React.FC = () => {
|
||||
return <EmptyView message={t('download.queue.label.no_downloads')} />;
|
||||
}
|
||||
|
||||
const handleDelete = async (chapter: ChapterType) => {
|
||||
const handleDelete = async (chapter: TChapter) => {
|
||||
const isRunning = status === 'STARTED';
|
||||
|
||||
try {
|
||||
|
||||
@@ -30,12 +30,12 @@ import { makeToaster } from '@/components/util/Toast';
|
||||
import LangSelect from '@/components/navbar/action/LangSelect';
|
||||
import NavbarContext from '@/components/context/NavbarContext';
|
||||
import ExtensionCard from '@/components/ExtensionCard';
|
||||
import { Extension } from '@/typings.ts';
|
||||
import { PartialExtension } from '@/typings.ts';
|
||||
|
||||
const LANGUAGE = 0;
|
||||
const EXTENSIONS = 1;
|
||||
|
||||
function getExtensionsInfo(extensions: Extension[]): {
|
||||
function getExtensionsInfo(extensions: PartialExtension[]): {
|
||||
allLangs: string[];
|
||||
groupedExtensions: GroupedExtensionsResult;
|
||||
} {
|
||||
@@ -132,7 +132,7 @@ export default function MangaExtensions() {
|
||||
[shownLangs, groupedExtensions],
|
||||
);
|
||||
|
||||
const flatRenderItems: (Extension | string)[] = filteredGroupedExtensions.flat(2);
|
||||
const flatRenderItems: (PartialExtension | string)[] = filteredGroupedExtensions.flat(2);
|
||||
|
||||
const [toasts, makeToast] = makeToaster(useState<React.ReactElement[]>([]));
|
||||
|
||||
@@ -229,7 +229,7 @@ export default function MangaExtensions() {
|
||||
</Typography>
|
||||
);
|
||||
}
|
||||
const item = flatRenderItems[index] as Extension;
|
||||
const item = flatRenderItems[index] as PartialExtension;
|
||||
|
||||
return <ExtensionCard key={item.apkName} extension={item} />;
|
||||
}}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import { Chip, Tab, Tabs, styled, Box } from '@mui/material';
|
||||
import React, { useContext, useEffect, useMemo, useRef } from 'react';
|
||||
import React, { useContext, useEffect, useMemo } from 'react';
|
||||
import { useQueryParam, NumberParam } from 'use-query-params';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import requestManager from '@/lib/requests/RequestManager.ts';
|
||||
@@ -20,7 +20,6 @@ import LibraryMangaGrid from '@/components/library/LibraryMangaGrid';
|
||||
import AppbarSearch from '@/components/util/AppbarSearch';
|
||||
import UpdateChecker from '@/components/library/UpdateChecker';
|
||||
import { useLibraryOptionsContext } from '@/components/context/LibraryOptionsContext';
|
||||
import { MangaType } from '@/lib/graphql/generated/graphql.ts';
|
||||
|
||||
const StyledGridWrapper = styled(Box)(({ theme }) => ({
|
||||
// TabsMenu height + TabsMenu bottom padding - grid item top padding
|
||||
@@ -85,7 +84,7 @@ export default function Library() {
|
||||
error: mangaError,
|
||||
loading: mangaLoading,
|
||||
} = requestManager.useGetCategoryMangas(activeTab?.id, { skip: !activeTab, nextFetchPolicy: 'cache-only' });
|
||||
const mangas = (categoryMangaResponse?.category.mangas.nodes as unknown as MangaType[]) ?? [];
|
||||
const mangas = categoryMangaResponse?.category.mangas.nodes ?? [];
|
||||
|
||||
const { setTitle, setAction } = useContext(NavbarContext);
|
||||
useEffect(() => {
|
||||
|
||||
@@ -20,7 +20,6 @@ import MangaDetails from '@/components/manga/MangaDetails';
|
||||
import MangaToolbarMenu from '@/components/manga/MangaToolbarMenu';
|
||||
import EmptyView from '@/components/util/EmptyView';
|
||||
import LoadingPlaceholder from '@/components/util/LoadingPlaceholder';
|
||||
import { MangaType } from '@/lib/graphql/generated/graphql.ts';
|
||||
|
||||
const AUTOFETCH_AGE = 1000 * 60 * 60 * 24; // 24 hours
|
||||
|
||||
@@ -33,7 +32,7 @@ const Manga: React.FC = () => {
|
||||
|
||||
const { data, error, loading: isLoading, networkStatus, refetch } = requestManager.useGetManga(id);
|
||||
const isValidating = isNetworkRequestInFlight(networkStatus);
|
||||
const manga = data?.manga as MangaType | undefined;
|
||||
const manga = data?.manga;
|
||||
|
||||
const [refresh, { loading: refreshing }] = useRefreshManga(id);
|
||||
useSetDefaultBackTo('library');
|
||||
|
||||
@@ -11,7 +11,7 @@ import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'r
|
||||
import { useLocation, useNavigate, useParams } from 'react-router-dom';
|
||||
import { Box } from '@mui/material';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { ChapterOffset, IReaderSettings, ReaderType, TranslationKey } from '@/typings';
|
||||
import { ChapterOffset, IReaderSettings, ReaderType, TChapter, TManga, TranslationKey } from '@/typings';
|
||||
import requestManager from '@/lib/requests/RequestManager.ts';
|
||||
import {
|
||||
checkAndHandleMissingStoredReaderSettings,
|
||||
@@ -27,9 +27,8 @@ import VerticalPager from '@/components/reader/pager/VerticalPager';
|
||||
import ReaderNavBar from '@/components/navbar/ReaderNavBar';
|
||||
import NavbarContext from '@/components/context/NavbarContext';
|
||||
import makeToast from '@/components/util/Toast';
|
||||
import { ChapterType, MangaType } from '@/lib/graphql/generated/graphql.ts';
|
||||
|
||||
const isDupChapter = async (chapterIndex: number, currentChapter: ChapterType) => {
|
||||
const isDupChapter = async (chapterIndex: number, currentChapter: TChapter) => {
|
||||
const nextChapter = await requestManager.getChapter(currentChapter.manga.id, chapterIndex).response;
|
||||
|
||||
return nextChapter.data.chapter.chapterNumber === currentChapter.chapterNumber;
|
||||
@@ -42,7 +41,7 @@ const isDupChapter = async (chapterIndex: number, currentChapter: ChapterType) =
|
||||
*/
|
||||
const getOffsetChapter = async (
|
||||
chapterIndex: number,
|
||||
currentChapter: ChapterType,
|
||||
currentChapter: TChapter,
|
||||
skipDupChapters: boolean,
|
||||
offset: ChapterOffset,
|
||||
): Promise<number> => {
|
||||
@@ -86,7 +85,7 @@ const initialChapter = {
|
||||
chapterCount: 0,
|
||||
lastPageRead: 0,
|
||||
name: 'Loading...',
|
||||
} as unknown as ChapterType;
|
||||
} as unknown as TChapter;
|
||||
|
||||
export default function Reader() {
|
||||
const { t } = useTranslation();
|
||||
@@ -105,17 +104,17 @@ export default function Reader() {
|
||||
inLibraryAt: 0,
|
||||
lastReadAt: 0,
|
||||
chapters: { totalCount: 0 },
|
||||
}) as unknown as MangaType,
|
||||
}) as unknown as TManga,
|
||||
[mangaId],
|
||||
);
|
||||
|
||||
const { data, loading: isMangaLoading } = requestManager.useGetManga(mangaId);
|
||||
const loadedChapter = useRef<ChapterType | null>(null);
|
||||
const loadedChapter = useRef<TChapter | null>(null);
|
||||
const isChapterLoaded =
|
||||
Number(mangaId) === loadedChapter.current?.manga.id &&
|
||||
Number(chapterIndex) === loadedChapter.current?.sourceOrder &&
|
||||
loadedChapter.current?.pageCount !== -1;
|
||||
const manga = (data?.manga as MangaType) ?? initialManga;
|
||||
const manga = data?.manga ?? initialManga;
|
||||
const { data: chapterData, loading: isChapterLoading } = requestManager.useGetMangaChapter(mangaId, chapterIndex, {
|
||||
skip: isChapterLoaded,
|
||||
});
|
||||
@@ -129,7 +128,7 @@ export default function Reader() {
|
||||
}
|
||||
|
||||
if (chapterData?.chapter) {
|
||||
return chapterData.chapter as ChapterType;
|
||||
return chapterData.chapter;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -21,7 +21,6 @@ import LangSelect from '@/components/navbar/action/LangSelect';
|
||||
import MangaGrid from '@/components/MangaGrid';
|
||||
import NavbarContext from '@/components/context/NavbarContext';
|
||||
import { useDebounce } from '@/components/manga/hooks';
|
||||
import { MangaType } from '@/lib/graphql/generated/graphql.ts';
|
||||
|
||||
type SourceLoadingState = { isLoading: boolean; hasResults: boolean; emptySearch: boolean };
|
||||
type SourceToLoadingStateMap = Map<string, SourceLoadingState>;
|
||||
@@ -103,7 +102,7 @@ const SourceSearchPreview = React.memo(
|
||||
skipRequest: !searchString,
|
||||
});
|
||||
const { data: searchResult, isLoading, error, abortRequest } = results[0]!;
|
||||
const mangas = (searchResult?.fetchSourceManga.mangas as MangaType[]) ?? [];
|
||||
const mangas = searchResult?.fetchSourceManga.mangas ?? [];
|
||||
const noMangasFound = !isLoading && !mangas.length;
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -17,7 +17,7 @@ import { Box, Button, styled, useTheme, useMediaQuery } from '@mui/material';
|
||||
import FavoriteIcon from '@mui/icons-material/Favorite';
|
||||
import NewReleasesIcon from '@mui/icons-material/NewReleases';
|
||||
import FilterListIcon from '@mui/icons-material/FilterList';
|
||||
import { TranslationKey } from '@/typings';
|
||||
import { TPartialManga, TranslationKey } from '@/typings';
|
||||
import requestManager, { AbortableApolloUseMutationPaginatedResponse } from '@/lib/requests/RequestManager.ts';
|
||||
import { useDebounce } from '@/components/manga/hooks';
|
||||
import { useLibraryOptionsContext } from '@/components/context/LibraryOptionsContext';
|
||||
@@ -29,7 +29,6 @@ import SourceMangaGrid from '@/components/source/SourceMangaGrid';
|
||||
import {
|
||||
GetSourceMangasFetchMutation,
|
||||
GetSourceMangasFetchMutationVariables,
|
||||
MangaType,
|
||||
} from '@/lib/graphql/generated/graphql.ts';
|
||||
|
||||
const ContentTypeMenu = styled('div')(({ theme }) => ({
|
||||
@@ -87,8 +86,8 @@ const SOURCE_CONTENT_TYPE_TO_ERROR_MSG_KEY: { [contentType in SourceContentType]
|
||||
[SourceContentType.SEARCH]: 'manga.error.label.no_mangas_found',
|
||||
};
|
||||
|
||||
const getUniqueMangas = (mangas: MangaType[]): MangaType[] => {
|
||||
const uniqueMangas: MangaType[] = [];
|
||||
const getUniqueMangas = (mangas: TPartialManga[]): TPartialManga[] => {
|
||||
const uniqueMangas: TPartialManga[] = [];
|
||||
|
||||
mangas.forEach((manga) => {
|
||||
const isDuplicate = uniqueMangas.some((uniqueManga) => uniqueManga.id === manga.id);
|
||||
@@ -166,7 +165,7 @@ const useSourceManga = (
|
||||
.map((page) => page.data?.fetchSourceManga.mangas ?? [])
|
||||
.reduce((prevList, list) => [...prevList, ...list], []),
|
||||
[pages],
|
||||
) as MangaType[];
|
||||
);
|
||||
const uniqueItems = useMemo(() => getUniqueMangas(items), [items]);
|
||||
|
||||
if (!uniqueItems.length) {
|
||||
@@ -224,7 +223,7 @@ export default function SourceMangas() {
|
||||
filtersToApply,
|
||||
isLargeScreen ? 2 : 1,
|
||||
);
|
||||
const mangas = (data?.fetchSourceManga.mangas as MangaType[]) ?? [];
|
||||
const mangas = data?.fetchSourceManga.mangas ?? [];
|
||||
const hasNextPage = data?.fetchSourceManga.hasNextPage ?? false;
|
||||
|
||||
const { data: sourceData } = requestManager.useGetSource(sourceId);
|
||||
|
||||
@@ -23,7 +23,8 @@ import LoadingPlaceholder from '@/components/util/LoadingPlaceholder';
|
||||
import EmptyView from '@/components/util/EmptyView';
|
||||
import DownloadStateIndicator from '@/components/molecules/DownloadStateIndicator';
|
||||
import NavbarContext from '@/components/context/NavbarContext';
|
||||
import { ChapterType, DownloadType } from '@/lib/graphql/generated/graphql.ts';
|
||||
import { DownloadType } from '@/lib/graphql/generated/graphql.ts';
|
||||
import { TChapter } from '@/typings.ts';
|
||||
|
||||
const StyledGroupedVirtuoso = styled(GroupedVirtuoso)(({ theme }) => ({
|
||||
// 64px header
|
||||
@@ -81,7 +82,7 @@ function getDateString(date: Date) {
|
||||
return date.toLocaleDateString();
|
||||
}
|
||||
|
||||
const groupByDate = (updates: ChapterType[]): [date: string, items: number][] => {
|
||||
const groupByDate = (updates: TChapter[]): [date: string, items: number][] => {
|
||||
if (!updates.length) {
|
||||
return [];
|
||||
}
|
||||
@@ -111,7 +112,7 @@ const Updates: React.FC = () => {
|
||||
});
|
||||
const hasNextPage = !!chapterUpdateData?.chapters.pageInfo.hasNextPage;
|
||||
const endCursor = chapterUpdateData?.chapters.pageInfo.endCursor;
|
||||
const updateEntries = (chapterUpdateData?.chapters.nodes as ChapterType[]) ?? [];
|
||||
const updateEntries = chapterUpdateData?.chapters.nodes ?? [];
|
||||
const groupedUpdates = useMemo(() => groupByDate(updateEntries), [updateEntries]);
|
||||
const groupCounts: number[] = useMemo(() => groupedUpdates.map((group) => group[1]), [groupedUpdates]);
|
||||
const { data: downloaderData } = requestManager.useDownloadSubscription();
|
||||
@@ -123,7 +124,7 @@ const Updates: React.FC = () => {
|
||||
setAction(null);
|
||||
}, [t]);
|
||||
|
||||
const downloadForChapter = (chapter: ChapterType) => {
|
||||
const downloadForChapter = (chapter: TChapter) => {
|
||||
const {
|
||||
sourceOrder,
|
||||
manga: { id: mangaId },
|
||||
@@ -131,7 +132,7 @@ const Updates: React.FC = () => {
|
||||
return queue.find((q) => sourceOrder === q.chapter.sourceOrder && mangaId === q.chapter.manga.id);
|
||||
};
|
||||
|
||||
const downloadChapter = (chapter: ChapterType) => {
|
||||
const downloadChapter = (chapter: TChapter) => {
|
||||
requestManager.addChapterToDownloadQueue(chapter.id);
|
||||
};
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import requestManager from '@/lib/requests/RequestManager.ts';
|
||||
import StrictModeDroppable from '@/lib/StrictModeDroppable';
|
||||
import { DEFAULT_FULL_FAB_HEIGHT } from '@/components/util/StyledFab';
|
||||
import NavbarContext, { useSetDefaultBackTo } from '@/components/context/NavbarContext';
|
||||
import { CategoryType } from '@/lib/graphql/generated/graphql.ts';
|
||||
import { TCategory } from '@/typings.ts';
|
||||
|
||||
const getItemStyle = (
|
||||
isDragging: boolean,
|
||||
@@ -58,7 +58,7 @@ export default function Categories() {
|
||||
if (res.length > 0 && res[0].name === 'Default') {
|
||||
res.shift();
|
||||
}
|
||||
return res as CategoryType[];
|
||||
return res;
|
||||
}, [data]);
|
||||
|
||||
const [categoryToEdit, setCategoryToEdit] = useState<number>(-1); // -1 means new category
|
||||
@@ -69,7 +69,7 @@ export default function Categories() {
|
||||
|
||||
useSetDefaultBackTo('settings');
|
||||
|
||||
const categoryReorder = (list: CategoryType[], from: number, to: number) => {
|
||||
const categoryReorder = (list: TCategory[], from: number, to: number) => {
|
||||
const reorderedCategory = list[from];
|
||||
const newData = [...list];
|
||||
const [removed] = newData.splice(from, 1);
|
||||
|
||||
@@ -25,7 +25,8 @@ import makeToast from '@/components/util/Toast';
|
||||
import ThreeStateCheckboxInput from '@/components/atoms/ThreeStateCheckboxInput';
|
||||
import NavbarContext, { useSetDefaultBackTo } from '@/components/context/NavbarContext';
|
||||
import SearchSettings from '@/screens/settings/SearchSettings';
|
||||
import { CategoryType, IncludeInUpdate } from '@/lib/graphql/generated/graphql.ts';
|
||||
import { IncludeInUpdate } from '@/lib/graphql/generated/graphql.ts';
|
||||
import { TCategory } from '@/typings.ts';
|
||||
|
||||
const CategoriesDiv = styled('div')({
|
||||
display: 'flex',
|
||||
@@ -62,7 +63,7 @@ const includeInUpdateStatusToBoolean = (status: IncludeInUpdate): boolean | null
|
||||
};
|
||||
|
||||
const getCategoryUpdateInfo = (
|
||||
categories: CategoryType[],
|
||||
categories: TCategory[],
|
||||
areIncluded: boolean,
|
||||
unsetCategories: number,
|
||||
allCategories: number,
|
||||
@@ -100,19 +101,19 @@ export default function LibrarySettings() {
|
||||
useSetDefaultBackTo('settings');
|
||||
|
||||
const { data, error: requestError } = requestManager.useGetCategories();
|
||||
const categories = (data?.categories.nodes ?? []) as CategoryType[];
|
||||
const [dialogCategories, setDialogCategories] = useState<CategoryType[]>(categories);
|
||||
const categories = data?.categories.nodes ?? [];
|
||||
const [dialogCategories, setDialogCategories] = useState<TCategory[]>(categories);
|
||||
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setDialogCategories(categories);
|
||||
}, [categories]);
|
||||
|
||||
const unsetCategories: CategoryType[] =
|
||||
const unsetCategories: TCategory[] =
|
||||
categories?.filter((category) => category.includeInUpdate === IncludeInUpdate.Unset) ?? [];
|
||||
const excludedCategories: CategoryType[] =
|
||||
const excludedCategories: TCategory[] =
|
||||
categories?.filter((category) => category.includeInUpdate === IncludeInUpdate.Exclude) ?? [];
|
||||
const includedCategories: CategoryType[] =
|
||||
const includedCategories: TCategory[] =
|
||||
categories?.filter((category) => category.includeInUpdate === IncludeInUpdate.Include) ?? [];
|
||||
const excludedCategoriesText = getCategoryUpdateInfo(
|
||||
excludedCategories,
|
||||
@@ -129,7 +130,7 @@ export default function LibrarySettings() {
|
||||
requestError,
|
||||
);
|
||||
|
||||
const updateCategory = (category: CategoryType) =>
|
||||
const updateCategory = (category: TCategory) =>
|
||||
requestManager.updateCategory(category.id, { includeInUpdate: category.includeInUpdate }).response;
|
||||
|
||||
const updateCategories = async () => {
|
||||
@@ -218,7 +219,7 @@ export default function LibrarySettings() {
|
||||
const categoryIndex = dialogCategories.findIndex(
|
||||
(category_) => category_ === category,
|
||||
);
|
||||
const updatedDialogCategories: CategoryType[] = [
|
||||
const updatedDialogCategories: TCategory[] = [
|
||||
...dialogCategories.slice(0, categoryIndex),
|
||||
{
|
||||
...category,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import { t } from 'i18next';
|
||||
import { Extension, TranslationKey } from '@/typings';
|
||||
import { PartialExtension, TranslationKey } from '@/typings';
|
||||
import { DefaultLanguage, langCodeToName } from '@/util/language';
|
||||
|
||||
export enum ExtensionState {
|
||||
@@ -16,16 +16,16 @@ export enum ExtensionState {
|
||||
OBSOLETE = 'OBSOLETE',
|
||||
}
|
||||
|
||||
export type GroupedExtensionsResult<KEY extends string = string> = [KEY, Extension[]][];
|
||||
export type GroupedExtensionsResult<KEY extends string = string> = [KEY, PartialExtension[]][];
|
||||
|
||||
export type GroupedByExtensionState = {
|
||||
[state in ExtensionState]: Extension[];
|
||||
[state in ExtensionState]: PartialExtension[];
|
||||
};
|
||||
|
||||
export type GroupedByLanguage = {
|
||||
[language in DefaultLanguage]: Extension[];
|
||||
[language in DefaultLanguage]: PartialExtension[];
|
||||
} & {
|
||||
[language: string]: Extension[];
|
||||
[language: string]: PartialExtension[];
|
||||
};
|
||||
|
||||
export type GroupedExtensions = GroupedByExtensionState & GroupedByLanguage;
|
||||
|
||||
Reference in New Issue
Block a user