mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-25 17:17:12 +00:00
Improve series subtitles upload experience
This commit is contained in:
parent
c8e02e280a
commit
48ba08e068
1 changed files with 22 additions and 6 deletions
|
@ -205,19 +205,34 @@ const SeriesUploadModal: FunctionComponent<SerieProps & BaseModalProps> = ({
|
|||
|
||||
setProcessState(uploadStates);
|
||||
|
||||
let exception = false;
|
||||
|
||||
for (const info of pending) {
|
||||
if (info.instance) {
|
||||
const { sonarrEpisodeId: episodeid } = info.instance;
|
||||
await EpisodesApi.uploadSubtitles(seriesid, episodeid, info.form);
|
||||
|
||||
uploadStates = {
|
||||
...uploadStates,
|
||||
[info.form.file.name]: { state: State.Valid, infos: [] },
|
||||
};
|
||||
try {
|
||||
await EpisodesApi.uploadSubtitles(seriesid, episodeid, info.form);
|
||||
|
||||
uploadStates = {
|
||||
...uploadStates,
|
||||
[info.form.file.name]: { state: State.Valid, infos: [] },
|
||||
};
|
||||
} catch (error) {
|
||||
uploadStates = {
|
||||
...uploadStates,
|
||||
[info.form.file.name]: { state: State.Error, infos: [] },
|
||||
};
|
||||
exception = true;
|
||||
}
|
||||
|
||||
setProcessState(uploadStates);
|
||||
}
|
||||
}
|
||||
|
||||
if (exception) {
|
||||
throw new Error("Error when uploading subtitles");
|
||||
}
|
||||
}, [series, pending]);
|
||||
|
||||
const canUpload = useMemo(
|
||||
|
@ -289,6 +304,7 @@ const SeriesUploadModal: FunctionComponent<SerieProps & BaseModalProps> = ({
|
|||
accessor: "instance",
|
||||
className: "vw-1",
|
||||
Cell: ({ value, loose, row, externalUpdate }) => {
|
||||
const uploading = loose![0] as boolean;
|
||||
const availables = loose![2] as Item.Episode[];
|
||||
|
||||
const options = availables.map<SelectorOption<Item.Episode>>(
|
||||
|
@ -311,6 +327,7 @@ const SeriesUploadModal: FunctionComponent<SerieProps & BaseModalProps> = ({
|
|||
|
||||
return (
|
||||
<Selector
|
||||
disabled={uploading}
|
||||
options={options}
|
||||
value={value ?? null}
|
||||
onChange={change}
|
||||
|
@ -376,7 +393,6 @@ const SeriesUploadModal: FunctionComponent<SerieProps & BaseModalProps> = ({
|
|||
Clean
|
||||
</Button>
|
||||
<AsyncButton
|
||||
noReset
|
||||
disabled={!canUpload}
|
||||
onChange={setUpload}
|
||||
promise={uploadSubtitles}
|
||||
|
|
Loading…
Reference in a new issue