Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Discard loading state on empty search request #32371

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 1 addition & 3 deletions src/pages/NewChatPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}, []);

Expand Down
5 changes: 1 addition & 4 deletions src/pages/SearchPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ class SearchPage extends Component {
}

onChangeText(searchValue = '') {
if (searchValue.length) {
Report.searchInServer(searchValue);
}

Report.searchInServer(searchValue);
this.setState({searchValue}, this.debouncedUpdateOptions);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}, []);

Expand Down
4 changes: 1 addition & 3 deletions src/pages/tasks/TaskShareDestinationSelectorModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}, []);

Expand Down
Loading