From 27aaa6dad37d77bc8a2660b27980c4ebd5957250 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Mon, 12 Dec 2016 19:52:19 -0500 Subject: Fix JS errors with RHS and flagged posts (#4771) --- .../components/post_view/components/post_list.jsx | 2 +- webapp/stores/suggestion_store.jsx | 28 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'webapp') diff --git a/webapp/components/post_view/components/post_list.jsx b/webapp/components/post_view/components/post_list.jsx index b3b83dfd6..05e2ff618 100644 --- a/webapp/components/post_view/components/post_list.jsx +++ b/webapp/components/post_view/components/post_list.jsx @@ -450,7 +450,7 @@ export default class PostList extends React.Component { } } else if (this.refs.postlist.scrollHeight !== this.prevScrollHeight) { window.requestAnimationFrame(() => { - if (this.jumpToPostNode) { + if (this.jumpToPostNode && this.refs.postlist) { this.refs.postlist.scrollTop += (this.jumpToPostNode.offsetTop - this.prevOffsetTop); } }); diff --git a/webapp/stores/suggestion_store.jsx b/webapp/stores/suggestion_store.jsx index 83c0c2a17..2dbef0490 100644 --- a/webapp/stores/suggestion_store.jsx +++ b/webapp/stores/suggestion_store.jsx @@ -87,7 +87,7 @@ class SuggestionStore extends EventEmitter { } clearSuggestions(id) { - const suggestion = this.suggestions.get(id); + const suggestion = this.getSuggestions(id); suggestion.matchedPretext = []; suggestion.terms = []; @@ -96,23 +96,23 @@ class SuggestionStore extends EventEmitter { } clearSelection(id) { - const suggestion = this.suggestions.get(id); + const suggestion = this.getSuggestions(id); suggestion.selection = ''; } hasSuggestions(id) { - return this.suggestions.get(id).terms.length > 0; + return this.getSuggestions(id).terms.length > 0; } setPretext(id, pretext) { - const suggestion = this.suggestions.get(id); + const suggestion = this.getSuggestions(id); suggestion.pretext = pretext; } addSuggestion(id, term, item, component, matchedPretext) { - const suggestion = this.suggestions.get(id); + const suggestion = this.getSuggestions(id); suggestion.terms.push(term); suggestion.items.push(item); @@ -126,7 +126,7 @@ class SuggestionStore extends EventEmitter { return; } - const suggestion = this.suggestions.get(id); + const suggestion = this.getSuggestions(id); suggestion.terms.push(...terms); suggestion.items.push(...items); @@ -139,7 +139,7 @@ class SuggestionStore extends EventEmitter { // make sure that if suggestions exist, then one of them is selected. return true if the selection changes. ensureSelectionExists(id) { - const suggestion = this.suggestions.get(id); + const suggestion = this.getSuggestions(id); if (suggestion.terms.length > 0) { // if the current selection is no longer in the map, select the first term in the list @@ -158,11 +158,11 @@ class SuggestionStore extends EventEmitter { } getPretext(id) { - return this.suggestions.get(id).pretext; + return this.getSuggestions(id).pretext; } getSelectedMatchedPretext(id) { - const suggestion = this.suggestions.get(id); + const suggestion = this.getSuggestions(id); for (let i = 0; i < suggestion.terms.length; i++) { if (suggestion.terms[i] === suggestion.selection) { @@ -174,23 +174,23 @@ class SuggestionStore extends EventEmitter { } getItems(id) { - return this.suggestions.get(id).items; + return this.getSuggestions(id).items; } getTerms(id) { - return this.suggestions.get(id).terms; + return this.getSuggestions(id).terms; } getComponents(id) { - return this.suggestions.get(id).components; + return this.getSuggestions(id).components; } getSuggestions(id) { - return this.suggestions.get(id); + return this.suggestions.get(id) || {}; } getSelection(id) { - return this.suggestions.get(id).selection; + return this.getSuggestions(id).selection; } selectNext(id) { -- cgit v1.2.3-1-g7c22