From a510ba9ab2b3f6e50ffb9c7e2a1a453302a68c7a Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 23 Feb 2022 11:26:40 +0100 Subject: [PATCH] linting --- .../search/src/lib/reducers/Reducer.ts | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/libs/remix-ui/search/src/lib/reducers/Reducer.ts b/libs/remix-ui/search/src/lib/reducers/Reducer.ts index 0841b2b424..05e9efaecb 100644 --- a/libs/remix-ui/search/src/lib/reducers/Reducer.ts +++ b/libs/remix-ui/search/src/lib/reducers/Reducer.ts @@ -36,19 +36,23 @@ export const SearchReducer = (state: SearchState = SearchingInitialState, action count: 0 } case 'UPDATE_COUNT': - const findFile = state.searchResults.find(file => file.filename === action.payload.file) - let count = 0 - if (findFile) { - findFile.count = action.payload.count - } - state.searchResults.forEach(file => { - if (file.count) { - count += file.count + if (state.searchResults) { + const findFile = state.searchResults.find(file => file.filename === action.payload.file) + let count = 0 + if (findFile) { + findFile.count = action.payload.count } - }) - return { - ...state, - count: count + state.searchResults.forEach(file => { + if (file.count) { + count += file.count + } + }) + return { + ...state, + count: count + } + } else { + return state } case 'TOGGLE_CASE_SENSITIVE': return { @@ -68,7 +72,7 @@ export const SearchReducer = (state: SearchState = SearchingInitialState, action matchWord: !state.matchWord, timeStamp: Date.now() } - case 'SET_REPLACE_WITHOUT_CONFIRMATION': + case 'SET_REPLACE_WITHOUT_CONFIRMATION': return { ...state, replaceWithOutConfirmation: action.payload,