@@ -253,5 +254,6 @@ PostInfo.propTypes = {
handleCommentClick: React.PropTypes.func.isRequired,
sameUser: React.PropTypes.bool.isRequired,
currentUser: React.PropTypes.object.isRequired,
- compactDisplay: React.PropTypes.bool
+ compactDisplay: React.PropTypes.bool,
+ useMilitaryTime: React.PropTypes.bool.isRequired
};
diff --git a/webapp/components/post_view/components/post_list.jsx b/webapp/components/post_view/components/post_list.jsx
index c23f785d9c..288a2d5e01 100644
--- a/webapp/components/post_view/components/post_list.jsx
+++ b/webapp/components/post_view/components/post_list.jsx
@@ -264,6 +264,7 @@ export default class PostList extends React.Component {
commentCount={commentCount}
compactDisplay={this.props.compactDisplay}
previewCollapsed={this.props.previewsCollapsed}
+ useMilitaryTime={this.props.useMilitaryTime}
/>
);
@@ -525,5 +526,6 @@ PostList.propTypes = {
displayPostsInCenter: React.PropTypes.bool,
compactDisplay: React.PropTypes.bool,
previewsCollapsed: React.PropTypes.string,
+ useMilitaryTime: React.PropTypes.bool.isRequired,
isFocusPost: React.PropTypes.bool
};
diff --git a/webapp/components/time_since.jsx b/webapp/components/post_view/components/post_time.jsx
similarity index 64%
rename from webapp/components/time_since.jsx
rename to webapp/components/post_view/components/post_time.jsx
index 2fbf73e31a..369a429a97 100644
--- a/webapp/components/time_since.jsx
+++ b/webapp/components/post_view/components/post_time.jsx
@@ -1,42 +1,52 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
-import Constants from 'utils/constants.jsx';
-import * as Utils from 'utils/utils.jsx';
-
import React from 'react';
+
+import Constants from 'utils/constants.jsx';
import PureRenderMixin from 'react-addons-pure-render-mixin';
-export default class TimeSince extends React.Component {
+import {FormattedTime} from 'react-intl';
+
+export default class PostTime extends React.Component {
constructor(props) {
super(props);
this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
}
+
componentDidMount() {
this.intervalId = setInterval(() => {
this.forceUpdate();
}, Constants.TIME_SINCE_UPDATE_INTERVAL);
}
+
componentWillUnmount() {
clearInterval(this.intervalId);
}
+
render() {
return (
);
}
}
-TimeSince.defaultProps = {
+PostTime.defaultProps = {
eventTime: 0,
sameUser: false
};
-TimeSince.propTypes = {
+PostTime.propTypes = {
eventTime: React.PropTypes.number.isRequired,
sameUser: React.PropTypes.bool,
- compactDisplay: React.PropTypes.bool
+ compactDisplay: React.PropTypes.bool,
+ useMilitaryTime: React.PropTypes.bool.isRequired
};
diff --git a/webapp/components/post_view/post_view_controller.jsx b/webapp/components/post_view/post_view_controller.jsx
index e5a14af36d..6d724f6591 100644
--- a/webapp/components/post_view/post_view_controller.jsx
+++ b/webapp/components/post_view/post_view_controller.jsx
@@ -52,7 +52,8 @@ export default class PostViewController extends React.Component {
displayNameType: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, 'name_format', 'false'),
displayPostsInCenter: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.CHANNEL_DISPLAY_MODE, Preferences.CHANNEL_DISPLAY_MODE_DEFAULT) === Preferences.CHANNEL_DISPLAY_MODE_CENTERED,
compactDisplay: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.MESSAGE_DISPLAY, Preferences.MESSAGE_DISPLAY_DEFAULT) === Preferences.MESSAGE_DISPLAY_COMPACT,
- previewsCollapsed: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.COLLAPSE_DISPLAY, 'false')
+ previewsCollapsed: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.COLLAPSE_DISPLAY, 'false'),
+ useMilitaryTime: PreferenceStore.getBool(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.USE_MILITARY_TIME, false)
};
}
@@ -80,7 +81,8 @@ export default class PostViewController extends React.Component {
displayNameType: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, 'name_format', 'false'),
displayPostsInCenter: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.CHANNEL_DISPLAY_MODE, Preferences.CHANNEL_DISPLAY_MODE_DEFAULT) === Preferences.CHANNEL_DISPLAY_MODE_CENTERED,
compactDisplay: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.MESSAGE_DISPLAY, Preferences.MESSAGE_DISPLAY_DEFAULT) === Preferences.MESSAGE_DISPLAY_COMPACT,
- previewsCollapsed: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.COLLAPSE_DISPLAY, 'false') + previewSuffix
+ previewsCollapsed: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.COLLAPSE_DISPLAY, 'false') + previewSuffix,
+ useMilitaryTime: PreferenceStore.getBool(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.USE_MILITARY_TIME, false)
});
}
@@ -142,6 +144,7 @@ export default class PostViewController extends React.Component {
displayPostsInCenter: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.CHANNEL_DISPLAY_MODE, Preferences.CHANNEL_DISPLAY_MODE_DEFAULT) === Preferences.CHANNEL_DISPLAY_MODE_CENTERED,
compactDisplay: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.MESSAGE_DISPLAY, Preferences.MESSAGE_DISPLAY_DEFAULT) === Preferences.MESSAGE_DISPLAY_COMPACT,
previewsCollapsed: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.COLLAPSE_DISPLAY, 'false'),
+ useMilitaryTime: PreferenceStore.getBool(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.USE_MILITARY_TIME, false),
scrollType: ScrollTypes.NEW_MESSAGE
});
}
@@ -197,6 +200,10 @@ export default class PostViewController extends React.Component {
return true;
}
+ if (nextState.useMilitaryTime !== this.state.useMilitaryTime) {
+ return true;
+ }
+
if (nextState.lastViewed !== this.state.lastViewed) {
return true;
}
@@ -256,6 +263,7 @@ export default class PostViewController extends React.Component {
displayPostsInCenter={this.state.displayPostsInCenter}
compactDisplay={this.state.compactDisplay}
previewsCollapsed={this.state.previewsCollapsed}
+ useMilitaryTime={this.state.useMilitaryTime}
lastViewed={this.state.lastViewed}
/>
);
diff --git a/webapp/components/rhs_comment.jsx b/webapp/components/rhs_comment.jsx
index 0ef2348d0d..7b754c04f2 100644
--- a/webapp/components/rhs_comment.jsx
+++ b/webapp/components/rhs_comment.jsx
@@ -38,6 +38,11 @@ export default class RhsComment extends React.Component {
if (nextProps.compactDisplay !== this.props.compactDisplay) {
return true;
}
+
+ if (nextProps.useMilitaryTime !== this.props.useMilitaryTime) {
+ return true;
+ }
+
if (!Utils.areObjectsEqual(nextProps.post, this.props.post)) {
return true;
}
@@ -231,7 +236,7 @@ export default class RhsComment extends React.Component {
day='numeric'
month='long'
year='numeric'
- hour12={!Utils.isMilitaryTime()}
+ hour12={!this.props.useMilitaryTime}
hour='2-digit'
minute='2-digit'
/>
@@ -259,5 +264,6 @@ RhsComment.propTypes = {
post: React.PropTypes.object,
user: React.PropTypes.object.isRequired,
currentUser: React.PropTypes.object.isRequired,
- compactDisplay: React.PropTypes.bool
+ compactDisplay: React.PropTypes.bool,
+ useMilitaryTime: React.PropTypes.bool.isRequired
};
diff --git a/webapp/components/rhs_root_post.jsx b/webapp/components/rhs_root_post.jsx
index ff64520354..b70b284d99 100644
--- a/webapp/components/rhs_root_post.jsx
+++ b/webapp/components/rhs_root_post.jsx
@@ -35,6 +35,11 @@ export default class RhsRootPost extends React.Component {
if (nextProps.compactDisplay !== this.props.compactDisplay) {
return true;
}
+
+ if (nextProps.useMilitaryTime !== this.props.useMilitaryTime) {
+ return true;
+ }
+
if (!Utils.areObjectsEqual(nextProps.post, this.props.post)) {
return true;
}
@@ -255,7 +260,7 @@ export default class RhsRootPost extends React.Component {
day='numeric'
month='long'
year='numeric'
- hour12={!Utils.isMilitaryTime()}
+ hour12={!this.props.useMilitaryTime}
hour='2-digit'
minute='2-digit'
/>
@@ -289,5 +294,6 @@ RhsRootPost.propTypes = {
user: React.PropTypes.object.isRequired,
currentUser: React.PropTypes.object.isRequired,
commentCount: React.PropTypes.number,
- compactDisplay: React.PropTypes.bool
+ compactDisplay: React.PropTypes.bool,
+ useMilitaryTime: React.PropTypes.bool.isRequired
};
diff --git a/webapp/components/rhs_thread.jsx b/webapp/components/rhs_thread.jsx
index b001da80a7..914a697a50 100644
--- a/webapp/components/rhs_thread.jsx
+++ b/webapp/components/rhs_thread.jsx
@@ -112,6 +112,10 @@ export default class RhsThread extends React.Component {
return true;
}
+ if (nextProps.useMilitaryTime !== this.props.useMilitaryTime) {
+ return true;
+ }
+
if (!Utils.areObjectsEqual(nextState.profiles, this.state.profiles)) {
return true;
}
@@ -243,6 +247,7 @@ export default class RhsThread extends React.Component {
user={profile}
currentUser={this.props.currentUser}
compactDisplay={this.state.compactDisplay}
+ useMilitaryTime={this.props.useMilitaryTime}
/>
{postsArray.map((comPost) => {
@@ -260,6 +265,7 @@ export default class RhsThread extends React.Component {
user={p}
currentUser={this.props.currentUser}
compactDisplay={this.state.compactDisplay}
+ useMilitaryTime={this.props.useMilitaryTime}
/>
);
})}
@@ -286,5 +292,6 @@ RhsThread.defaultProps = {
RhsThread.propTypes = {
fromSearch: React.PropTypes.string,
isMentionSearch: React.PropTypes.bool,
- currentUser: React.PropTypes.object.isRequired
+ currentUser: React.PropTypes.object.isRequired,
+ useMilitaryTime: React.PropTypes.bool.isRequired
};
diff --git a/webapp/components/search_results.jsx b/webapp/components/search_results.jsx
index 4daa94d8ae..213a677e76 100644
--- a/webapp/components/search_results.jsx
+++ b/webapp/components/search_results.jsx
@@ -170,6 +170,7 @@ export default class SearchResults extends React.Component {
user={profile}
term={searchTerm}
isMentionSearch={this.props.isMentionSearch}
+ useMilitaryTime={this.props.useMilitaryTime}
/>
);
}, this);
@@ -193,5 +194,6 @@ export default class SearchResults extends React.Component {
}
SearchResults.propTypes = {
- isMentionSearch: React.PropTypes.bool
+ isMentionSearch: React.PropTypes.bool,
+ useMilitaryTime: React.PropTypes.bool.isRequired
};
diff --git a/webapp/components/search_results_item.jsx b/webapp/components/search_results_item.jsx
index d8e4711101..3fff4ea33d 100644
--- a/webapp/components/search_results_item.jsx
+++ b/webapp/components/search_results_item.jsx
@@ -113,7 +113,7 @@ export default class SearchResultsItem extends React.Component {