mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-14 16:28:59 +00:00
[Glitch] Fix Edit as well as “Delete & Redraft” on a poll not inserting empty option
Port a48567784c to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@@ -102,12 +102,17 @@ export const ensureComposeIsVisible = (getState) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function setComposeToStatus(status, text, spoiler_text, content_type) {
|
export function setComposeToStatus(status, text, spoiler_text, content_type) {
|
||||||
return{
|
return (dispatch, getState) => {
|
||||||
|
const maxOptions = getState().server.getIn(['server', 'configuration', 'polls', 'max_options']);
|
||||||
|
|
||||||
|
dispatch({
|
||||||
type: COMPOSE_SET_STATUS,
|
type: COMPOSE_SET_STATUS,
|
||||||
status,
|
status,
|
||||||
text,
|
text,
|
||||||
spoiler_text,
|
spoiler_text,
|
||||||
content_type,
|
content_type,
|
||||||
|
maxOptions
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,11 +90,16 @@ export function fetchStatusFail(id, error, skipLoading) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function redraft(status, raw_text, content_type) {
|
export function redraft(status, raw_text, content_type) {
|
||||||
return {
|
return (dispatch, getState) => {
|
||||||
|
const maxOptions = getState().server.getIn(['server', 'configuration', 'polls', 'max_options']);
|
||||||
|
|
||||||
|
dispatch({
|
||||||
type: REDRAFT,
|
type: REDRAFT,
|
||||||
status,
|
status,
|
||||||
raw_text,
|
raw_text,
|
||||||
content_type,
|
content_type,
|
||||||
|
maxOptions,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -623,8 +623,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'])),
|
||||||
}));
|
}));
|
||||||
@@ -653,8 +658,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