summaryrefslogtreecommitdiffstats
path: root/webapp/stores
diff options
context:
space:
mode:
authorDavid Meza <dmeza@users.noreply.github.com>2017-07-31 07:24:13 -0500
committerJoram Wilander <jwawilander@gmail.com>2017-07-31 08:24:13 -0400
commitf740698dbe06816921d2a20eea876c9ca7b515ed (patch)
treedf5c9f4f076c6294da8246275a97133f59b5a82f /webapp/stores
parent22fa48f455f15be7a7528501431841a2c7d84c85 (diff)
downloadchat-f740698dbe06816921d2a20eea876c9ca7b515ed.tar.gz
chat-f740698dbe06816921d2a20eea876c9ca7b515ed.tar.bz2
chat-f740698dbe06816921d2a20eea876c9ca7b515ed.zip
PLT-6486 Add an `@username` button to the profile popover, that puts the username in the post when clicked (#6349)
* PLT-6486 Add an `@username` button to the profile popover, that puts the username in the post when clicked * PLT-6486 Display `@username` mention on the right text area on center or RHS. * Disable @mentions from profile popover on searches, mentions and pinned posts. Fix js errors. * Control undefined post in SearchStore that causes an exception.
Diffstat (limited to 'webapp/stores')
-rw-r--r--webapp/stores/search_store.jsx2
-rw-r--r--webapp/stores/suggestion_store.jsx18
2 files changed, 19 insertions, 1 deletions
diff --git a/webapp/stores/search_store.jsx b/webapp/stores/search_store.jsx
index 5dfea6867..d57c630cb 100644
--- a/webapp/stores/search_store.jsx
+++ b/webapp/stores/search_store.jsx
@@ -122,7 +122,7 @@ class SearchStoreClass extends EventEmitter {
updatePost(post) {
const results = this.getSearchResults();
- if (results == null) {
+ if (!post || results == null) {
return;
}
diff --git a/webapp/stores/suggestion_store.jsx b/webapp/stores/suggestion_store.jsx
index d1f5a64f6..902886ed7 100644
--- a/webapp/stores/suggestion_store.jsx
+++ b/webapp/stores/suggestion_store.jsx
@@ -10,6 +10,7 @@ const ActionTypes = Constants.ActionTypes;
const COMPLETE_WORD_EVENT = 'complete_word';
const PRETEXT_CHANGED_EVENT = 'pretext_changed';
const SUGGESTIONS_CHANGED_EVENT = 'suggestions_changed';
+const POPOVER_MENTION_KEY_CLICK_EVENT = 'popover_mention_key_click';
class SuggestionStore extends EventEmitter {
constructor() {
@@ -27,6 +28,10 @@ class SuggestionStore extends EventEmitter {
this.removeCompleteWordListener = this.removeCompleteWordListener.bind(this);
this.emitCompleteWord = this.emitCompleteWord.bind(this);
+ this.addPopoverMentionKeyClickListener = this.addPopoverMentionKeyClickListener.bind(this);
+ this.removePopoverMentionKeyClickListener = this.removePopoverMentionKeyClickListener.bind(this);
+ this.emitPopoverMentionKeyClick = this.emitPopoverMentionKeyClick.bind(this);
+
this.handleEventPayload = this.handleEventPayload.bind(this);
this.dispatchToken = AppDispatcher.register(this.handleEventPayload);
@@ -71,6 +76,16 @@ class SuggestionStore extends EventEmitter {
this.emit(COMPLETE_WORD_EVENT + id, term, matchedPretext);
}
+ addPopoverMentionKeyClickListener(id, callback) {
+ this.on(POPOVER_MENTION_KEY_CLICK_EVENT + id, callback);
+ }
+ removePopoverMentionKeyClickListener(id, callback) {
+ this.removeListener(POPOVER_MENTION_KEY_CLICK_EVENT + id, callback);
+ }
+ emitPopoverMentionKeyClick(isRHS, mentionKey) {
+ this.emit(POPOVER_MENTION_KEY_CLICK_EVENT + isRHS, mentionKey);
+ }
+
registerSuggestionBox(id) {
this.suggestions.set(id, {
pretext: '',
@@ -304,6 +319,9 @@ class SuggestionStore extends EventEmitter {
this.completeWord(id, other.term, other.matchedPretext);
}
break;
+ case ActionTypes.POPOVER_MENTION_KEY_CLICK:
+ this.emitPopoverMentionKeyClick(other.isRHS, other.mentionKey);
+ break;
}
}
}