about summary refs log tree commit diff
path: root/app/javascript/mastodon/features/compose/containers/poll_button_container.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/javascript/mastodon/features/compose/containers/poll_button_container.js')
-rw-r--r--app/javascript/mastodon/features/compose/containers/poll_button_container.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/app/javascript/mastodon/features/compose/containers/poll_button_container.js b/app/javascript/mastodon/features/compose/containers/poll_button_container.js
new file mode 100644
index 000000000..8f1cb7c10
--- /dev/null
+++ b/app/javascript/mastodon/features/compose/containers/poll_button_container.js
@@ -0,0 +1,24 @@
+import { connect } from 'react-redux';
+import PollButton from '../components/poll_button';
+import { addPoll, removePoll } from '../../../actions/compose';
+
+const mapStateToProps = state => ({
+  unavailable: state.getIn(['compose', 'is_uploading']) || (state.getIn(['compose', 'media_attachments']).size > 0),
+  active: state.getIn(['compose', 'poll']) !== null,
+});
+
+const mapDispatchToProps = dispatch => ({
+
+  onClick () {
+    dispatch((_, getState) => {
+      if (getState().getIn(['compose', 'poll'])) {
+        dispatch(removePoll());
+      } else {
+        dispatch(addPoll());
+      }
+    });
+  },
+
+});
+
+export default connect(mapStateToProps, mapDispatchToProps)(PollButton);