summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLASER-Yi <[email protected]>2021-08-22 16:35:55 +0800
committerLASER-Yi <[email protected]>2021-08-22 16:35:55 +0800
commit9765c5713c5739573712f9eeb7daaef2a811e0e6 (patch)
treefcf1f17c3e1009f9d09c8c76332c2404bbf32778
parent03156f2981889e5ac34a460c0631b688706f6452 (diff)
downloadbazarr-9765c5713c5739573712f9eeb7daaef2a811e0e6.tar.gz
bazarr-9765c5713c5739573712f9eeb7daaef2a811e0e6.zip
Move scan and search action to background
-rw-r--r--frontend/src/Movies/Detail/index.tsx40
-rw-r--r--frontend/src/Series/Episodes/index.tsx40
-rw-r--r--frontend/src/Wanted/generic/index.tsx18
3 files changed, 71 insertions, 27 deletions
diff --git a/frontend/src/Movies/Detail/index.tsx b/frontend/src/Movies/Detail/index.tsx
index dd6234c31..d13b040e6 100644
--- a/frontend/src/Movies/Detail/index.tsx
+++ b/frontend/src/Movies/Detail/index.tsx
@@ -11,7 +11,9 @@ import React, { FunctionComponent, useState } from "react";
import { Alert, Container, Row } from "react-bootstrap";
import { Helmet } from "react-helmet";
import { Redirect, RouteComponentProps, withRouter } from "react-router-dom";
+import { dispatchTask } from "../../@modules/task";
import { useIsAnyTaskRunningWithId } from "../../@modules/task/hooks";
+import { createTask } from "../../@modules/task/utilites";
import { useMovieBy, useProfileBy } from "../../@redux/hooks";
import { MoviesApi, ProvidersApi } from "../../apis";
import {
@@ -83,27 +85,39 @@ const MovieDetailView: FunctionComponent<Props> = ({ match }) => {
</Helmet>
<ContentHeader>
<ContentHeader.Group pos="start">
- <ContentHeader.AsyncButton
+ <ContentHeader.Button
icon={faSync}
disabled={hasTask}
- promise={() =>
- MoviesApi.action({ action: "scan-disk", radarrid: item.radarrId })
- }
+ onClick={() => {
+ const task = createTask(
+ item.title,
+ id,
+ MoviesApi.action.bind(MoviesApi),
+ { action: "scan-disk", radarrid: id }
+ );
+ dispatchTask("Scaning Disk...", [task], "Scaning...");
+ }}
>
Scan Disk
- </ContentHeader.AsyncButton>
- <ContentHeader.AsyncButton
+ </ContentHeader.Button>
+ <ContentHeader.Button
icon={faSearch}
disabled={item.profileId === null || hasTask}
- promise={() =>
- MoviesApi.action({
- action: "search-missing",
- radarrid: item.radarrId,
- })
- }
+ onClick={() => {
+ const task = createTask(
+ item.title,
+ id,
+ MoviesApi.action.bind(MoviesApi),
+ {
+ action: "search-missing",
+ radarrid: id,
+ }
+ );
+ dispatchTask("Searching subtitles...", [task], "Searching...");
+ }}
>
Search
- </ContentHeader.AsyncButton>
+ </ContentHeader.Button>
<ContentHeader.Button
icon={faUser}
disabled={item.profileId === null || hasTask}
diff --git a/frontend/src/Series/Episodes/index.tsx b/frontend/src/Series/Episodes/index.tsx
index 825d5e47a..3e9ae4bfa 100644
--- a/frontend/src/Series/Episodes/index.tsx
+++ b/frontend/src/Series/Episodes/index.tsx
@@ -11,7 +11,9 @@ import React, { FunctionComponent, useMemo, useState } from "react";
import { Alert, Container, Row } from "react-bootstrap";
import { Helmet } from "react-helmet";
import { Redirect, RouteComponentProps, withRouter } from "react-router-dom";
+import { dispatchTask } from "../../@modules/task";
import { useIsAnyTaskRunningWithId } from "../../@modules/task/hooks";
+import { createTask } from "../../@modules/task/utilites";
import { useEpisodesBy, useProfileBy, useSerieBy } from "../../@redux/hooks";
import { SeriesApi } from "../../apis";
import {
@@ -86,20 +88,38 @@ const SeriesEpisodesView: FunctionComponent<Props> = (props) => {
</Helmet>
<ContentHeader>
<ContentHeader.Group pos="start">
- <ContentHeader.AsyncButton
+ <ContentHeader.Button
icon={faSync}
disabled={!available || hasTask}
- promise={() =>
- SeriesApi.action({ action: "scan-disk", seriesid: id })
- }
+ onClick={() => {
+ const task = createTask(
+ serie.title,
+ id,
+ SeriesApi.action.bind(SeriesApi),
+ {
+ action: "scan-disk",
+ seriesid: id,
+ }
+ );
+ dispatchTask("Scaning disk...", [task], "Scaning...");
+ }}
>
Scan Disk
- </ContentHeader.AsyncButton>
- <ContentHeader.AsyncButton
+ </ContentHeader.Button>
+ <ContentHeader.Button
icon={faSearch}
- promise={() =>
- SeriesApi.action({ action: "search-missing", seriesid: id })
- }
+ onClick={() => {
+ const task = createTask(
+ serie.title,
+ id,
+ SeriesApi.action.bind(SeriesApi),
+ {
+ action: "search-missing",
+ seriesid: id,
+ }
+ );
+ dispatchTask("Searching subtitles...", [task], "Searching...");
+ }}
disabled={
serie.episodeFileCount === 0 ||
serie.profileId === null ||
@@ -108,7 +128,7 @@ const SeriesEpisodesView: FunctionComponent<Props> = (props) => {
}
>
Search
- </ContentHeader.AsyncButton>
+ </ContentHeader.Button>
</ContentHeader.Group>
<ContentHeader.Group pos="end">
<ContentHeader.Button
diff --git a/frontend/src/Wanted/generic/index.tsx b/frontend/src/Wanted/generic/index.tsx
index f8a4fda36..f25b346ee 100644
--- a/frontend/src/Wanted/generic/index.tsx
+++ b/frontend/src/Wanted/generic/index.tsx
@@ -4,6 +4,9 @@ import React from "react";
import { Container, Row } from "react-bootstrap";
import { Helmet } from "react-helmet";
import { Column } from "react-table";
+import { dispatchTask } from "../../@modules/task";
+import { useIsGroupTaskRunning } from "../../@modules/task/hooks";
+import { createTask } from "../../@modules/task/utilites";
import { AsyncPageTable, ContentHeader } from "../../components";
interface Props<T extends Wanted.Base> {
@@ -14,6 +17,8 @@ interface Props<T extends Wanted.Base> {
searchAll: () => Promise<void>;
}
+const TaskGroupName = "Searching wanted subtitles...";
+
function GenericWantedView<T extends Wanted.Base>({
type,
columns,
@@ -25,19 +30,24 @@ function GenericWantedView<T extends Wanted.Base>({
const dataCount = Object.keys(state.content.entities).length;
+ const hasTask = useIsGroupTaskRunning(TaskGroupName);
+
return (
<Container fluid>
<Helmet>
<title>Wanted {typeName} - Bazarr</title>
</Helmet>
<ContentHeader>
- <ContentHeader.AsyncButton
- disabled={dataCount === 0}
- promise={searchAll}
+ <ContentHeader.Button
+ disabled={dataCount === 0 || hasTask}
+ onClick={() => {
+ const task = createTask(type, undefined, searchAll);
+ dispatchTask(TaskGroupName, [task], "Searching...");
+ }}
icon={faSearch}
>
Search All
- </ContentHeader.AsyncButton>
+ </ContentHeader.Button>
</ContentHeader>
<Row>
<AsyncPageTable