From f740698dbe06816921d2a20eea876c9ca7b515ed Mon Sep 17 00:00:00 2001 From: David Meza Date: Mon, 31 Jul 2017 07:24:13 -0500 Subject: 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. --- webapp/stores/search_store.jsx | 2 +- webapp/stores/suggestion_store.jsx | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'webapp/stores') 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; } } } -- cgit v1.2.3-1-g7c22