diff --git a/src/components/tracker/TrackerActiveCard.tsx b/src/components/tracker/TrackerActiveCard.tsx index 183602cb..35eb9d21 100644 --- a/src/components/tracker/TrackerActiveCard.tsx +++ b/src/components/tracker/TrackerActiveCard.tsx @@ -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 ( diff --git a/src/i18n/locale/en.json b/src/i18n/locale/en.json index a8d4f7b5..d7e901aa 100644 --- a/src/i18n/locale/en.json +++ b/src/i18n/locale/en.json @@ -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" } }, diff --git a/src/lib/graphql/generated/graphql.ts b/src/lib/graphql/generated/graphql.ts index 66f75a78..29be037b 100644 --- a/src/lib/graphql/generated/graphql.ts +++ b/src/lib/graphql/generated/graphql.ts @@ -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; diff --git a/src/lib/graphql/mutations/TrackerMutation.ts b/src/lib/graphql/mutations/TrackerMutation.ts index 9df0a10c..7a6165f7 100644 --- a/src/lib/graphql/mutations/TrackerMutation.ts +++ b/src/lib/graphql/mutations/TrackerMutation.ts @@ -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 } } diff --git a/src/lib/requests/RequestManager.ts b/src/lib/requests/RequestManager.ts index 37bfd35b..e4f34269 100644 --- a/src/lib/requests/RequestManager.ts +++ b/src/lib/requests/RequestManager.ts @@ -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 { return this.doRequest(GQLMethod.MUTATION, TRACKER_UPDATE_BIND, { input: { ...patch, recordId: id } }, options); } + + public fetchTrackBind( + recordId: number, + options?: MutationOptions, + ): AbortableApolloMutationResponse { + return this.doRequest( + GQLMethod.MUTATION, + TRACKER_FETCH_BIND, + { recordId }, + options, + ); + } } export const requestManager = new RequestManager();