PLT-6147 Fixed reactions not rendering properly while loading (#5958)
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
0a81dd9fff
Коммит
63cdb89144
@@ -37,36 +37,36 @@ class ReactionStore extends EventEmitter {
|
||||
}
|
||||
|
||||
addReaction(postId, reaction) {
|
||||
const reactions = [];
|
||||
let reactions = this.getReactions(postId) || [];
|
||||
|
||||
for (const existing of this.getReactions(postId)) {
|
||||
// make sure not to add duplicates
|
||||
if (existing.user_id !== reaction.user_id || existing.post_id !== reaction.post_id ||
|
||||
existing.emoji_name !== reaction.emoji_name) {
|
||||
reactions.push(existing);
|
||||
}
|
||||
// Make sure not to add duplicates
|
||||
const existingIndex = reactions.findIndex((existing) => {
|
||||
return existing.user_id === reaction.user_id && existing.post_id === reaction.post_id && existing.emoji_name === reaction.emoji_name;
|
||||
});
|
||||
|
||||
if (existingIndex === -1) {
|
||||
reactions = [...reactions, reaction];
|
||||
}
|
||||
|
||||
reactions.push(reaction);
|
||||
|
||||
this.setReactions(postId, reactions);
|
||||
}
|
||||
|
||||
removeReaction(postId, reaction) {
|
||||
const reactions = [];
|
||||
let reactions = this.getReactions(postId) || [];
|
||||
|
||||
for (const existing of this.getReactions(postId)) {
|
||||
if (existing.user_id !== reaction.user_id || existing.post_id !== reaction.post_id ||
|
||||
existing.emoji_name !== reaction.emoji_name) {
|
||||
reactions.push(existing);
|
||||
}
|
||||
const existingIndex = reactions.findIndex((existing) => {
|
||||
return existing.user_id === reaction.user_id && existing.post_id === reaction.post_id && existing.emoji_name === reaction.emoji_name;
|
||||
});
|
||||
|
||||
if (existingIndex !== -1) {
|
||||
reactions = reactions.slice(0, existingIndex).concat(reactions.slice(existingIndex + 1));
|
||||
}
|
||||
|
||||
this.setReactions(postId, reactions);
|
||||
}
|
||||
|
||||
getReactions(postId) {
|
||||
return this.reactions.get(postId) || [];
|
||||
return this.reactions.get(postId);
|
||||
}
|
||||
|
||||
handleEventPayload(payload) {
|
||||
@@ -89,4 +89,4 @@ class ReactionStore extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
export default new ReactionStore();
|
||||
export default new ReactionStore();
|
||||
|
||||
Ссылка в новой задаче
Block a user