From 6994da072dd83efffad243ddabf3fa009b01a78a Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Tue, 24 Aug 2021 21:59:59 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Fixed=20bugs=20with=20tab=20chan?= =?UTF-8?q?ges=20and=20state?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/actions/fileops.actions.tsx | 9 ++++++--- src/client/components/DownloadsPanel.tsx | 6 +++--- src/client/constants/action-types.ts | 1 + src/client/reducers/airdcpp.reducer.ts | 5 +++++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/client/actions/fileops.actions.tsx b/src/client/actions/fileops.actions.tsx index 625f77b..78a5913 100644 --- a/src/client/actions/fileops.actions.tsx +++ b/src/client/actions/fileops.actions.tsx @@ -105,7 +105,7 @@ export const getComicBooks = (options) => async (dispatch) => { }); }; -export const importToDB = (payload) => (dispatch) => { +export const importToDB = (payload?: any) => (dispatch) => { try { const comicBookMetadata = { importStatus: { @@ -115,7 +115,7 @@ export const importToDB = (payload) => (dispatch) => { score: "0", }, }, - sourcedMetadata: { comicvine: payload }, + sourcedMetadata: { comicvine: payload || null }, }; dispatch({ type: IMS_CV_METADATA_IMPORT_CALL_IN_PROGRESS, @@ -164,7 +164,10 @@ export const fetchComicVineMatches = (searchPayload) => (dispatch) => { data: { format: "json", sort: "name%3Aasc", - query: issueSearchQuery.searchParams.searchTerms.name, + // hack + query: issueSearchQuery.searchParams.searchTerms.name + .replace(/[^a-zA-Z0-9 ]/g, "") + .trim(), fieldList: "id", limit: "20", offset: "0", diff --git a/src/client/components/DownloadsPanel.tsx b/src/client/components/DownloadsPanel.tsx index ae516e2..be5370a 100644 --- a/src/client/components/DownloadsPanel.tsx +++ b/src/client/components/DownloadsPanel.tsx @@ -1,8 +1,8 @@ -import React, { useCallback, useEffect, useState, ReactElement } from "react"; +import React, { useEffect, ReactElement } from "react"; import { getDownloadProgress } from "../actions/airdcpp.actions"; import { useDispatch, useSelector } from "react-redux"; -import { RootState, SearchInstance } from "threetwo-ui-typings"; -import { isNil, map } from "lodash"; +import { RootState } from "threetwo-ui-typings"; +import { isNil } from "lodash"; import prettyBytes from "pretty-bytes"; interface IDownloadsPanelProps { diff --git a/src/client/constants/action-types.ts b/src/client/constants/action-types.ts index 1d1213a..1128b13 100644 --- a/src/client/constants/action-types.ts +++ b/src/client/constants/action-types.ts @@ -1,3 +1,4 @@ + export const CV_API_CALL_IN_PROGRESS = "CV_SEARCH_IN_PROGRESS"; export const CV_SEARCH_FAILURE = "CV_SEARCH_FAILURE"; export const CV_SEARCH_SUCCESS = "CV_SEARCH_SUCCESS"; diff --git a/src/client/reducers/airdcpp.reducer.ts b/src/client/reducers/airdcpp.reducer.ts index 2edbc11..117243a 100644 --- a/src/client/reducers/airdcpp.reducer.ts +++ b/src/client/reducers/airdcpp.reducer.ts @@ -5,6 +5,7 @@ import { AIRDCPP_RESULT_DOWNLOAD_INITIATED, AIRDCPP_DOWNLOAD_PROGRESS_TICK, } from "../constants/action-types"; +import { LOCATION_CHANGE } from "connected-react-router"; const initialState = { isAirDCPPSearchInProgress: false, @@ -49,6 +50,10 @@ function airdcppReducer(state = initialState, action) { ...state, downloadProgressData: action.downloadProgressData, }; + case LOCATION_CHANGE: + return { + initialState, + }; default: return state;