diff options
author | Pepijn <pepijnfens@gmail.com> | 2016-10-11 15:07:38 +0200 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2016-10-11 09:07:38 -0400 |
commit | 944bb1ba615ef5205f33191a4542f36002a4db23 (patch) | |
tree | 8a95e4081e050298491c46520fa45eaa70ee5ec7 /webapp/actions/global_actions.jsx | |
parent | 6e9e41ebb500e0d343374421719f24c515958808 (diff) | |
download | chat-944bb1ba615ef5205f33191a4542f36002a4db23.tar.gz chat-944bb1ba615ef5205f33191a4542f36002a4db23.tar.bz2 chat-944bb1ba615ef5205f33191a4542f36002a4db23.zip |
First commit for toggling mentions using shortcut and button (#4169)
Also did some refactoring and moved code to actions
Fixed coding style errors
Diffstat (limited to 'webapp/actions/global_actions.jsx')
-rw-r--r-- | webapp/actions/global_actions.jsx | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/webapp/actions/global_actions.jsx b/webapp/actions/global_actions.jsx index 81c06fe93..941aa34f4 100644 --- a/webapp/actions/global_actions.jsx +++ b/webapp/actions/global_actions.jsx @@ -487,3 +487,49 @@ export function emitJoinChannelEvent(channel, success, failure) { failure ); } + +export function emitSearchMentionsEvent(user) { + let terms = ''; + if (user.notify_props && user.notify_props.mention_keys) { + const termKeys = UserStore.getMentionKeys(user.id); + + if (termKeys.indexOf('@channel') !== -1) { + termKeys[termKeys.indexOf('@channel')] = ''; + } + + if (termKeys.indexOf('@all') !== -1) { + termKeys[termKeys.indexOf('@all')] = ''; + } + + terms = termKeys.join(' '); + } + + AppDispatcher.handleServerAction({ + type: ActionTypes.RECEIVED_SEARCH_TERM, + term: terms, + do_search: true, + is_mention_search: true + }); +} + +export function toggleSideBarAction(visible) { + if (!visible) { + //Array of actions resolving in the closing of the sidebar + AppDispatcher.handleServerAction({ + type: ActionTypes.RECEIVED_SEARCH, + results: null + }); + + AppDispatcher.handleServerAction({ + type: ActionTypes.RECEIVED_SEARCH_TERM, + term: null, + do_search: false, + is_mention_search: false + }); + + AppDispatcher.handleServerAction({ + type: ActionTypes.RECEIVED_POST_SELECTED, + postId: null + }); + } +} |