mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-13 15:58:50 +00:00
Fix Edit as well as “Delete & Redraft” on a poll not inserting empty option (#35892)
This commit is contained in:
@@ -96,11 +96,16 @@ export const ensureComposeIsVisible = (getState) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function setComposeToStatus(status, text, spoiler_text) {
|
export function setComposeToStatus(status, text, spoiler_text) {
|
||||||
return{
|
return (dispatch, getState) => {
|
||||||
type: COMPOSE_SET_STATUS,
|
const maxOptions = getState().server.getIn(['server', 'configuration', 'polls', 'max_options']);
|
||||||
status,
|
|
||||||
text,
|
dispatch({
|
||||||
spoiler_text,
|
type: COMPOSE_SET_STATUS,
|
||||||
|
status,
|
||||||
|
text,
|
||||||
|
spoiler_text,
|
||||||
|
maxOptions,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,10 +90,15 @@ export function fetchStatusFail(id, error, skipLoading) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function redraft(status, raw_text) {
|
export function redraft(status, raw_text) {
|
||||||
return {
|
return (dispatch, getState) => {
|
||||||
type: REDRAFT,
|
const maxOptions = getState().server.getIn(['server', 'configuration', 'polls', 'max_options']);
|
||||||
status,
|
|
||||||
raw_text,
|
dispatch({
|
||||||
|
type: REDRAFT,
|
||||||
|
status,
|
||||||
|
raw_text,
|
||||||
|
maxOptions,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -504,8 +504,13 @@ export default function compose(state = initialState, action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (action.status.get('poll')) {
|
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({
|
map.set('poll', ImmutableMap({
|
||||||
options: action.status.getIn(['poll', 'options']).map(x => x.get('title')),
|
options: options,
|
||||||
multiple: action.status.getIn(['poll', 'multiple']),
|
multiple: action.status.getIn(['poll', 'multiple']),
|
||||||
expires_in: expiresInFromExpiresAt(action.status.getIn(['poll', 'expires_at'])),
|
expires_in: expiresInFromExpiresAt(action.status.getIn(['poll', 'expires_at'])),
|
||||||
}));
|
}));
|
||||||
@@ -533,8 +538,13 @@ export default function compose(state = initialState, action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (action.status.get('poll')) {
|
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({
|
map.set('poll', ImmutableMap({
|
||||||
options: action.status.getIn(['poll', 'options']).map(x => x.get('title')),
|
options: options,
|
||||||
multiple: action.status.getIn(['poll', 'multiple']),
|
multiple: action.status.getIn(['poll', 'multiple']),
|
||||||
expires_in: expiresInFromExpiresAt(action.status.getIn(['poll', 'expires_at'])),
|
expires_in: expiresInFromExpiresAt(action.status.getIn(['poll', 'expires_at'])),
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user