Use the server setting to get the max number of poll options in UI (#29490)
This commit is contained in:
parent
6984f94044
commit
b9722dfe2b
3 changed files with 8 additions and 6 deletions
|
@ -280,12 +280,12 @@ const updateSuggestionTags = (state, token) => {
|
|||
});
|
||||
};
|
||||
|
||||
const updatePoll = (state, index, value) => state.updateIn(['poll', 'options'], options => {
|
||||
const updatePoll = (state, index, value, maxOptions) => state.updateIn(['poll', 'options'], options => {
|
||||
const tmp = options.set(index, value).filterNot(x => x.trim().length === 0);
|
||||
|
||||
if (tmp.size === 0) {
|
||||
return tmp.push('').push('');
|
||||
} else if (tmp.size < 4) {
|
||||
} else if (tmp.size < maxOptions) {
|
||||
return tmp.push('');
|
||||
}
|
||||
|
||||
|
@ -529,7 +529,7 @@ export default function compose(state = initialState, action) {
|
|||
case COMPOSE_POLL_REMOVE:
|
||||
return state.set('poll', null);
|
||||
case COMPOSE_POLL_OPTION_CHANGE:
|
||||
return updatePoll(state, action.index, action.title);
|
||||
return updatePoll(state, action.index, action.title, action.maxOptions);
|
||||
case COMPOSE_POLL_SETTINGS_CHANGE:
|
||||
return state.update('poll', poll => poll.set('expires_in', action.expiresIn).set('multiple', action.isMultiple));
|
||||
case COMPOSE_LANGUAGE_CHANGE:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue