From 974d712fbe5775903a4fec5ddc44b4069e68c925 Mon Sep 17 00:00:00 2001
From: Eugen Rochko <eugen@zeonfederated.com>
Date: Wed, 22 Feb 2017 15:43:07 +0100
Subject: Improve performance of compose form

---
 .../containers/unlisted_toggle_container.jsx       | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 app/assets/javascripts/components/features/compose/containers/unlisted_toggle_container.jsx

(limited to 'app/assets/javascripts/components/features/compose/containers/unlisted_toggle_container.jsx')

diff --git a/app/assets/javascripts/components/features/compose/containers/unlisted_toggle_container.jsx b/app/assets/javascripts/components/features/compose/containers/unlisted_toggle_container.jsx
new file mode 100644
index 000000000..ceac903d9
--- /dev/null
+++ b/app/assets/javascripts/components/features/compose/containers/unlisted_toggle_container.jsx
@@ -0,0 +1,31 @@
+import { connect } from 'react-redux';
+import UnlistedToggle from '../components/unlisted_toggle';
+import { makeGetStatus } from '../../../selectors';
+import { changeComposeListability } from '../../../actions/compose';
+
+const makeMapStateToProps = () => {
+  const getStatus = makeGetStatus();
+
+  const mapStateToProps = state => {
+    const status = getStatus(state, state.getIn(['compose', 'in_reply_to']));
+    const me     = state.getIn(['compose', 'me']);
+
+    return {
+      isPrivate: state.getIn(['compose', 'private']),
+      isUnlisted: state.getIn(['compose', 'unlisted']),
+      isReplyToOther: status ? status.getIn(['account', 'id']) !== me : false
+    };
+  };
+
+  return mapStateToProps;
+};
+
+const mapDispatchToProps = dispatch => ({
+
+  onChangeListability (e) {
+    dispatch(changeComposeListability(e.target.checked));
+  }
+
+});
+
+export default connect(makeMapStateToProps, mapDispatchToProps)(UnlistedToggle);
-- 
cgit 

