mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-07 23:37:58 +08: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);
|
setProcessState(uploadStates);
|
||||||
|
|
||||||
|
let exception = false;
|
||||||
|
|
||||||
for (const info of pending) {
|
for (const info of pending) {
|
||||||
if (info.instance) {
|
if (info.instance) {
|
||||||
const { sonarrEpisodeId: episodeid } = info.instance;
|
const { sonarrEpisodeId: episodeid } = info.instance;
|
||||||
await EpisodesApi.uploadSubtitles(seriesid, episodeid, info.form);
|
|
||||||
|
|
||||||
uploadStates = {
|
try {
|
||||||
...uploadStates,
|
await EpisodesApi.uploadSubtitles(seriesid, episodeid, info.form);
|
||||||
[info.form.file.name]: { state: State.Valid, infos: [] },
|
|
||||||
};
|
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);
|
setProcessState(uploadStates);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (exception) {
|
||||||
|
throw new Error("Error when uploading subtitles");
|
||||||
|
}
|
||||||
}, [series, pending]);
|
}, [series, pending]);
|
||||||
|
|
||||||
const canUpload = useMemo(
|
const canUpload = useMemo(
|
||||||
|
@ -289,6 +304,7 @@ const SeriesUploadModal: FunctionComponent<SerieProps & BaseModalProps> = ({
|
||||||
accessor: "instance",
|
accessor: "instance",
|
||||||
className: "vw-1",
|
className: "vw-1",
|
||||||
Cell: ({ value, loose, row, externalUpdate }) => {
|
Cell: ({ value, loose, row, externalUpdate }) => {
|
||||||
|
const uploading = loose![0] as boolean;
|
||||||
const availables = loose![2] as Item.Episode[];
|
const availables = loose![2] as Item.Episode[];
|
||||||
|
|
||||||
const options = availables.map<SelectorOption<Item.Episode>>(
|
const options = availables.map<SelectorOption<Item.Episode>>(
|
||||||
|
@ -311,6 +327,7 @@ const SeriesUploadModal: FunctionComponent<SerieProps & BaseModalProps> = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Selector
|
<Selector
|
||||||
|
disabled={uploading}
|
||||||
options={options}
|
options={options}
|
||||||
value={value ?? null}
|
value={value ?? null}
|
||||||
onChange={change}
|
onChange={change}
|
||||||
|
@ -376,7 +393,6 @@ const SeriesUploadModal: FunctionComponent<SerieProps & BaseModalProps> = ({
|
||||||
Clean
|
Clean
|
||||||
</Button>
|
</Button>
|
||||||
<AsyncButton
|
<AsyncButton
|
||||||
noReset
|
|
||||||
disabled={!canUpload}
|
disabled={!canUpload}
|
||||||
onChange={setUpload}
|
onChange={setUpload}
|
||||||
promise={uploadSubtitles}
|
promise={uploadSubtitles}
|
||||||
|
|
Loading…
Reference in a new issue