From 38dd85daab8e8342ec608d24cf81254c0dfde95c Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 20 Nov 2016 19:39:18 +0100 Subject: Adding notifications column --- .../components/containers/account_container.jsx | 30 ++++++++++++++++++++++ .../javascripts/components/containers/mastodon.jsx | 11 ++++++++ 2 files changed, 41 insertions(+) create mode 100644 app/assets/javascripts/components/containers/account_container.jsx (limited to 'app/assets/javascripts/components/containers') diff --git a/app/assets/javascripts/components/containers/account_container.jsx b/app/assets/javascripts/components/containers/account_container.jsx new file mode 100644 index 000000000..1f49f9819 --- /dev/null +++ b/app/assets/javascripts/components/containers/account_container.jsx @@ -0,0 +1,30 @@ +import { connect } from 'react-redux'; +import { makeGetAccount } from '../selectors'; +import Account from '../components/account'; +import { + followAccount, + unfollowAccount +} from '../actions/accounts'; + +const makeMapStateToProps = () => { + const getAccount = makeGetAccount(); + + const mapStateToProps = (state, props) => ({ + account: getAccount(state, props.id), + me: state.getIn(['meta', 'me']) + }); + + return mapStateToProps; +}; + +const mapDispatchToProps = (dispatch) => ({ + onFollow (account) { + if (account.getIn(['relationship', 'following'])) { + dispatch(unfollowAccount(account.get('id'))); + } else { + dispatch(followAccount(account.get('id'))); + } + } +}); + +export default connect(makeMapStateToProps, mapDispatchToProps)(Account); diff --git a/app/assets/javascripts/components/containers/mastodon.jsx b/app/assets/javascripts/components/containers/mastodon.jsx index b2c978ee8..cf77c169d 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'; @@ -75,11 +77,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))); } } }); } + + // Desktop notifications + if (Notification.permission === 'default') { + Notification.requestPermission(); + } }, componentWillUnmount () { @@ -103,6 +112,8 @@ const Mastodon = React.createClass({ + + -- cgit