summaryrefslogtreecommitdiffstats
path: root/webapp/components/posts_view.jsx
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-04-21 09:56:11 -0400
committerHarrison Healey <harrisonmhealey@gmail.com>2016-04-21 09:56:11 -0400
commit899ee09224799cb8b1dffaea781a18594616b50e (patch)
treee6b57b8458abd864ac92dd0074d73e9f7a5284cf /webapp/components/posts_view.jsx
parentcf1f3ba322ce64ca383ce1a5f0ca3d9bacb180ea (diff)
downloadchat-899ee09224799cb8b1dffaea781a18594616b50e.tar.gz
chat-899ee09224799cb8b1dffaea781a18594616b50e.tar.bz2
chat-899ee09224799cb8b1dffaea781a18594616b50e.zip
Adding option to display channels sanely (#2761)
Diffstat (limited to 'webapp/components/posts_view.jsx')
-rw-r--r--webapp/components/posts_view.jsx11
1 files changed, 10 insertions, 1 deletions
diff --git a/webapp/components/posts_view.jsx b/webapp/components/posts_view.jsx
index d072203a0..560a46e9a 100644
--- a/webapp/components/posts_view.jsx
+++ b/webapp/components/posts_view.jsx
@@ -40,6 +40,7 @@ export default class PostsView extends React.Component {
this.state = {
displayNameType: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, 'name_format', 'false'),
+ centerPosts: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.CHANNEL_DISPLAY_MODE, Preferences.CHANNEL_DISPLAY_MODE_DEFAULT) === Preferences.CHANNEL_DISPLAY_MODE_CENTERED,
isScrolling: false,
topPostId: null,
showUnreadMessageAlert: false
@@ -61,7 +62,10 @@ export default class PostsView extends React.Component {
return 5;
}
updateState() {
- this.setState({displayNameType: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, 'name_format', 'false')});
+ this.setState({
+ displayNameType: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, 'name_format', 'false'),
+ centerPosts: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.CHANNEL_DISPLAY_MODE, Preferences.CHANNEL_DISPLAY_MODE_DEFAULT) === Preferences.CHANNEL_DISPLAY_MODE_CENTERED
+ });
}
isAtBottom() {
// consider the view to be at the bottom if it's within this many pixels of the bottom
@@ -247,6 +251,7 @@ export default class PostsView extends React.Component {
displayNameType={this.state.displayNameType}
user={profile}
currentUser={this.props.currentUser}
+ center={this.state.centerPosts}
/>
);
@@ -373,6 +378,7 @@ export default class PostsView extends React.Component {
this.updateScrolling();
}
window.addEventListener('resize', this.handleResize);
+ PreferenceStore.addChangeListener(this.updateState);
$('body').addClass('app__body');
}
componentWillUnmount() {
@@ -429,6 +435,9 @@ export default class PostsView extends React.Component {
if (this.state.isScrolling !== nextState.isScrolling) {
return true;
}
+ if (this.state.centerPosts !== nextState.centerPosts) {
+ return true;
+ }
if (!Utils.areObjectsEqual(this.props.profiles, nextProps.profiles)) {
return true;
}