|
|
@ -21,7 +21,7 @@ import {
|
|
|
|
MessageIcon,
|
|
|
|
MessageIcon,
|
|
|
|
SimpleTable,
|
|
|
|
SimpleTable,
|
|
|
|
} from "..";
|
|
|
|
} from "..";
|
|
|
|
import BackgroundTask from "../../@modules/task";
|
|
|
|
import { dispatchTask } from "../../@modules/task";
|
|
|
|
import { createTask } from "../../@modules/task/utilites";
|
|
|
|
import { createTask } from "../../@modules/task/utilites";
|
|
|
|
import { useProfileBy, useProfileItemsToLanguages } from "../../@redux/hooks";
|
|
|
|
import { useProfileBy, useProfileItemsToLanguages } from "../../@redux/hooks";
|
|
|
|
import { EpisodesApi, SubtitlesApi } from "../../apis";
|
|
|
|
import { EpisodesApi, SubtitlesApi } from "../../apis";
|
|
|
@ -29,15 +29,9 @@ import { Selector } from "../inputs";
|
|
|
|
import BaseModal, { BaseModalProps } from "./BaseModal";
|
|
|
|
import BaseModal, { BaseModalProps } from "./BaseModal";
|
|
|
|
import { useModalInformation } from "./hooks";
|
|
|
|
import { useModalInformation } from "./hooks";
|
|
|
|
|
|
|
|
|
|
|
|
enum State {
|
|
|
|
|
|
|
|
Updating,
|
|
|
|
|
|
|
|
Valid,
|
|
|
|
|
|
|
|
Warning,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface PendingSubtitle {
|
|
|
|
interface PendingSubtitle {
|
|
|
|
file: File;
|
|
|
|
file: File;
|
|
|
|
state: State;
|
|
|
|
fetching: boolean;
|
|
|
|
instance?: Item.Episode;
|
|
|
|
instance?: Item.Episode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -95,11 +89,14 @@ const SeriesUploadModal: FunctionComponent<SerieProps & BaseModalProps> = ({
|
|
|
|
}, {});
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
|
|
|
|
setPending((pd) =>
|
|
|
|
setPending((pd) =>
|
|
|
|
pd.map((v) => ({
|
|
|
|
pd.map((v) => {
|
|
|
|
...v,
|
|
|
|
const instance = episodeMap[v.file.name];
|
|
|
|
state: State.Valid,
|
|
|
|
return {
|
|
|
|
instance: episodeMap[v.file.name],
|
|
|
|
...v,
|
|
|
|
}))
|
|
|
|
instance,
|
|
|
|
|
|
|
|
fetching: false,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
})
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -113,7 +110,7 @@ const SeriesUploadModal: FunctionComponent<SerieProps & BaseModalProps> = ({
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
file: f,
|
|
|
|
file: f,
|
|
|
|
didCheck: false,
|
|
|
|
didCheck: false,
|
|
|
|
state: State.Updating,
|
|
|
|
fetching: true,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
});
|
|
|
|
setPending(list);
|
|
|
|
setPending(list);
|
|
|
@ -144,7 +141,7 @@ const SeriesUploadModal: FunctionComponent<SerieProps & BaseModalProps> = ({
|
|
|
|
|
|
|
|
|
|
|
|
return createTask(
|
|
|
|
return createTask(
|
|
|
|
v.file.name,
|
|
|
|
v.file.name,
|
|
|
|
seriesid,
|
|
|
|
episodeid,
|
|
|
|
EpisodesApi.uploadSubtitles.bind(EpisodesApi),
|
|
|
|
EpisodesApi.uploadSubtitles.bind(EpisodesApi),
|
|
|
|
seriesid,
|
|
|
|
seriesid,
|
|
|
|
episodeid,
|
|
|
|
episodeid,
|
|
|
@ -152,7 +149,7 @@ const SeriesUploadModal: FunctionComponent<SerieProps & BaseModalProps> = ({
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
BackgroundTask.dispatch(TaskGroupName, tasks);
|
|
|
|
dispatchTask(TaskGroupName, tasks, "Uploading subtitles...");
|
|
|
|
}, [payload, pending, language]);
|
|
|
|
}, [payload, pending, language]);
|
|
|
|
|
|
|
|
|
|
|
|
const canUpload = useMemo(
|
|
|
|
const canUpload = useMemo(
|
|
|
@ -169,28 +166,35 @@ const SeriesUploadModal: FunctionComponent<SerieProps & BaseModalProps> = ({
|
|
|
|
() => [
|
|
|
|
() => [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
id: "Icon",
|
|
|
|
id: "Icon",
|
|
|
|
accessor: "state",
|
|
|
|
accessor: "fetching",
|
|
|
|
className: "text-center",
|
|
|
|
className: "text-center",
|
|
|
|
Cell: ({ value: state }) => {
|
|
|
|
Cell: ({ value: fetching, row: { original } }) => {
|
|
|
|
let icon = faCircleNotch;
|
|
|
|
let icon = faCircleNotch;
|
|
|
|
let color: string | undefined = undefined;
|
|
|
|
let color: string | undefined = undefined;
|
|
|
|
let spin = false;
|
|
|
|
let spin = false;
|
|
|
|
let msgs: string[] = [];
|
|
|
|
let msgs: string[] = [];
|
|
|
|
|
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
const override = useMemo(
|
|
|
|
case State.Valid:
|
|
|
|
() =>
|
|
|
|
icon = faCheck;
|
|
|
|
original.instance?.subtitles.find(
|
|
|
|
color = "var(--success)";
|
|
|
|
(v) => v.code2 === language?.code2
|
|
|
|
break;
|
|
|
|
) !== undefined,
|
|
|
|
case State.Warning:
|
|
|
|
[original.instance?.subtitles]
|
|
|
|
icon = faInfoCircle;
|
|
|
|
);
|
|
|
|
color = "var(--warning)";
|
|
|
|
|
|
|
|
break;
|
|
|
|
if (fetching) {
|
|
|
|
case State.Updating:
|
|
|
|
spin = true;
|
|
|
|
spin = true;
|
|
|
|
} else if (override) {
|
|
|
|
break;
|
|
|
|
icon = faInfoCircle;
|
|
|
|
default:
|
|
|
|
color = "var(--warning)";
|
|
|
|
break;
|
|
|
|
msgs.push("Overwrite existing subtitle");
|
|
|
|
|
|
|
|
} else if (original.instance) {
|
|
|
|
|
|
|
|
icon = faCheck;
|
|
|
|
|
|
|
|
color = "var(--success)";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
icon = faInfoCircle;
|
|
|
|
|
|
|
|
color = "var(--warning)";
|
|
|
|
|
|
|
|
msgs.push("Season or episode info is missing");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
@ -262,7 +266,7 @@ const SeriesUploadModal: FunctionComponent<SerieProps & BaseModalProps> = ({
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
[]
|
|
|
|
[language?.code2]
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const updateItem = useCallback<TableUpdater<PendingSubtitle>>(
|
|
|
|
const updateItem = useCallback<TableUpdater<PendingSubtitle>>(
|
|
|
|