From 096deaad7a18389318bfcba931775835bc7fad66 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 6 May 2021 02:11:43 +0200 Subject: [PATCH] [Glitch] Fix "You might be interested in" flashing while searching in web UI Port f932cc9b26ace2a151ac9f4a5c292605e989b008 to glitch-soc Signed-off-by: Claire --- app/javascript/flavours/glitch/actions/search.js | 1 + .../glitch/features/compose/components/search_results.js | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/javascript/flavours/glitch/actions/search.js b/app/javascript/flavours/glitch/actions/search.js index a025f352a5..b4aee4525d 100644 --- a/app/javascript/flavours/glitch/actions/search.js +++ b/app/javascript/flavours/glitch/actions/search.js @@ -32,6 +32,7 @@ export function submitSearch() { const value = getState().getIn(['search', 'value']); if (value.length === 0) { + dispatch(fetchSearchSuccess({ accounts: [], statuses: [], hashtags: [] }, '')); return; } diff --git a/app/javascript/flavours/glitch/features/compose/components/search_results.js b/app/javascript/flavours/glitch/features/compose/components/search_results.js index c7e225507f..a0f86a06aa 100644 --- a/app/javascript/flavours/glitch/features/compose/components/search_results.js +++ b/app/javascript/flavours/glitch/features/compose/components/search_results.js @@ -33,6 +33,12 @@ class SearchResults extends ImmutablePureComponent { } } + componentDidUpdate () { + if (this.props.searchTerm === '') { + this.props.fetchSuggestions(); + } + } + handleLoadMoreAccounts = () => this.props.expandSearch('accounts'); handleLoadMoreStatuses = () => this.props.expandSearch('statuses'); @@ -42,7 +48,7 @@ class SearchResults extends ImmutablePureComponent { render () { const { intl, results, suggestions, dismissSuggestion, searchTerm } = this.props; - if (results.isEmpty() && !suggestions.isEmpty()) { + if (searchTerm === '' && !suggestions.isEmpty()) { return (