Skip to content

Commit

Permalink
Remove duplicated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ember-ruby committed Feb 2, 2024
1 parent b52cd0f commit f4251ac
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions app/javascript/flavours/glitch/reducers/statuses.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,43 +105,6 @@ const statusTranslateUndo = (state, id) => {
});
};

const updateReaction = (state, id, name, updater) => state.update(
id,
status => status.update(
'reactions',
reactions => {
const index = reactions.findIndex(reaction => reaction.get('name') === name);
if (index > -1) {
return reactions.update(index, reaction => updater(reaction));
} else {
return reactions.push(updater(fromJS({ name, count: 0 })));
}
},
),
);

const updateReactionCount = (state, reaction) => updateReaction(state, reaction.status_id, reaction.name, x => x.set('count', reaction.count));

// The url parameter is only used when adding a new custom emoji reaction
// (one that wasn't in the reactions list before) because we don't have its
// URL yet. In all other cases, it's undefined.
const addReaction = (state, id, name, url) => updateReaction(
state,
id,
name,
x => x.set('me', true)
.update('count', n => n + 1)
.update('url', old => old ? old : url)
.update('static_url', old => old ? old : url),
);

const removeReaction = (state, id, name) => updateReaction(
state,
id,
name,
x => x.set('me', false).update('count', n => n - 1),
);

const initialState = ImmutableMap();

export default function statuses(state = initialState, action) {
Expand Down

0 comments on commit f4251ac

Please sign in to comment.