mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-14 08:19:05 +00:00
[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:
@@ -102,13 +102,18 @@ 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) => {
|
||||||
type: COMPOSE_SET_STATUS,
|
const maxOptions = getState().server.getIn(['server', 'configuration', 'polls', 'max_options']);
|
||||||
status,
|
|
||||||
text,
|
dispatch({
|
||||||
spoiler_text,
|
type: COMPOSE_SET_STATUS,
|
||||||
content_type,
|
status,
|
||||||
};
|
text,
|
||||||
|
spoiler_text,
|
||||||
|
content_type,
|
||||||
|
maxOptions,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function changeCompose(text) {
|
export function changeCompose(text) {
|
||||||
|
|||||||
@@ -89,11 +89,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) => {
|
||||||
type: REDRAFT,
|
const maxOptions = getState().server.getIn(['server', 'configuration', 'polls', 'max_options']);
|
||||||
status,
|
|
||||||
raw_text,
|
dispatch({
|
||||||
content_type,
|
type: REDRAFT,
|
||||||
|
status,
|
||||||
|
raw_text,
|
||||||
|
content_type,
|
||||||
|
maxOptions,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -644,8 +644,13 @@ export const composeReducer = (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: ImmutableList(action.status.get('poll').options.map(x => x.title)),
|
options: options,
|
||||||
multiple: action.status.get('poll').multiple,
|
multiple: action.status.get('poll').multiple,
|
||||||
expires_in: expiresInFromExpiresAt(action.status.get('poll').expires_at),
|
expires_in: expiresInFromExpiresAt(action.status.get('poll').expires_at),
|
||||||
}));
|
}));
|
||||||
@@ -678,8 +683,13 @@ export const composeReducer = (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: ImmutableList(action.status.get('poll').options.map(x => x.title)),
|
options: options,
|
||||||
multiple: action.status.get('poll').multiple,
|
multiple: action.status.get('poll').multiple,
|
||||||
expires_in: expiresInFromExpiresAt(action.status.get('poll').expires_at),
|
expires_in: expiresInFromExpiresAt(action.status.get('poll').expires_at),
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user