From f4879c4481ff4fd487bc1bfb1a48aa252960b2a3 Mon Sep 17 00:00:00 2001 From: Claire Date: Sun, 4 Dec 2022 17:58:10 +0100 Subject: Fix content-type being reset when editing toots (#1993) Fixes #1990 --- app/javascript/flavours/glitch/actions/compose.js | 3 ++- app/javascript/flavours/glitch/actions/statuses.js | 2 +- app/javascript/flavours/glitch/reducers/compose.js | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/javascript/flavours/glitch/actions/compose.js b/app/javascript/flavours/glitch/actions/compose.js index 54909b56e..7a4af4cda 100644 --- a/app/javascript/flavours/glitch/actions/compose.js +++ b/app/javascript/flavours/glitch/actions/compose.js @@ -93,12 +93,13 @@ export const ensureComposeIsVisible = (getState, routerHistory) => { } }; -export function setComposeToStatus(status, text, spoiler_text) { +export function setComposeToStatus(status, text, spoiler_text, content_type) { return{ type: COMPOSE_SET_STATUS, status, text, spoiler_text, + content_type, }; }; diff --git a/app/javascript/flavours/glitch/actions/statuses.js b/app/javascript/flavours/glitch/actions/statuses.js index a3e2a24f2..efb4cc33b 100644 --- a/app/javascript/flavours/glitch/actions/statuses.js +++ b/app/javascript/flavours/glitch/actions/statuses.js @@ -106,7 +106,7 @@ export const editStatus = (id, routerHistory) => (dispatch, getState) => { api(getState).get(`/api/v1/statuses/${id}/source`).then(response => { dispatch(fetchStatusSourceSuccess()); ensureComposeIsVisible(getState, routerHistory); - dispatch(setComposeToStatus(status, response.data.text, response.data.spoiler_text)); + dispatch(setComposeToStatus(status, response.data.text, response.data.spoiler_text, response.data.content_type)); }).catch(error => { dispatch(fetchStatusSourceFail(error)); }); diff --git a/app/javascript/flavours/glitch/reducers/compose.js b/app/javascript/flavours/glitch/reducers/compose.js index b1c792406..9b50ec23a 100644 --- a/app/javascript/flavours/glitch/reducers/compose.js +++ b/app/javascript/flavours/glitch/reducers/compose.js @@ -599,6 +599,7 @@ export default function compose(state = initialState, action) { return state.withMutations(map => { map.set('id', action.status.get('id')); map.set('text', action.text); + map.set('content_type', action.content_type || 'text/plain'); map.set('in_reply_to', action.status.get('in_reply_to_id')); map.set('privacy', action.status.get('visibility')); map.set('media_attachments', action.status.get('media_attachments')); -- cgit