From 235be596bc6a6ed6a042975ac7f698695d6cda19 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Wed, 6 Mar 2019 13:42:48 +0100 Subject: [PATCH] Use server-provided poll limits instead of hardcoded ones Also does not enable polls if no limits are provided by the server --- .../glitch/features/composer/options/index.js | 29 ++++++++++--------- .../poll_form/components/poll_form.js | 5 ++-- .../flavours/glitch/util/initial_state.js | 1 + 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/app/javascript/flavours/glitch/features/composer/options/index.js b/app/javascript/flavours/glitch/features/composer/options/index.js index 80ac1b63a1c..7c7f01dc2db 100644 --- a/app/javascript/flavours/glitch/features/composer/options/index.js +++ b/app/javascript/flavours/glitch/features/composer/options/index.js @@ -19,6 +19,7 @@ import { assignHandlers, hiddenComponent, } from 'flavours/glitch/util/react_helpers'; +import { pollLimits } from 'flavours/glitch/util/initial_state'; // Messages. const messages = defineMessages({ @@ -248,19 +249,21 @@ export default class ComposerOptions extends React.PureComponent { onModalOpen={onModalOpen} title={intl.formatMessage(messages.attach)} /> - + {!!pollLimits && ( + + )} @@ -100,7 +101,7 @@ class PollForm extends ImmutablePureComponent {
- {options.size < 4 && ( + {options.size < pollLimits.max_options && ( )} diff --git a/app/javascript/flavours/glitch/util/initial_state.js b/app/javascript/flavours/glitch/util/initial_state.js index a3c65563c2f..62588eeaaf7 100644 --- a/app/javascript/flavours/glitch/util/initial_state.js +++ b/app/javascript/flavours/glitch/util/initial_state.js @@ -22,6 +22,7 @@ export const deleteModal = getMeta('delete_modal'); export const me = getMeta('me'); export const searchEnabled = getMeta('search_enabled'); export const maxChars = (initialState && initialState.max_toot_chars) || 500; +export const pollLimits = (initialState && initialState.poll_limits); export const invitesEnabled = getMeta('invites_enabled'); export const version = getMeta('version'); export const mascot = getMeta('mascot');