From 606d240703445bbf73b6e95de4b8b4179bb230a0 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 1 Apr 2020 15:15:55 -0500 Subject: [PATCH] Load max_toot_chars from Instance --- .../features/compose/components/compose_form.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/gabsocial/features/compose/components/compose_form.js b/app/gabsocial/features/compose/components/compose_form.js index 6e145ecec..f8af8052b 100644 --- a/app/gabsocial/features/compose/components/compose_form.js +++ b/app/gabsocial/features/compose/components/compose_form.js @@ -1,4 +1,5 @@ import React from 'react'; +import { connect } from 'react-redux'; import CharacterCounter from './character_counter'; import Button from '../../../components/button'; import ImmutablePropTypes from 'react-immutable-proptypes'; @@ -21,7 +22,6 @@ import ImmutablePureComponent from 'react-immutable-pure-component'; import { length } from 'stringz'; import { countableText } from '../util/counter'; import Icon from 'gabsocial/components/icon'; -import { maxTootChars } from '../../../initial_state'; const allowedAroundShortCode = '><\u0085\u0020\u00a0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029\u0009\u000a\u000b\u000c\u000d'; @@ -32,7 +32,14 @@ const messages = defineMessages({ publishLoud: { id: 'compose_form.publish_loud', defaultMessage: '{publish}!' }, }); -export default @injectIntl +const mapStateToProps = state => { + return { + maxTootChars: state.getIn(['instance', 'max_toot_chars']), + }; +}; + +export default @connect(mapStateToProps) +@injectIntl class ComposeForm extends ImmutablePureComponent { state = { @@ -113,7 +120,7 @@ class ComposeForm extends ImmutablePureComponent { } // Submit disabled: - const { isSubmitting, isChangingUpload, isUploading, anyMedia } = this.props; + const { isSubmitting, isChangingUpload, isUploading, anyMedia, maxTootChars } = this.props; const fulltext = [this.props.spoilerText, countableText(this.props.text)].join(''); if (isSubmitting || isUploading || isChangingUpload || length(fulltext) > maxTootChars || (fulltext.length !== 0 && fulltext.trim().length === 0 && !anyMedia)) { @@ -199,7 +206,7 @@ class ComposeForm extends ImmutablePureComponent { } render () { - const { intl, onPaste, showSearch, anyMedia, shouldCondense, autoFocus, isModalOpen } = this.props; + const { intl, onPaste, showSearch, anyMedia, shouldCondense, autoFocus, isModalOpen, maxTootChars } = this.props; const condensed = shouldCondense && !this.props.text && !this.state.composeFocused; const disabled = this.props.isSubmitting; const text = [this.props.spoilerText, countableText(this.props.text)].join(''); @@ -280,7 +287,7 @@ class ComposeForm extends ImmutablePureComponent { -
+ {maxTootChars &&
} }