diff options
Diffstat (limited to 'app/assets/javascripts/components/containers/mastodon.jsx')
-rw-r--r-- | app/assets/javascripts/components/containers/mastodon.jsx | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/app/assets/javascripts/components/containers/mastodon.jsx b/app/assets/javascripts/components/containers/mastodon.jsx index b2c978ee8..3528ef81c 100644 --- a/app/assets/javascripts/components/containers/mastodon.jsx +++ b/app/assets/javascripts/components/containers/mastodon.jsx @@ -6,6 +6,7 @@ import { deleteFromTimelines, refreshTimeline } from '../actions/timelines'; +import { updateNotifications } from '../actions/notifications'; import { setAccessToken } from '../actions/meta'; import { setAccountSelf } from '../actions/accounts'; import PureRenderMixin from 'react-addons-pure-render-mixin'; @@ -32,6 +33,7 @@ import Following from '../features/following'; import Reblogs from '../features/reblogs'; import Favourites from '../features/favourites'; import HashtagTimeline from '../features/hashtag_timeline'; +import Notifications from '../features/notifications'; import { IntlProvider, addLocaleData } from 'react-intl'; import en from 'react-intl/locale-data/en'; import de from 'react-intl/locale-data/de'; @@ -58,8 +60,10 @@ const Mastodon = React.createClass({ mixins: [PureRenderMixin], componentWillMount() { - store.dispatch(setAccessToken(this.props.token)); - store.dispatch(setAccountSelf(JSON.parse(this.props.account))); + const { token, account, locale } = this.props; + + store.dispatch(setAccessToken(token)); + store.dispatch(setAccountSelf(JSON.parse(account))); if (typeof App !== 'undefined') { this.subscription = App.cable.subscriptions.create('TimelineChannel', { @@ -75,11 +79,18 @@ const Mastodon = React.createClass({ return store.dispatch(refreshTimeline('home', true)); case 'block': return store.dispatch(refreshTimeline('mentions', true)); + case 'notification': + return store.dispatch(updateNotifications(JSON.parse(data.message), getMessagesForLocale(locale), locale)); } } }); } + + // Desktop notifications + if (typeof window.Notification !== 'undefined' && Notification.permission === 'default') { + Notification.requestPermission(); + } }, componentWillUnmount () { @@ -103,6 +114,8 @@ const Mastodon = React.createClass({ <Route path='timelines/public' component={PublicTimeline} /> <Route path='timelines/tag/:id' component={HashtagTimeline} /> + <Route path='notifications' component={Notifications} /> + <Route path='statuses/new' component={Compose} /> <Route path='statuses/:statusId' component={Status} /> <Route path='statuses/:statusId/reblogs' component={Reblogs} /> |