mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-25 17:51:36 +01:00
Fix min_options, let vanilla flavor behave properly for pollLimits
This commit is contained in:
parent
8f8cb0fad3
commit
4c24022984
3 changed files with 14 additions and 10 deletions
|
@ -357,10 +357,13 @@ const updateSuggestionTags = (state, token) => {
|
|||
};
|
||||
|
||||
const updatePoll = (state, index, value) => state.updateIn(['poll', 'options'], options => {
|
||||
const tmp = options.set(index, value).filterNot(x => x.trim().length === 0);
|
||||
let tmp = options.set(index, value).filterNot(x => x.trim().length === 0);
|
||||
|
||||
if (tmp.size === 0) {
|
||||
return tmp.push('').push('');
|
||||
const minOptions = pollLimits.min_options ?? 2;
|
||||
for (let i = 0; i < minOptions; i++) {
|
||||
tmp = tmp.push('');
|
||||
}
|
||||
} else if (tmp.size < pollLimits.max_options) {
|
||||
return tmp.push('');
|
||||
}
|
||||
|
|
|
@ -122,8 +122,6 @@ export const sso_redirect = getMeta('sso_redirect');
|
|||
|
||||
// Glitch-soc-specific settings
|
||||
export const maxChars = (initialState && initialState.max_toot_chars) || 500;
|
||||
|
||||
// CatCatNya~ specific settings
|
||||
export const pollMinOptions = (initialState && initialState.poll_limits && initialState.poll_limits.min_options) || 2;
|
||||
export const pollLimits = (initialState && initialState.poll_limits);
|
||||
|
||||
export default initialState;
|
||||
|
|
|
@ -51,7 +51,7 @@ import {
|
|||
import { REDRAFT } from '../actions/statuses';
|
||||
import { STORE_HYDRATE } from '../actions/store';
|
||||
import { TIMELINE_DELETE } from '../actions/timelines';
|
||||
import { me, pollMinOptions } from '../initial_state';
|
||||
import { me, pollLimits } from '../initial_state';
|
||||
import { unescapeHTML } from '../utils/html';
|
||||
import { uuid } from '../uuid';
|
||||
|
||||
|
@ -95,7 +95,7 @@ const initialState = ImmutableMap({
|
|||
});
|
||||
|
||||
const initialPoll = ImmutableMap({
|
||||
options: ImmutableList(new Array(pollMinOptions).fill('')),
|
||||
options: ImmutableList(new Array(pollLimits.min_options ?? 2).fill('')),
|
||||
expires_in: 24 * 3600,
|
||||
multiple: false,
|
||||
});
|
||||
|
@ -281,11 +281,14 @@ const updateSuggestionTags = (state, token) => {
|
|||
};
|
||||
|
||||
const updatePoll = (state, index, value) => state.updateIn(['poll', 'options'], options => {
|
||||
const tmp = options.set(index, value).filterNot(x => x.trim().length === 0);
|
||||
let tmp = options.set(index, value).filterNot(x => x.trim().length === 0);
|
||||
|
||||
if (tmp.size === 0) {
|
||||
return tmp.push('').push('');
|
||||
} else if (tmp.size < 4) {
|
||||
const minOptions = pollLimits.min_options ?? 2;
|
||||
for (let i = 0; i < minOptions; i++) {
|
||||
tmp = tmp.push('');
|
||||
}
|
||||
} else if (tmp.size < pollLimits.max_options) {
|
||||
return tmp.push('');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue