Fetch latest track data from tracker (#692)
This commit is contained in:
@@ -29,7 +29,7 @@ import {
|
||||
} from '@mui/material';
|
||||
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
||||
import PopupState, { bindDialog, bindMenu, bindTrigger } from 'material-ui-popup-state';
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import { Trackers, TTrackRecord, UNSET_DATE } from '@/lib/data/Trackers.ts';
|
||||
import { ListPreference } from '@/components/sourceConfiguration/ListPreference.tsx';
|
||||
@@ -235,6 +235,12 @@ export const TrackerActiveCard = ({
|
||||
.response.catch(() => makeToast(t('global.error.label.failed_to_save_changes'), 'error'));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
requestManager
|
||||
.fetchTrackBind(trackRecord.id)
|
||||
.response.catch(() => makeToast(t('tracking.error.label.could_not_fetch_track_info'), 'error'));
|
||||
}, [trackRecord.id]);
|
||||
|
||||
return (
|
||||
<Card sx={CARD_STYLING}>
|
||||
<CardContent sx={{ padding: 0 }}>
|
||||
|
||||
@@ -1101,6 +1101,7 @@
|
||||
},
|
||||
"error": {
|
||||
"label": {
|
||||
"could_not_fetch_track_info": "Could not load latest track info from tracker",
|
||||
"could_not_load_track_info": "Could not load track info"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -3012,12 +3012,12 @@ export type TrackerUpdateBindMutationVariables = Exact<{
|
||||
|
||||
export type TrackerUpdateBindMutation = { __typename?: 'Mutation', updateTrack: { __typename?: 'UpdateTrackPayload', trackRecord?: { __typename?: 'TrackRecordType', title: string, remoteUrl: string, remoteId: string, id: number, status: number, lastChapterRead: number, totalChapters: number, score: number, displayScore: string, startDate: string, finishDate: string, manga: { __typename?: 'MangaType', id: number, trackRecords: { __typename?: 'TrackRecordNodeList', totalCount: number, nodes: Array<{ __typename?: 'TrackRecordType', id: number }> } } } | null } };
|
||||
|
||||
export type TrackerTrackProgressMutationVariables = Exact<{
|
||||
mangaId: Scalars['Int']['input'];
|
||||
export type TrackerFetchBindMutationVariables = Exact<{
|
||||
recordId: Scalars['Int']['input'];
|
||||
}>;
|
||||
|
||||
|
||||
export type TrackerTrackProgressMutation = { __typename?: 'Mutation', trackProgress: { __typename?: 'TrackProgressPayload', trackRecords: Array<{ __typename?: 'TrackRecordType', id: number, status: number, lastChapterRead: number, totalChapters: number, score: number, displayScore: string, startDate: string, finishDate: string }> } };
|
||||
export type TrackerFetchBindMutation = { __typename?: 'Mutation', fetchTrack: { __typename?: 'FetchTrackPayload', trackRecord: { __typename?: 'TrackRecordType', id: number, status: number, lastChapterRead: number, totalChapters: number, score: number, displayScore: string, startDate: string, finishDate: string } } };
|
||||
|
||||
export type UpdateCategoryMangasMutationVariables = Exact<{
|
||||
input: UpdateCategoryMangaInput;
|
||||
|
||||
@@ -109,11 +109,11 @@ export const TRACKER_UPDATE_BIND = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
export const TRACKER_TRACK_PROGRESS = gql`
|
||||
export const TRACKER_FETCH_BIND = gql`
|
||||
${BASE_TRACK_RECORD_FIELDS}
|
||||
mutation TRACKER_TRACK_PROGRESS($mangaId: Int!) {
|
||||
trackProgress(input: { mangaId: $mangaId }) {
|
||||
trackRecords {
|
||||
mutation TRACKER_FETCH_BIND($recordId: Int!) {
|
||||
fetchTrack(input: { recordId: $recordId }) {
|
||||
trackRecord {
|
||||
...BASE_TRACK_RECORD_FIELDS
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,6 +194,8 @@ import {
|
||||
UpdateTrackInput,
|
||||
TrackerUnbindMutation,
|
||||
TrackerUnbindMutationVariables,
|
||||
TrackerFetchBindMutation,
|
||||
TrackerFetchBindMutationVariables,
|
||||
} from '@/lib/graphql/generated/graphql.ts';
|
||||
import { GET_GLOBAL_METADATAS } from '@/lib/graphql/queries/GlobalMetadataQuery.ts';
|
||||
import { SET_GLOBAL_METADATA } from '@/lib/graphql/mutations/GlobalMetadataMutation.ts';
|
||||
@@ -277,6 +279,7 @@ import { Queue, QueuePriority } from '@/lib/Queue.ts';
|
||||
import { GET_TRACKERS, TRACKER_SEARCH } from '@/lib/graphql/queries/TrackerQuery.ts';
|
||||
import {
|
||||
TRACKER_BIND,
|
||||
TRACKER_FETCH_BIND,
|
||||
TRACKER_LOGIN_CREDENTIALS,
|
||||
TRACKER_LOGIN_OAUTH,
|
||||
TRACKER_LOGOUT,
|
||||
@@ -2499,6 +2502,18 @@ export class RequestManager {
|
||||
): AbortableApolloMutationResponse<TrackerUpdateBindMutation> {
|
||||
return this.doRequest(GQLMethod.MUTATION, TRACKER_UPDATE_BIND, { input: { ...patch, recordId: id } }, options);
|
||||
}
|
||||
|
||||
public fetchTrackBind(
|
||||
recordId: number,
|
||||
options?: MutationOptions<TrackerFetchBindMutation, TrackerFetchBindMutationVariables>,
|
||||
): AbortableApolloMutationResponse<TrackerFetchBindMutation> {
|
||||
return this.doRequest<TrackerFetchBindMutation, TrackerFetchBindMutationVariables>(
|
||||
GQLMethod.MUTATION,
|
||||
TRACKER_FETCH_BIND,
|
||||
{ recordId },
|
||||
options,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const requestManager = new RequestManager();
|
||||
|
||||
Reference in New Issue
Block a user