diff --git a/app/gabsocial/features/compose/components/compose_form.js b/app/gabsocial/features/compose/components/compose_form.js
index e7fd0d08a..0ace5a0f1 100644
--- a/app/gabsocial/features/compose/components/compose_form.js
+++ b/app/gabsocial/features/compose/components/compose_form.js
@@ -34,7 +34,7 @@ const messages = defineMessages({
const mapStateToProps = state => {
return {
- maxTootChars: state.getIn(['instance', 'max_toot_chars']) || 500,
+ maxTootChars: state.getIn(['instance', 'max_toot_chars']),
};
};
diff --git a/app/gabsocial/features/compose/components/poll_form.js b/app/gabsocial/features/compose/components/poll_form.js
index c9a66b385..b00751aac 100644
--- a/app/gabsocial/features/compose/components/poll_form.js
+++ b/app/gabsocial/features/compose/components/poll_form.js
@@ -4,6 +4,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
+import { connect } from 'react-redux';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import IconButton from 'gabsocial/components/icon_button';
import Icon from 'gabsocial/components/icon';
@@ -35,6 +36,7 @@ class Option extends React.PureComponent {
onFetchSuggestions: PropTypes.func.isRequired,
onSuggestionSelected: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
+ maxChars: PropTypes.number.isRequired,
};
handleOptionTitleChange = e => {
@@ -65,7 +67,7 @@ class Option extends React.PureComponent {
}
render() {
- const { isPollMultiple, title, index, intl } = this.props;
+ const { isPollMultiple, title, index, maxChars, intl } = this.props;
return (
@@ -79,7 +81,7 @@ class Option extends React.PureComponent {
{
@@ -131,7 +135,7 @@ class PollForm extends ImmutablePureComponent {
};
render() {
- const { options, expiresIn, isMultiple, onChangeOption, onRemoveOption, intl, ...other } = this.props;
+ const { options, expiresIn, isMultiple, onChangeOption, onRemoveOption, maxOptions, maxOptionChars, intl, ...other } = this.props;
if (!options) {
return null;
@@ -140,11 +144,23 @@ class PollForm extends ImmutablePureComponent {
return (
- {options.map((title, i) => )}
+ {options.map((title, i) => (
+
+ ))}
- {options.size < 8 && (
+ {options.size < maxOptions && (
)}
@@ -163,3 +179,16 @@ class PollForm extends ImmutablePureComponent {
}
}
+
+const mapStateToProps = state => {
+ const pollLimits = state.getIn(['instance', 'poll_limits']);
+
+ return {
+ maxOptions: pollLimits.get('max_options'),
+ maxOptionChars: pollLimits.get('max_option_chars'),
+ maxExpiration: pollLimits.get('max_expiration'),
+ minExpiration: pollLimits.get('min_expiration'),
+ };
+};
+
+export default injectIntl(connect(mapStateToProps)(PollForm));
diff --git a/app/gabsocial/reducers/instance.js b/app/gabsocial/reducers/instance.js
index 8e91fc4e4..1976de437 100644
--- a/app/gabsocial/reducers/instance.js
+++ b/app/gabsocial/reducers/instance.js
@@ -1,7 +1,16 @@
import { INSTANCE_IMPORT } from '../actions/instance';
import { Map as ImmutableMap, fromJS } from 'immutable';
-const initialState = ImmutableMap();
+// Set Mastodon defaults, overridden by Pleroma servers
+const initialState = ImmutableMap({
+ max_toot_chars: 500,
+ poll_limits: ImmutableMap({
+ max_expiration: 2629746,
+ max_option_chars: 25,
+ max_options: 4,
+ min_expiration: 300,
+ }),
+});
export default function instance(state = initialState, action) {
switch(action.type) {