From 9765c5713c5739573712f9eeb7daaef2a811e0e6 Mon Sep 17 00:00:00 2001 From: LASER-Yi Date: Sun, 22 Aug 2021 16:35:55 +0800 Subject: Move scan and search action to background --- frontend/src/Movies/Detail/index.tsx | 40 +++++++++++++++++++++++----------- frontend/src/Series/Episodes/index.tsx | 40 +++++++++++++++++++++++++--------- frontend/src/Wanted/generic/index.tsx | 18 +++++++++++---- 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 = ({ match }) => { - - 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 - - + - 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 - + = (props) => { - - 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 - - + - 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) => { } > Search - + { @@ -14,6 +17,8 @@ interface Props { searchAll: () => Promise; } +const TaskGroupName = "Searching wanted subtitles..."; + function GenericWantedView({ type, columns, @@ -25,19 +30,24 @@ function GenericWantedView({ const dataCount = Object.keys(state.content.entities).length; + const hasTask = useIsGroupTaskRunning(TaskGroupName); + return ( Wanted {typeName} - Bazarr - { + const task = createTask(type, undefined, searchAll); + dispatchTask(TaskGroupName, [task], "Searching..."); + }} icon={faSearch} > Search All - +