Skip to content

Commit

Permalink
Fix additional local-only emoji being added when updating toot
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Plastikmensch committed Oct 31, 2023
1 parent 954f125 commit f88e33d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/javascript/flavours/glitch/reducers/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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'));
Expand All @@ -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')) {
Expand Down

0 comments on commit f88e33d

Please sign in to comment.