diff options
author | Joram Wilander <jwawilander@gmail.com> | 2015-12-01 11:34:53 -0500 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2015-12-01 11:34:53 -0500 |
commit | 2b2ee62a1df0504fff3f3e0e59966db1cd297531 (patch) | |
tree | 03f9a86f5c679a643a6a064e75c4046fde972744 /web/react/components/posts_view.jsx | |
parent | 272ed29a85b617bfe771917e1f5cbe27c740946f (diff) | |
parent | 478af4bf7501404ab53dd9afe981b26721682834 (diff) | |
download | chat-2b2ee62a1df0504fff3f3e0e59966db1cd297531.tar.gz chat-2b2ee62a1df0504fff3f3e0e59966db1cd297531.tar.bz2 chat-2b2ee62a1df0504fff3f3e0e59966db1cd297531.zip |
Merge pull request #1512 from rgarmsen2295/plt-995b
PLT-995 Applies name display preference setting in more places
Diffstat (limited to 'web/react/components/posts_view.jsx')
-rw-r--r-- | web/react/components/posts_view.jsx | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/web/react/components/posts_view.jsx b/web/react/components/posts_view.jsx index 6b61d465c..242b26b91 100644 --- a/web/react/components/posts_view.jsx +++ b/web/react/components/posts_view.jsx @@ -2,15 +2,18 @@ // See License.txt for license information. import UserStore from '../stores/user_store.jsx'; +import PreferenceStore from '../stores/preference_store.jsx'; import * as EventHelpers from '../dispatcher/event_helpers.jsx'; import * as Utils from '../utils/utils.jsx'; import Post from './post.jsx'; import Constants from '../utils/constants.jsx'; +const Preferences = Constants.Preferences; export default class PostsView extends React.Component { constructor(props) { super(props); + this.updateState = this.updateState.bind(this); this.handleScroll = this.handleScroll.bind(this); this.isAtBottom = this.isAtBottom.bind(this); this.loadMorePostsTop = this.loadMorePostsTop.bind(this); @@ -22,6 +25,8 @@ export default class PostsView extends React.Component { this.jumpToPostNode = null; this.wasAtBottom = true; this.scrollHeight = 0; + + this.state = {displayNameType: PreferenceStore.getPreference(Preferences.CATEGORY_DISPLAY_SETTINGS, 'name_format', {value: 'false'}).value}; } static get SCROLL_TYPE_FREE() { return 1; @@ -38,6 +43,9 @@ export default class PostsView extends React.Component { static get SCROLL_TYPE_POST() { return 5; } + updateState() { + this.setState({displayNameType: PreferenceStore.getPreference(Preferences.CATEGORY_DISPLAY_SETTINGS, 'name_format', {value: 'false'}).value}); + } isAtBottom() { return ((this.refs.postlist.scrollHeight - this.refs.postlist.scrollTop) === this.refs.postlist.clientHeight); } @@ -166,6 +174,7 @@ export default class PostsView extends React.Component { isLastComment={isLastComment} shouldHighlight={shouldHighlight} onClick={() => EventHelpers.emitPostFocusEvent(post.id)} //eslint-disable-line no-loop-func + displayNameType={this.state.displayNameType} /> ); @@ -272,9 +281,11 @@ export default class PostsView extends React.Component { } window.addEventListener('resize', this.handleResize); $(this.refs.postlist).perfectScrollbar(); + PreferenceStore.addChangeListener(this.updateState); } componentWillUnmount() { window.removeEventListener('resize', this.handleResize); + PreferenceStore.removeChangeListener(this.updateState); } componentDidUpdate() { if (this.props.postList != null) { @@ -282,7 +293,7 @@ export default class PostsView extends React.Component { } $(this.refs.postlist).perfectScrollbar('update'); } - shouldComponentUpdate(nextProps) { + shouldComponentUpdate(nextProps, nextState) { if (this.props.isActive !== nextProps.isActive) { return true; } @@ -301,6 +312,9 @@ export default class PostsView extends React.Component { if (!Utils.areObjectsEqual(this.props.postList, nextProps.postList)) { return true; } + if (nextState.displayNameType !== this.state.displayNameType) { + return true; + } return false; } |