fix JS error when adding reaction when latest post is ephemeral (#6512)
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
fdf1164aee
Коммит
8ce72aedc3
@@ -270,11 +270,11 @@ export default class CreatePost extends React.Component {
|
||||
const action = isReaction[1];
|
||||
|
||||
const emojiName = isReaction[2];
|
||||
const postId = PostStore.getLatestPost(this.state.channelId).id;
|
||||
const postId = PostStore.getLatestNonEphemeralPost(this.state.channelId).id;
|
||||
|
||||
if (action === '+') {
|
||||
if (postId && action === '+') {
|
||||
PostActions.addReaction(this.state.channelId, postId, emojiName);
|
||||
} else if (action === '-') {
|
||||
} else if (postId && action === '-') {
|
||||
PostActions.removeReaction(this.state.channelId, postId, emojiName);
|
||||
}
|
||||
|
||||
|
||||
@@ -148,6 +148,20 @@ class PostStoreClass extends EventEmitter {
|
||||
return null;
|
||||
}
|
||||
|
||||
getLatestNonEphemeralPost(id) {
|
||||
if (this.postsInfo.hasOwnProperty(id)) {
|
||||
const postList = this.postsInfo[id].postList;
|
||||
|
||||
for (const postId of postList.order) {
|
||||
if (postList.posts[postId].state !== Constants.POST_DELETED && postList.posts[postId].type !== Constants.PostTypes.EPHEMERAL) {
|
||||
return postList.posts[postId];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
getLatestPostFromPageTime(id) {
|
||||
if (this.latestPageTime.hasOwnProperty(id)) {
|
||||
return this.latestPageTime[id];
|
||||
|
||||
Ссылка в новой задаче
Block a user