Move tracker types and constants to corresponding files
This commit is contained in:
@@ -43,3 +43,5 @@ export const PUBLISHING_STATUS_TO_TRANSLATION: Record<PublishingStatus, Translat
|
|||||||
[PublishingStatus.CURRENTLY_PUBLISHING]: 'tracking.publishing.status.currently_publishing',
|
[PublishingStatus.CURRENTLY_PUBLISHING]: 'tracking.publishing.status.currently_publishing',
|
||||||
[PublishingStatus.NOT_YET_PUBLISHED]: 'tracking.publishing.status.not_yet_published',
|
[PublishingStatus.NOT_YET_PUBLISHED]: 'tracking.publishing.status.not_yet_published',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const UNSET_DATE = '0';
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { TrackerType, TrackRecordType, TrackSearchType } from '@/lib/graphql/generated/graphql.ts';
|
||||||
|
|
||||||
export type MetadataTrackingSettings = {
|
export type MetadataTrackingSettings = {
|
||||||
updateProgressAfterReading: boolean;
|
updateProgressAfterReading: boolean;
|
||||||
updateProgressManualMarkRead: boolean;
|
updateProgressManualMarkRead: boolean;
|
||||||
@@ -31,3 +33,42 @@ export enum PublishingStatus {
|
|||||||
CURRENTLY_PUBLISHING = 'currently_publishing',
|
CURRENTLY_PUBLISHING = 'currently_publishing',
|
||||||
NOT_YET_PUBLISHED = 'not_yet_published',
|
NOT_YET_PUBLISHED = 'not_yet_published',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum Tracker {
|
||||||
|
MYANIMELIST = 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
export type TTrackRecordBase = Pick<TrackRecordType, 'id' | 'remoteId' | 'title'>;
|
||||||
|
export type TTrackRecordBind = TTrackRecordBase &
|
||||||
|
Pick<
|
||||||
|
TrackRecordType,
|
||||||
|
| 'trackerId'
|
||||||
|
| 'remoteUrl'
|
||||||
|
| 'status'
|
||||||
|
| 'lastChapterRead'
|
||||||
|
| 'totalChapters'
|
||||||
|
| 'score'
|
||||||
|
| 'displayScore'
|
||||||
|
| 'startDate'
|
||||||
|
| 'finishDate'
|
||||||
|
>;
|
||||||
|
export type TTrackerManga = Pick<
|
||||||
|
TrackSearchType,
|
||||||
|
| 'id'
|
||||||
|
| 'remoteId'
|
||||||
|
| 'trackingUrl'
|
||||||
|
| 'title'
|
||||||
|
| 'coverUrl'
|
||||||
|
| 'publishingType'
|
||||||
|
| 'startDate'
|
||||||
|
| 'publishingStatus'
|
||||||
|
| 'summary'
|
||||||
|
>;
|
||||||
|
export type TTrackerBase = Pick<TrackerType, 'id' | 'name' | 'icon' | 'isLoggedIn' | 'isTokenExpired'>;
|
||||||
|
export type TTrackerSearch = TTrackerBase & Pick<TrackerType, 'authUrl'>;
|
||||||
|
export type TTrackerBind = TTrackerBase & Pick<TrackerType, 'icon' | 'supportsTrackDeletion' | 'scores' | 'statuses'>;
|
||||||
|
export type TrackerIdInfo = Pick<TrackerType, 'id'>;
|
||||||
|
export type LoggedInInfo = Pick<TrackerType, 'isLoggedIn' | 'isTokenExpired'>;
|
||||||
|
export type TrackRecordTrackerInfo = Pick<TrackRecordType, 'trackerId'>;
|
||||||
|
export type TrackSearchPublishingTypeInfo = Pick<TrackSearchType, 'publishingType'>;
|
||||||
|
export type TrackSearchPublishingStatusInfo = Pick<TrackSearchType, 'publishingStatus'>;
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import Typography from '@mui/material/Typography';
|
|||||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||||
import { EmptyViewAbsoluteCentered } from '@/modules/core/components/feedback/EmptyViewAbsoluteCentered.tsx';
|
import { EmptyViewAbsoluteCentered } from '@/modules/core/components/feedback/EmptyViewAbsoluteCentered.tsx';
|
||||||
import { LoadingPlaceholder } from '@/modules/core/components/feedback/LoadingPlaceholder.tsx';
|
import { LoadingPlaceholder } from '@/modules/core/components/feedback/LoadingPlaceholder.tsx';
|
||||||
import { Tracker, TTrackerBase } from '@/modules/tracker/services/Trackers.ts';
|
|
||||||
import { SearchTextField } from '@/modules/core/components/inputs/SearchTextField.tsx';
|
import { SearchTextField } from '@/modules/core/components/inputs/SearchTextField.tsx';
|
||||||
import { makeToast } from '@/modules/core/utils/Toast.ts';
|
import { makeToast } from '@/modules/core/utils/Toast.ts';
|
||||||
import { TrackerMangaCard } from '@/modules/tracker/components/cards/TrackerMangaCard.tsx';
|
import { TrackerMangaCard } from '@/modules/tracker/components/cards/TrackerMangaCard.tsx';
|
||||||
@@ -36,6 +35,7 @@ import { MangaType } from '@/lib/graphql/generated/graphql.ts';
|
|||||||
import { MangaIdInfo } from '@/modules/manga/Manga.types.ts';
|
import { MangaIdInfo } from '@/modules/manga/Manga.types.ts';
|
||||||
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
|
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
|
||||||
import { applyStyles } from '@/modules/core/utils/ApplyStyles.ts';
|
import { applyStyles } from '@/modules/core/utils/ApplyStyles.ts';
|
||||||
|
import { Tracker, TTrackerBase } from '@/modules/tracker/Tracker.types.ts';
|
||||||
|
|
||||||
export const TrackerSearch = ({
|
export const TrackerSearch = ({
|
||||||
manga,
|
manga,
|
||||||
|
|||||||
@@ -24,9 +24,10 @@ import Button from '@mui/material/Button';
|
|||||||
import { PasswordTextField } from '@/modules/core/components/inputs/PasswordTextField.tsx';
|
import { PasswordTextField } from '@/modules/core/components/inputs/PasswordTextField.tsx';
|
||||||
import { makeToast } from '@/modules/core/utils/Toast.ts';
|
import { makeToast } from '@/modules/core/utils/Toast.ts';
|
||||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||||
import { Trackers, TTrackerSearch } from '@/modules/tracker/services/Trackers.ts';
|
import { Trackers } from '@/modules/tracker/services/Trackers.ts';
|
||||||
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
|
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
|
||||||
import { useLocalStorage } from '@/modules/core/hooks/useStorage.tsx';
|
import { useLocalStorage } from '@/modules/core/hooks/useStorage.tsx';
|
||||||
|
import { TTrackerSearch } from '@/modules/tracker/Tracker.types.ts';
|
||||||
|
|
||||||
export const SettingsTrackerCard = ({ tracker }: { tracker: TTrackerSearch }) => {
|
export const SettingsTrackerCard = ({ tracker }: { tracker: TTrackerSearch }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|||||||
@@ -29,18 +29,19 @@ import PopupState, { bindDialog, bindMenu, bindTrigger } from 'material-ui-popup
|
|||||||
import { useMemo, useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
import { CustomTooltip } from '@/modules/core/components/CustomTooltip.tsx';
|
import { CustomTooltip } from '@/modules/core/components/CustomTooltip.tsx';
|
||||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||||
import { Trackers, TTrackerBind, TTrackRecordBind, UNSET_DATE } from '@/modules/tracker/services/Trackers.ts';
|
import { Trackers } from '@/modules/tracker/services/Trackers.ts';
|
||||||
import { ListPreference } from '@/modules/source/components/sourceConfiguration/ListPreference.tsx';
|
import { ListPreference } from '@/modules/source/components/sourceConfiguration/ListPreference.tsx';
|
||||||
import { NumberSetting } from '@/modules/core/components/settings/NumberSetting.tsx';
|
import { NumberSetting } from '@/modules/core/components/settings/NumberSetting.tsx';
|
||||||
import { DateSetting } from '@/modules/core/components/settings/DateSetting.tsx';
|
import { DateSetting } from '@/modules/core/components/settings/DateSetting.tsx';
|
||||||
import { makeToast } from '@/modules/core/utils/Toast.ts';
|
import { makeToast } from '@/modules/core/utils/Toast.ts';
|
||||||
import { Menu } from '@/modules/core/components/menu/Menu.tsx';
|
import { Menu } from '@/modules/core/components/menu/Menu.tsx';
|
||||||
import { CARD_STYLING } from '@/modules/tracker/Tracker.constants.ts';
|
import { CARD_STYLING, UNSET_DATE } from '@/modules/tracker/Tracker.constants.ts';
|
||||||
import { TypographyMaxLines } from '@/modules/core/components/texts/TypographyMaxLines.tsx';
|
import { TypographyMaxLines } from '@/modules/core/components/texts/TypographyMaxLines.tsx';
|
||||||
import { SelectSetting, SelectSettingValue } from '@/modules/core/components/settings/SelectSetting.tsx';
|
import { SelectSetting, SelectSettingValue } from '@/modules/core/components/settings/SelectSetting.tsx';
|
||||||
import { CheckboxInput } from '@/modules/core/components/inputs/CheckboxInput.tsx';
|
import { CheckboxInput } from '@/modules/core/components/inputs/CheckboxInput.tsx';
|
||||||
import { TrackRecordType } from '@/lib/graphql/generated/graphql.ts';
|
import { TrackRecordType } from '@/lib/graphql/generated/graphql.ts';
|
||||||
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
|
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
|
||||||
|
import { TTrackerBind, TTrackRecordBind } from '@/modules/tracker/Tracker.types.ts';
|
||||||
|
|
||||||
const TrackerActiveLink = ({ children, url }: { children: React.ReactNode; url: string }) => (
|
const TrackerActiveLink = ({ children, url }: { children: React.ReactNode; url: string }) => (
|
||||||
<Link href={url} rel="noreferrer" target="_blank" underline="none" color="inherit">
|
<Link href={url} rel="noreferrer" target="_blank" underline="none" color="inherit">
|
||||||
|
|||||||
@@ -9,10 +9,10 @@
|
|||||||
import { TrackerUntrackedCard } from '@/modules/tracker/components/cards/TrackerUntrackedCard.tsx';
|
import { TrackerUntrackedCard } from '@/modules/tracker/components/cards/TrackerUntrackedCard.tsx';
|
||||||
import { TrackerSearch } from '@/modules/tracker/components/TrackerSearch.tsx';
|
import { TrackerSearch } from '@/modules/tracker/components/TrackerSearch.tsx';
|
||||||
import { TrackerActiveCard } from '@/modules/tracker/components/cards/TrackerActiveCard.tsx';
|
import { TrackerActiveCard } from '@/modules/tracker/components/cards/TrackerActiveCard.tsx';
|
||||||
import { TTrackerBind, TTrackRecordBind } from '@/modules/tracker/services/Trackers.ts';
|
|
||||||
import { MangaType } from '@/lib/graphql/generated/graphql.ts';
|
import { MangaType } from '@/lib/graphql/generated/graphql.ts';
|
||||||
|
|
||||||
import { MangaIdInfo } from '@/modules/manga/Manga.types.ts';
|
import { MangaIdInfo } from '@/modules/manga/Manga.types.ts';
|
||||||
|
import { TTrackerBind, TTrackRecordBind } from '@/modules/tracker/Tracker.types.ts';
|
||||||
|
|
||||||
export enum TrackerMode {
|
export enum TrackerMode {
|
||||||
UNTRACKED,
|
UNTRACKED,
|
||||||
|
|||||||
@@ -26,13 +26,14 @@ import { SpinnerImage } from '@/modules/core/components/SpinnerImage.tsx';
|
|||||||
import { TypographyMaxLines } from '@/modules/core/components/texts/TypographyMaxLines.tsx';
|
import { TypographyMaxLines } from '@/modules/core/components/texts/TypographyMaxLines.tsx';
|
||||||
import { Metadata } from '@/modules/core/components/texts/Metadata.tsx';
|
import { Metadata } from '@/modules/core/components/texts/Metadata.tsx';
|
||||||
import { MediaQuery } from '@/modules/core/utils/MediaQuery.tsx';
|
import { MediaQuery } from '@/modules/core/utils/MediaQuery.tsx';
|
||||||
import { Trackers, TTrackerManga } from '@/modules/tracker/services/Trackers.ts';
|
import { Trackers } from '@/modules/tracker/services/Trackers.ts';
|
||||||
import { MANGA_COVER_ASPECT_RATIO } from '@/modules/manga/Manga.constants.ts';
|
import { MANGA_COVER_ASPECT_RATIO } from '@/modules/manga/Manga.constants.ts';
|
||||||
import { MUIUtil } from '@/lib/mui/MUI.util.ts';
|
import { MUIUtil } from '@/lib/mui/MUI.util.ts';
|
||||||
import {
|
import {
|
||||||
PUBLISHING_STATUS_TO_TRANSLATION,
|
PUBLISHING_STATUS_TO_TRANSLATION,
|
||||||
PUBLISHING_TYPE_TO_TRANSLATION,
|
PUBLISHING_TYPE_TO_TRANSLATION,
|
||||||
} from '@/modules/tracker/Tracker.constants.ts';
|
} from '@/modules/tracker/Tracker.constants.ts';
|
||||||
|
import { TTrackerManga } from '@/modules/tracker/Tracker.types.ts';
|
||||||
|
|
||||||
const TrackerMangaCardTitle = ({ title, selected }: { title: string; selected: boolean }) => (
|
const TrackerMangaCardTitle = ({ title, selected }: { title: string; selected: boolean }) => (
|
||||||
<Stack
|
<Stack
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import Stack from '@mui/material/Stack';
|
import Stack from '@mui/material/Stack';
|
||||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||||
import { CARD_STYLING } from '@/modules/tracker/Tracker.constants.ts';
|
import { CARD_STYLING } from '@/modules/tracker/Tracker.constants.ts';
|
||||||
import { TTrackerBase } from '@/modules/tracker/services/Trackers.ts';
|
|
||||||
|
import { TTrackerBase } from '@/modules/tracker/Tracker.types.ts';
|
||||||
|
|
||||||
export const TrackerUntrackedCard = ({
|
export const TrackerUntrackedCard = ({
|
||||||
tracker,
|
tracker,
|
||||||
|
|||||||
@@ -6,56 +6,16 @@
|
|||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { TrackerType, TrackRecordType, TrackSearchType } from '@/lib/graphql/generated/graphql.ts';
|
import {
|
||||||
import { PublishingStatus, PublishingType } from '@/modules/tracker/Tracker.types.ts';
|
LoggedInInfo,
|
||||||
|
PublishingStatus,
|
||||||
export enum Tracker {
|
PublishingType,
|
||||||
MYANIMELIST = 1,
|
TrackerIdInfo,
|
||||||
}
|
TrackRecordTrackerInfo,
|
||||||
|
TrackSearchPublishingStatusInfo,
|
||||||
export const UNSET_DATE = '0';
|
TrackSearchPublishingTypeInfo,
|
||||||
|
} from '@/modules/tracker/Tracker.types.ts';
|
||||||
export type TTrackRecordBase = Pick<TrackRecordType, 'id' | 'remoteId' | 'title'>;
|
import { UNSET_DATE } from '@/modules/tracker/Tracker.constants.ts';
|
||||||
|
|
||||||
export type TTrackRecordBind = TTrackRecordBase &
|
|
||||||
Pick<
|
|
||||||
TrackRecordType,
|
|
||||||
| 'trackerId'
|
|
||||||
| 'remoteUrl'
|
|
||||||
| 'status'
|
|
||||||
| 'lastChapterRead'
|
|
||||||
| 'totalChapters'
|
|
||||||
| 'score'
|
|
||||||
| 'displayScore'
|
|
||||||
| 'startDate'
|
|
||||||
| 'finishDate'
|
|
||||||
>;
|
|
||||||
|
|
||||||
export type TTrackerManga = Pick<
|
|
||||||
TrackSearchType,
|
|
||||||
| 'id'
|
|
||||||
| 'remoteId'
|
|
||||||
| 'trackingUrl'
|
|
||||||
| 'title'
|
|
||||||
| 'coverUrl'
|
|
||||||
| 'publishingType'
|
|
||||||
| 'startDate'
|
|
||||||
| 'publishingStatus'
|
|
||||||
| 'summary'
|
|
||||||
>;
|
|
||||||
|
|
||||||
export type TTrackerBase = Pick<TrackerType, 'id' | 'name' | 'icon' | 'isLoggedIn' | 'isTokenExpired'>;
|
|
||||||
|
|
||||||
export type TTrackerSearch = TTrackerBase & Pick<TrackerType, 'authUrl'>;
|
|
||||||
|
|
||||||
export type TTrackerBind = TTrackerBase & Pick<TrackerType, 'icon' | 'supportsTrackDeletion' | 'scores' | 'statuses'>;
|
|
||||||
|
|
||||||
type TrackerIdInfo = Pick<TrackerType, 'id'>;
|
|
||||||
type LoggedInInfo = Pick<TrackerType, 'isLoggedIn' | 'isTokenExpired'>;
|
|
||||||
|
|
||||||
type TrackRecordTrackerInfo = Pick<TrackRecordType, 'trackerId'>;
|
|
||||||
type TrackSearchPublishingTypeInfo = Pick<TrackSearchType, 'publishingType'>;
|
|
||||||
type TrackSearchPublishingStatusInfo = Pick<TrackSearchType, 'publishingStatus'>;
|
|
||||||
|
|
||||||
export class Trackers {
|
export class Trackers {
|
||||||
static getIds(trackers: TrackerIdInfo[]): number[] {
|
static getIds(trackers: TrackerIdInfo[]): number[] {
|
||||||
|
|||||||
Reference in New Issue
Block a user