summaryrefslogtreecommitdiffstats
path: root/webapp/stores
diff options
context:
space:
mode:
authorJonathan <jonfritz@gmail.com>2017-08-02 15:38:54 -0400
committerGitHub <noreply@github.com>2017-08-02 15:38:54 -0400
commit76bfd279b34f960149dba15424593dfd5fbfb956 (patch)
tree2aef72326ba55d0a3c162073a279286f3c0636c6 /webapp/stores
parentb796960a2514a2eb5ae900436806f343dbddf50f (diff)
downloadchat-76bfd279b34f960149dba15424593dfd5fbfb956.tar.gz
chat-76bfd279b34f960149dba15424593dfd5fbfb956.tar.bz2
chat-76bfd279b34f960149dba15424593dfd5fbfb956.zip
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)
Diffstat (limited to 'webapp/stores')
-rw-r--r--webapp/stores/search_store.jsx16
1 files changed, 16 insertions, 0 deletions
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;