From 76bfd279b34f960149dba15424593dfd5fbfb956 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 2 Aug 2017 15:38:54 -0400 Subject: PLT-7140: On slow connection searching should clear RHS and show spinner (#7014) * Added a RECEIVED_SEARCH_TERM event on search form submit, attempted to modify Search Results Header title when loading search results * Fixed RHS behaviour so that loading icon is shown while waiting for search results on slow connections. * PLT-7140: Fixed all eslint issues * PLT-7140: reverted changes to config/config.json that were accidentally committed * PLT-7140: Removed all static function decorators that I previously added to jsx files. These were suggested by eslint, but can cause issues for functions that override parent functionality. still can't reproduce the errors seen on spinmint locally, so I'm guessing at this point * PLT-7140: Changed var to const * Updating UI for search results loading (#7096) --- webapp/stores/search_store.jsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'webapp/stores') diff --git a/webapp/stores/search_store.jsx b/webapp/stores/search_store.jsx index d57c630cb..dd9b6dbdf 100644 --- a/webapp/stores/search_store.jsx +++ b/webapp/stores/search_store.jsx @@ -24,6 +24,7 @@ class SearchStoreClass extends EventEmitter { this.isPinnedPosts = false; this.isVisible = false; this.searchTerm = ''; + this.loading = false; } emitChange() { @@ -157,6 +158,14 @@ class SearchStoreClass extends EventEmitter { results.order.splice(index, 1); } } + + setLoading(loading) { + this.loading = loading; + } + + isLoading() { + return this.loading; + } } var SearchStore = new SearchStoreClass(); @@ -173,10 +182,17 @@ SearchStore.dispatchToken = AppDispatcher.register((payload) => { // ignore pin posts update after switch to a new channel return; } + SearchStore.setLoading(false); SearchStore.storeSearchResults(action.results, action.is_mention_search, action.is_flagged_posts, action.is_pinned_posts); SearchStore.emitSearchChange(); break; case ActionTypes.RECEIVED_SEARCH_TERM: + if (action.do_search) { + // while a search is in progress, hide results from previous search + SearchStore.setLoading(true); + SearchStore.storeSearchResults(null, false, false, false); + SearchStore.emitSearchChange(); + } SearchStore.storeSearchTerm(action.term); SearchStore.emitSearchTermChange(action.do_search, action.is_mention_search); break; -- cgit v1.2.3-1-g7c22