Merge branch 'fix-redraft' into 'develop'

Fix redraft: don't set compose id

See merge request soapbox-pub/soapbox-fe!1405
merge-requests/1406/merge
Justin 2022-05-17 10:57:58 +00:00
commit 1a1df69d0b
4 zmienionych plików z 29 dodań i 4 usunięć

Wyświetl plik

@ -98,7 +98,7 @@ export const ensureComposeIsVisible = (getState, routerHistory) => {
}
};
export function setComposeToStatus(status, rawText, spoilerText, contentType) {
export function setComposeToStatus(status, rawText, spoilerText, contentType, withRedraft) {
return (dispatch, getState) => {
const { instance } = getState();
const { explicitAddressing } = getFeatures(instance);
@ -111,6 +111,7 @@ export function setComposeToStatus(status, rawText, spoilerText, contentType) {
spoilerText,
contentType,
v: parseVersion(instance.version),
withRedraft,
});
};
}

Wyświetl plik

@ -98,7 +98,7 @@ export const editStatus = (id) => (dispatch, getState) => {
api(getState).get(`/api/v1/statuses/${id}/source`).then(response => {
dispatch({ type: STATUS_FETCH_SOURCE_SUCCESS });
dispatch(setComposeToStatus(status, response.data.text, response.data.spoiler_text));
dispatch(setComposeToStatus(status, response.data.text, response.data.spoiler_text, false));
dispatch(openModal('COMPOSE'));
}).catch(error => {
dispatch({ type: STATUS_FETCH_SOURCE_FAIL, error });
@ -139,7 +139,7 @@ export function deleteStatus(id, routerHistory, withRedraft = false) {
dispatch(deleteFromTimelines(id));
if (withRedraft) {
dispatch(setComposeToStatus(status, response.data.text, response.data.spoiler_text, response.data.pleroma?.content_type));
dispatch(setComposeToStatus(status, response.data.text, response.data.spoiler_text, response.data.pleroma?.content_type, withRedraft));
dispatch(openModal('COMPOSE'));
}
}).catch(error => {

Wyświetl plik

@ -59,6 +59,28 @@ describe('compose reducer', () => {
const result = reducer(undefined, action);
expect(result.getIn(['media_attachments', 0, 'id'])).toEqual('508107650');
});
it('sets the id when editing a post', () => {
const action = {
withRedraft: false,
type: actions.COMPOSE_SET_STATUS,
status: normalizeStatus(fromJS(require('soapbox/__fixtures__/pleroma-status-deleted.json'))),
};
const result = reducer(undefined, action);
expect(result.get('id')).toEqual('AHU2RrX0wdcwzCYjFQ');
});
it('does not set the id when redrafting a post', () => {
const action = {
withRedraft: true,
type: actions.COMPOSE_SET_STATUS,
status: normalizeStatus(fromJS(require('soapbox/__fixtures__/pleroma-status-deleted.json'))),
};
const result = reducer(undefined, action);
expect(result.get('id')).toEqual(null);
});
});
it('uses \'public\' scope as default', () => {

Wyświetl plik

@ -429,7 +429,9 @@ export default function compose(state = initialState, action) {
}));
case COMPOSE_SET_STATUS:
return state.withMutations(map => {
map.set('id', action.status.get('id'));
if (!action.withRedraft) {
map.set('id', action.status.get('id'));
}
map.set('text', action.rawText || unescapeHTML(expandMentions(action.status)));
map.set('to', action.explicitAddressing ? getExplicitMentions(action.status.get('account', 'id'), action.status) : ImmutableOrderedSet());
map.set('in_reply_to', action.status.get('in_reply_to_id'));