Skip to content

Commit c7697db

Browse files
Manual link: fix more spinners and toasts (#1123)
1 parent 2fa069a commit c7697db

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/pages/utilities/UnrecognizedUtilityTabs/LinkFilesTab.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ function LinkFilesTab() {
205205
() => selectedRows.map(file => ({ LinkID: generateLinkID(), FileID: file.ID, EpisodeID: 0 })),
206206
);
207207

208-
const { mutate: linkOneFileToManyEpisodes } = useLinkOneFileToManyEpisodesMutation();
209-
const { mutate: linkManyFilesToOneEpisode } = useLinkManyFilesToOneEpisodeMutation();
208+
const { mutateAsync: linkOneFileToManyEpisodes } = useLinkOneFileToManyEpisodesMutation();
209+
const { mutateAsync: linkManyFilesToOneEpisode } = useLinkManyFilesToOneEpisodeMutation();
210210

211211
const { mutate: deleteSeries } = useDeleteSeriesMutation();
212212
const { mutateAsync: refreshSeries } = useRefreshAniDBSeriesMutation();
@@ -349,6 +349,7 @@ function LinkFilesTab() {
349349
if (isLinking) return;
350350
setSelectedLink(-1);
351351
const doesNotExist = selectedSeries.ShokoID === null;
352+
setLoading({ isLinking: true, createdNewSeries: doesNotExist, isLinkingRunning: false });
352353
if (doesNotExist) {
353354
try {
354355
await refreshSeries({ anidbID: selectedSeries.ID, createSeriesEntry: true, immediate: true });
@@ -359,7 +360,6 @@ function LinkFilesTab() {
359360
setLoading({ isLinking: false, isLinkingRunning: false, createdNewSeries: false });
360361
}
361362
}
362-
setLoading({ isLinking: true, createdNewSeries: doesNotExist, isLinkingRunning: false });
363363
});
364364

365365
const rangeFill = (rangeStart: string, epType: string) => {
@@ -496,14 +496,14 @@ function LinkFilesTab() {
496496
}),
497497
...map(oneToOne, ({ EpisodeID, FileID }) => {
498498
const { path = '<missing file path>' } = showDataMap.get(FileID)!;
499-
linkOneFileToManyEpisodes({ episodeIDs: [EpisodeID], fileId: FileID }, {
499+
return linkOneFileToManyEpisodes({ episodeIDs: [EpisodeID], fileId: FileID }, {
500500
onSuccess: () => toast.success('Scheduled a 1:1 mapping for linking!', `Path: ${path}`),
501501
onError: () => toast.error('Failed at 1:1 linking!', `Path: ${path}`),
502502
});
503503
}),
504504
...map(oneToMany, ({ EpisodeIDs, FileID }) => {
505505
const { path = '<missing file path>' } = showDataMap.get(FileID)!;
506-
linkOneFileToManyEpisodes({ episodeIDs: EpisodeIDs, fileId: FileID }, {
506+
return linkOneFileToManyEpisodes({ episodeIDs: EpisodeIDs, fileId: FileID }, {
507507
onSuccess: () => toast.success(`Scheduled a 1:${EpisodeIDs.length} mapping for linking!`, `Path: ${path}`),
508508
onError: () => toast.error(`Failed at 1:${EpisodeIDs.length} linked!`, `Path: ${path}`),
509509
});
@@ -513,7 +513,7 @@ function LinkFilesTab() {
513513
const episodeDetails = episode
514514
? `Episode: ${episode.EpisodeNumber} - ${episode.Title}`
515515
: `Episode: ${EpisodeID}`;
516-
linkManyFilesToOneEpisode({ episodeID: EpisodeID, fileIDs: FileIDs }, {
516+
return linkManyFilesToOneEpisode({ episodeID: EpisodeID, fileIDs: FileIDs }, {
517517
onSuccess: () => toast.success(`Scheduled a ${FileIDs.length}:1 mapping for linking!`, episodeDetails),
518518
onError: () => toast.error(`Failed at ${FileIDs.length}:1 linking!`, episodeDetails),
519519
});

0 commit comments

Comments
 (0)