diff --git a/app/javascript/flavours/glitch/features/compose/components/poll_form.js b/app/javascript/flavours/glitch/features/compose/components/poll_form.js index d0c39c35a4..0a52ecd310 100644 --- a/app/javascript/flavours/glitch/features/compose/components/poll_form.js +++ b/app/javascript/flavours/glitch/features/compose/components/poll_form.js @@ -81,7 +81,7 @@ class Option extends React.PureComponent {
- +
); diff --git a/app/javascript/flavours/glitch/reducers/compose.js b/app/javascript/flavours/glitch/reducers/compose.js index 6aef0ecf10..46bcd8146e 100644 --- a/app/javascript/flavours/glitch/reducers/compose.js +++ b/app/javascript/flavours/glitch/reducers/compose.js @@ -60,6 +60,7 @@ import { me, defaultContentType } from 'flavours/glitch/initial_state'; import { overwrite } from 'flavours/glitch/utils/js_helpers'; import { unescapeHTML } from 'flavours/glitch/utils/html'; import { recoverHashtags } from 'flavours/glitch/utils/hashtag'; +import { pollLimits } from 'flavours/glitch/initial_state'; const totalElefriends = 3; @@ -127,7 +128,7 @@ const initialState = ImmutableMap({ }); const initialPoll = ImmutableMap({ - options: ImmutableList(['']), + options: ImmutableList(new Array(pollLimits.min_options).fill('')), expires_in: 24 * 3600, multiple: false, }); diff --git a/app/javascript/mastodon/features/compose/components/poll_form.js b/app/javascript/mastodon/features/compose/components/poll_form.js index 1628aa6b31..69aee9d981 100644 --- a/app/javascript/mastodon/features/compose/components/poll_form.js +++ b/app/javascript/mastodon/features/compose/components/poll_form.js @@ -7,6 +7,7 @@ import IconButton from 'mastodon/components/icon_button'; import Icon from 'mastodon/components/icon'; import AutosuggestInput from 'mastodon/components/autosuggest_input'; import classNames from 'classnames'; +import { pollLimits } from 'mastodon/initial_state'; const messages = defineMessages({ option_placeholder: { id: 'compose_form.poll.option_placeholder', defaultMessage: 'Choice {number}' }, @@ -102,7 +103,7 @@ class Option extends React.PureComponent {
- +
); diff --git a/app/javascript/mastodon/initial_state.js b/app/javascript/mastodon/initial_state.js index bb05dafdf7..b21567cd0a 100644 --- a/app/javascript/mastodon/initial_state.js +++ b/app/javascript/mastodon/initial_state.js @@ -129,4 +129,7 @@ export const version = getMeta('version'); export const translationEnabled = getMeta('translation_enabled'); export const languages = initialState?.languages; +// CatCatNya~ specific setting for vanilla flavor +export const pollLimits = (initialState && initialState.poll_limits); + export default initialState; diff --git a/app/javascript/mastodon/reducers/compose.js b/app/javascript/mastodon/reducers/compose.js index 55a07249dc..82bc64a8ba 100644 --- a/app/javascript/mastodon/reducers/compose.js +++ b/app/javascript/mastodon/reducers/compose.js @@ -52,7 +52,7 @@ import { STORE_HYDRATE } from '../actions/store'; import { REDRAFT } from '../actions/statuses'; import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrderedSet, fromJS } from 'immutable'; import uuid from '../uuid'; -import { me } from '../initial_state'; +import { me, pollLimits } from '../initial_state'; import { unescapeHTML } from '../utils/html'; const initialState = ImmutableMap({ @@ -95,7 +95,7 @@ const initialState = ImmutableMap({ }); const initialPoll = ImmutableMap({ - options: ImmutableList(['']), + options: ImmutableList(new Array(pollLimits.min_options).fill('')), expires_in: 24 * 3600, multiple: false, }); diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index 7e57ce4bf0..d88acf1edc 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -17,6 +17,7 @@ class InitialStateSerializer < ActiveModel::Serializer def poll_limits { + min_options: PollValidator::MIN_OPTIONS, max_options: PollValidator::MAX_OPTIONS, max_option_chars: PollValidator::MAX_OPTION_CHARS, min_expiration: PollValidator::MIN_EXPIRATION, diff --git a/app/serializers/rest/instance_serializer.rb b/app/serializers/rest/instance_serializer.rb index 5ae1099d04..23525116d6 100644 --- a/app/serializers/rest/instance_serializer.rb +++ b/app/serializers/rest/instance_serializer.rb @@ -67,6 +67,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer }, polls: { + min_options: PollValidator::MIN_OPTIONS, max_options: PollValidator::MAX_OPTIONS, max_characters_per_option: PollValidator::MAX_OPTION_CHARS, min_expiration: PollValidator::MIN_EXPIRATION, diff --git a/app/serializers/rest/v1/instance_serializer.rb b/app/serializers/rest/v1/instance_serializer.rb index 389ec7dffc..0262f10d01 100644 --- a/app/serializers/rest/v1/instance_serializer.rb +++ b/app/serializers/rest/v1/instance_serializer.rb @@ -42,6 +42,7 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer def poll_limits { + min_options: PollValidator::MIN_OPTIONS, max_options: PollValidator::MAX_OPTIONS, max_option_chars: PollValidator::MAX_OPTION_CHARS, min_expiration: PollValidator::MIN_EXPIRATION, @@ -91,6 +92,7 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer }, polls: { + min_options: PollValidator::MIN_OPTIONS, max_options: PollValidator::MAX_OPTIONS, max_characters_per_option: PollValidator::MAX_OPTION_CHARS, min_expiration: PollValidator::MIN_EXPIRATION,