From a6e4f754fc4dd025be55c6d6362e8c5e98a299d9 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 17 Nov 2016 16:34:36 +0100 Subject: [PATCH] Add an Intl polyfill --- app/assets/javascripts/components.js | 5 +++++ .../components/components/relative_timestamp.jsx | 15 +++------------ .../components/components/status_list.jsx | 16 +--------------- .../components/containers/mastodon.jsx | 5 ++++- .../status/components/detailed_status.jsx | 2 +- package.json | 1 + yarn.lock | 4 ++++ 7 files changed, 19 insertions(+), 29 deletions(-) diff --git a/app/assets/javascripts/components.js b/app/assets/javascripts/components.js index 0ac74c70c..1604d5198 100644 --- a/app/assets/javascripts/components.js +++ b/app/assets/javascripts/components.js @@ -5,6 +5,11 @@ window.React = require('react'); window.ReactDOM = require('react-dom'); window.Perf = require('react-addons-perf'); +if (!window.Intl) { + require('intl'); + require('intl/locale-data/jsonp/en.js'); +} + //= require_tree ./components window.Mastodon = require('./components/containers/mastodon'); diff --git a/app/assets/javascripts/components/components/relative_timestamp.jsx b/app/assets/javascripts/components/components/relative_timestamp.jsx index 96f99cca8..3a5b88523 100644 --- a/app/assets/javascripts/components/components/relative_timestamp.jsx +++ b/app/assets/javascripts/components/components/relative_timestamp.jsx @@ -4,21 +4,12 @@ import { FormattedRelative } from 'react-intl'; -const RelativeTimestamp = ({ timestamp, now }) => { - const diff = (new Date(now)) - (new Date(timestamp)); - - if (diff < 0) { - return - } else if (diff > (3600 * 24 * 7 * 1000)) { - return - } else { - return - } +const RelativeTimestamp = ({ timestamp }) => { + return ; }; RelativeTimestamp.propTypes = { - timestamp: React.PropTypes.string.isRequired, - now: React.PropTypes.any + timestamp: React.PropTypes.string.isRequired }; export default RelativeTimestamp; diff --git a/app/assets/javascripts/components/components/status_list.jsx b/app/assets/javascripts/components/components/status_list.jsx index 91fb45cf5..f989ef895 100644 --- a/app/assets/javascripts/components/components/status_list.jsx +++ b/app/assets/javascripts/components/components/status_list.jsx @@ -18,22 +18,8 @@ const StatusList = React.createClass({ }; }, - getInitialState () { - return { - now: (new Date()).toString() - }; - }, - mixins: [PureRenderMixin], - componentDidMount () { - this._interval = setInterval(() => this.setState({ now: (new Date()).toString() }), 60000); - }, - - componentWillUnmount () { - clearInterval(this._interval); - }, - handleScroll (e) { const { scrollTop, scrollHeight, clientHeight } = e.target; @@ -61,7 +47,7 @@ const StatusList = React.createClass({
{statusIds.map((statusId) => { - return ; + return ; })}
diff --git a/app/assets/javascripts/components/containers/mastodon.jsx b/app/assets/javascripts/components/containers/mastodon.jsx index dbc32076b..a12b19746 100644 --- a/app/assets/javascripts/components/containers/mastodon.jsx +++ b/app/assets/javascripts/components/containers/mastodon.jsx @@ -32,7 +32,8 @@ import Following from '../features/following'; import Reblogs from '../features/reblogs'; import Favourites from '../features/favourites'; import HashtagTimeline from '../features/hashtag_timeline'; -import { IntlProvider } from 'react-intl'; +import { IntlProvider, addLocaleData } from 'react-intl'; +import en from 'react-intl/locale-data/en'; const store = configureStore(); @@ -40,6 +41,8 @@ const browserHistory = useRouterHistory(createBrowserHistory)({ basename: '/web' }); +addLocaleData([...en]); + const Mastodon = React.createClass({ propTypes: { diff --git a/app/assets/javascripts/components/features/status/components/detailed_status.jsx b/app/assets/javascripts/components/features/status/components/detailed_status.jsx index 8efdf195f..76ddafb3b 100644 --- a/app/assets/javascripts/components/features/status/components/detailed_status.jsx +++ b/app/assets/javascripts/components/features/status/components/detailed_status.jsx @@ -54,7 +54,7 @@ const DetailedStatus = React.createClass({ {media}
- · · + · ·
); diff --git a/package.json b/package.json index 6264b62f5..2b34153d4 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "babel-plugin-transform-decorators-legacy": "^1.3.4", "emojione": "^2.2.6", "http-link-header": "^0.5.0", + "intl": "^1.2.5", "react-autosuggest": "^7.0.1", "react-decoration": "^1.4.0", "react-intl": "^2.1.5", diff --git a/yarn.lock b/yarn.lock index fac059911..580c0e1a6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2497,6 +2497,10 @@ interpret@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.1.tgz#d579fb7f693b858004947af39fa0db49f795602c" +intl: + version "1.2.5" + resolved "https://registry.yarnpkg.com/intl/-/intl-1.2.5.tgz#82244a2190c4e419f8371f5aa34daa3420e2abde" + intl-format-cache@^2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/intl-format-cache/-/intl-format-cache-2.0.5.tgz#b484cefcb9353f374f25de389a3ceea1af18d7c9"