PLT-6147 Fixed reactions not rendering properly while loading (#5958)
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
0a81dd9fff
Коммит
63cdb89144
@@ -81,7 +81,6 @@ export default class ReactionListContainer extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.props.post.has_reactions && this.state.reactions.length > 0) {
|
|
||||||
return (
|
return (
|
||||||
<ReactionListView
|
<ReactionListView
|
||||||
post={this.props.post}
|
post={this.props.post}
|
||||||
@@ -90,7 +89,4 @@ export default class ReactionListContainer extends React.Component {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,14 @@ export default class ReactionListView extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
if (!this.props.post.has_reactions || (this.props.reactions && this.props.reactions.length === 0)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const reactionsByName = new Map();
|
const reactionsByName = new Map();
|
||||||
const emojiNames = [];
|
const emojiNames = [];
|
||||||
|
|
||||||
|
if (this.props.reactions) {
|
||||||
for (const reaction of this.props.reactions) {
|
for (const reaction of this.props.reactions) {
|
||||||
const emojiName = reaction.emoji_name;
|
const emojiName = reaction.emoji_name;
|
||||||
|
|
||||||
@@ -26,6 +31,7 @@ export default class ReactionListView extends React.Component {
|
|||||||
reactionsByName.set(emojiName, [reaction]);
|
reactionsByName.set(emojiName, [reaction]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const children = emojiNames.map((emojiName) => {
|
const children = emojiNames.map((emojiName) => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1287,10 +1287,6 @@ form {
|
|||||||
|
|
||||||
.post-reaction-list {
|
.post-reaction-list {
|
||||||
min-height: 30px;
|
min-height: 30px;
|
||||||
|
|
||||||
&:empty {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-reaction {
|
.post-reaction {
|
||||||
|
|||||||
@@ -37,36 +37,36 @@ class ReactionStore extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addReaction(postId, reaction) {
|
addReaction(postId, reaction) {
|
||||||
const reactions = [];
|
let reactions = this.getReactions(postId) || [];
|
||||||
|
|
||||||
for (const existing of this.getReactions(postId)) {
|
// Make sure not to add duplicates
|
||||||
// make sure not to add duplicates
|
const existingIndex = reactions.findIndex((existing) => {
|
||||||
if (existing.user_id !== reaction.user_id || existing.post_id !== reaction.post_id ||
|
return existing.user_id === reaction.user_id && existing.post_id === reaction.post_id && existing.emoji_name === reaction.emoji_name;
|
||||||
existing.emoji_name !== reaction.emoji_name) {
|
});
|
||||||
reactions.push(existing);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
reactions.push(reaction);
|
if (existingIndex === -1) {
|
||||||
|
reactions = [...reactions, reaction];
|
||||||
|
}
|
||||||
|
|
||||||
this.setReactions(postId, reactions);
|
this.setReactions(postId, reactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
removeReaction(postId, reaction) {
|
removeReaction(postId, reaction) {
|
||||||
const reactions = [];
|
let reactions = this.getReactions(postId) || [];
|
||||||
|
|
||||||
for (const existing of this.getReactions(postId)) {
|
const existingIndex = reactions.findIndex((existing) => {
|
||||||
if (existing.user_id !== reaction.user_id || existing.post_id !== reaction.post_id ||
|
return existing.user_id === reaction.user_id && existing.post_id === reaction.post_id && existing.emoji_name === reaction.emoji_name;
|
||||||
existing.emoji_name !== reaction.emoji_name) {
|
});
|
||||||
reactions.push(existing);
|
|
||||||
}
|
if (existingIndex !== -1) {
|
||||||
|
reactions = reactions.slice(0, existingIndex).concat(reactions.slice(existingIndex + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setReactions(postId, reactions);
|
this.setReactions(postId, reactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
getReactions(postId) {
|
getReactions(postId) {
|
||||||
return this.reactions.get(postId) || [];
|
return this.reactions.get(postId);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleEventPayload(payload) {
|
handleEventPayload(payload) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user