[Glitch] Fix Edit as well as “Delete & Redraft” on a poll not inserting empty option

Port d8c07be021 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Claire
2025-08-25 14:25:35 +02:00
parent 7fcd9184d2
commit 24e2bd2d6c
3 changed files with 34 additions and 14 deletions

View File

@@ -102,13 +102,18 @@ export const ensureComposeIsVisible = (getState) => {
};
export function setComposeToStatus(status, text, spoiler_text, content_type) {
return{
type: COMPOSE_SET_STATUS,
status,
text,
spoiler_text,
content_type,
};
return (dispatch, getState) => {
const maxOptions = getState().server.getIn(['server', 'configuration', 'polls', 'max_options']);
dispatch({
type: COMPOSE_SET_STATUS,
status,
text,
spoiler_text,
content_type,
maxOptions,
});
}
}
export function changeCompose(text) {

View File

@@ -89,11 +89,16 @@ export function fetchStatusFail(id, error, skipLoading) {
}
export function redraft(status, raw_text, content_type) {
return {
type: REDRAFT,
status,
raw_text,
content_type,
return (dispatch, getState) => {
const maxOptions = getState().server.getIn(['server', 'configuration', 'polls', 'max_options']);
dispatch({
type: REDRAFT,
status,
raw_text,
content_type,
maxOptions,
});
};
}

View File

@@ -644,8 +644,13 @@ export const composeReducer = (state = initialState, action) => {
}
if (action.status.get('poll')) {
let options = ImmutableList(action.status.get('poll').options.map(x => x.title));
if (options.size < action.maxOptions) {
options = options.push('');
}
map.set('poll', ImmutableMap({
options: ImmutableList(action.status.get('poll').options.map(x => x.title)),
options: options,
multiple: action.status.get('poll').multiple,
expires_in: expiresInFromExpiresAt(action.status.get('poll').expires_at),
}));
@@ -678,8 +683,13 @@ export const composeReducer = (state = initialState, action) => {
}
if (action.status.get('poll')) {
let options = ImmutableList(action.status.get('poll').options.map(x => x.title));
if (options.size < action.maxOptions) {
options = options.push('');
}
map.set('poll', ImmutableMap({
options: ImmutableList(action.status.get('poll').options.map(x => x.title)),
options: options,
multiple: action.status.get('poll').multiple,
expires_in: expiresInFromExpiresAt(action.status.get('poll').expires_at),
}));