about summary refs log tree commit diff
path: root/app/javascript/mastodon/features/notifications/containers/notification_container.js
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-01-27 17:54:54 +0100
committerEugen Rochko <eugen@zeonfederated.com>2019-01-27 17:54:54 +0100
commitec5bd8b8bbe5a7500680eeab40ce36f28373d0ba (patch)
tree3d12985a7c99466d4649e9a8e14bb0f6c21296ba /app/javascript/mastodon/features/notifications/containers/notification_container.js
parente2a5be6e9a070792fa72711c812f75bc61990052 (diff)
Implement missing hotkeys for notifications (#9927)
Diffstat (limited to 'app/javascript/mastodon/features/notifications/containers/notification_container.js')
-rw-r--r--app/javascript/mastodon/features/notifications/containers/notification_container.js57
1 files changed, 53 insertions, 4 deletions
diff --git a/app/javascript/mastodon/features/notifications/containers/notification_container.js b/app/javascript/mastodon/features/notifications/containers/notification_container.js
index 921aa460f..78576c760 100644
--- a/app/javascript/mastodon/features/notifications/containers/notification_container.js
+++ b/app/javascript/mastodon/features/notifications/containers/notification_container.js
@@ -1,14 +1,31 @@
 import { connect } from 'react-redux';
-import { makeGetNotification } from '../../../selectors';
+import { makeGetNotification, makeGetStatus } from '../../../selectors';
 import Notification from '../components/notification';
+import { openModal } from '../../../actions/modal';
 import { mentionCompose } from '../../../actions/compose';
+import {
+  reblog,
+  favourite,
+  unreblog,
+  unfavourite,
+} from '../../../actions/interactions';
+import {
+  hideStatus,
+  revealStatus,
+} from '../../../actions/statuses';
+import { boostModal } from '../../../initial_state';
 
 const makeMapStateToProps = () => {
   const getNotification = makeGetNotification();
+  const getStatus = makeGetStatus();
 
-  const mapStateToProps = (state, props) => ({
-    notification: getNotification(state, props.notification, props.accountId),
-  });
+  const mapStateToProps = (state, props) => {
+    const notification = getNotification(state, props.notification, props.accountId);
+    return {
+      notification: notification,
+      status: notification.get('status') ? getStatus(state, { id: notification.get('status') }) : null,
+    };
+  };
 
   return mapStateToProps;
 };
@@ -17,6 +34,38 @@ const mapDispatchToProps = dispatch => ({
   onMention: (account, router) => {
     dispatch(mentionCompose(account, router));
   },
+
+  onModalReblog (status) {
+    dispatch(reblog(status));
+  },
+
+  onReblog (status, e) {
+    if (status.get('reblogged')) {
+      dispatch(unreblog(status));
+    } else {
+      if (e.shiftKey || !boostModal) {
+        this.onModalReblog(status);
+      } else {
+        dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog }));
+      }
+    }
+  },
+
+  onFavourite (status) {
+    if (status.get('favourited')) {
+      dispatch(unfavourite(status));
+    } else {
+      dispatch(favourite(status));
+    }
+  },
+
+  onToggleHidden (status) {
+    if (status.get('hidden')) {
+      dispatch(revealStatus(status.get('id')));
+    } else {
+      dispatch(hideStatus(status.get('id')));
+    }
+  },
 });
 
 export default connect(makeMapStateToProps, mapDispatchToProps)(Notification);