From 954f12591819ac5aa8bd67967fd230c632bbe99d Mon Sep 17 00:00:00 2001 From: Plastikmensch Date: Tue, 31 Oct 2023 05:42:49 +0100 Subject: [PATCH 1/2] Reset advanced options when editing toots There was both an issue with threaded mode and local-only toots when editing. When activating either option, it was preserved on edit, but changing the local-only attribute is not supported and threaded mode got stuck editing the same toot. The local-only option will be set to the toots local-only attribute to reflect that it is a local-only toot in the compose form. This unfortunately adds an additional local-only emoji. Signed-off-by: Plastikmensch --- app/javascript/flavours/glitch/reducers/compose.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/javascript/flavours/glitch/reducers/compose.js b/app/javascript/flavours/glitch/reducers/compose.js index 0915ecba0f21bb..7f6217b887a3ad 100644 --- a/app/javascript/flavours/glitch/reducers/compose.js +++ b/app/javascript/flavours/glitch/reducers/compose.js @@ -630,6 +630,11 @@ export default function compose(state = initialState, action) { map.set('spoiler_text', ''); } + map.update( + 'advanced_options', + map => map.merge(new ImmutableMap({ do_not_federate: action.status.get('local_only'), threaded_mode: false })), + ); + if (action.status.get('poll')) { map.set('poll', ImmutableMap({ options: action.status.getIn(['poll', 'options']).map(x => x.get('title')), From f88e33d836e603134e87451b272fc1ac01a561ce Mon Sep 17 00:00:00 2001 From: Plastikmensch Date: Tue, 31 Oct 2023 05:52:41 +0100 Subject: [PATCH 2/2] Fix additional local-only emoji being added when updating toot An additional local-only emoji was added to toots after editing a local-only toot, because the `do_not_federate` option is `true` and a local-only emoji is added unconditionally in such a case. Signed-off-by: Plastikmensch --- app/javascript/flavours/glitch/reducers/compose.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/javascript/flavours/glitch/reducers/compose.js b/app/javascript/flavours/glitch/reducers/compose.js index 7f6217b887a3ad..b50d3ce0412234 100644 --- a/app/javascript/flavours/glitch/reducers/compose.js +++ b/app/javascript/flavours/glitch/reducers/compose.js @@ -364,6 +364,8 @@ const updateSuggestionTags = (state, token) => { }; export default function compose(state = initialState, action) { + let do_not_federate, text; + switch(action.type) { case STORE_HYDRATE: return hydrate(state, action.state.get('compose')); @@ -568,8 +570,8 @@ export default function compose(state = initialState, action) { case COMPOSE_DOODLE_SET: return state.mergeIn(['doodle'], action.options); case REDRAFT: - const do_not_federate = !!action.status.get('local_only'); - let text = action.raw_text || unescapeHTML(expandMentions(action.status)); + do_not_federate = !!action.status.get('local_only'); + text = action.raw_text || unescapeHTML(expandMentions(action.status)); if (do_not_federate) text = text.replace(/ ?👁\ufe0f?\u200b?$/, ''); return state.withMutations(map => { map.set('text', text); @@ -609,9 +611,12 @@ export default function compose(state = initialState, action) { } }); case COMPOSE_SET_STATUS: + do_not_federate = !!action.status.get('local_only'); + text = action.text || unescapeHTML(expandMentions(action.status)); + if (do_not_federate) text = text.replace(/ ?👁\ufe0f?\u200b?$/, ''); return state.withMutations(map => { map.set('id', action.status.get('id')); - map.set('text', action.text); + map.set('text', 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')); @@ -632,7 +637,7 @@ export default function compose(state = initialState, action) { map.update( 'advanced_options', - map => map.merge(new ImmutableMap({ do_not_federate: action.status.get('local_only'), threaded_mode: false })), + map => map.merge(new ImmutableMap({ do_not_federate, threaded_mode: false })), ); if (action.status.get('poll')) {