From 3abc582f93ef2a8fd3e6b7e2e1bbb2a826a1d8cb Mon Sep 17 00:00:00 2001 From: Pavlo Tsimura Date: Fri, 1 Dec 2023 13:04:16 +0100 Subject: [PATCH] Discard loading state on empty search request --- src/libs/actions/Report.js | 2 +- src/pages/NewChatPage.js | 4 +--- src/pages/SearchPage.js | 5 +---- .../MoneyRequestParticipantsSelector.js | 4 +--- src/pages/tasks/TaskShareDestinationSelectorModal.js | 4 +--- 5 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index a03488429405..e68c13e20407 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -2490,7 +2490,7 @@ const debouncedSearchInServer = lodashDebounce(searchForReports, CONST.TIMING.SE * @param {string} searchInput */ function searchInServer(searchInput) { - if (isNetworkOffline) { + if (isNetworkOffline || !searchInput.trim().length) { Onyx.set(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, false); return; } diff --git a/src/pages/NewChatPage.js b/src/pages/NewChatPage.js index aae61b100cd7..2bbd0556aad8 100755 --- a/src/pages/NewChatPage.js +++ b/src/pages/NewChatPage.js @@ -210,9 +210,7 @@ function NewChatPage({betas, isGroupChat, personalDetails, reports, translate, i // When search term updates we will fetch any reports const setSearchTermAndSearchInServer = useCallback((text = '') => { - if (text.length) { - Report.searchInServer(text); - } + Report.searchInServer(text); setSearchTerm(text); }, []); diff --git a/src/pages/SearchPage.js b/src/pages/SearchPage.js index 3332c3d2058a..5d111e7c181f 100755 --- a/src/pages/SearchPage.js +++ b/src/pages/SearchPage.js @@ -84,10 +84,7 @@ class SearchPage extends Component { } onChangeText(searchValue = '') { - if (searchValue.length) { - Report.searchInServer(searchValue); - } - + Report.searchInServer(searchValue); this.setState({searchValue}, this.debouncedUpdateOptions); } diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js index 61ca7853cc27..c08c8c0a21b8 100755 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js @@ -259,9 +259,7 @@ function MoneyRequestParticipantsSelector({ // When search term updates we will fetch any reports const setSearchTermAndSearchInServer = useCallback((text = '') => { - if (text.length) { - Report.searchInServer(text); - } + Report.searchInServer(text); setSearchTerm(text); }, []); diff --git a/src/pages/tasks/TaskShareDestinationSelectorModal.js b/src/pages/tasks/TaskShareDestinationSelectorModal.js index cb7ee9704021..914afa34bd85 100644 --- a/src/pages/tasks/TaskShareDestinationSelectorModal.js +++ b/src/pages/tasks/TaskShareDestinationSelectorModal.js @@ -119,9 +119,7 @@ function TaskShareDestinationSelectorModal(props) { // When search term updates we will fetch any reports const setSearchTermAndSearchInServer = useCallback((text = '') => { - if (text.length) { - Report.searchInServer(text); - } + Report.searchInServer(text); setSearchValue(text); }, []);