Fixed PostStore to not return deleted posts when attempting to edit (#2839)
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
a0ba70823d
Коммит
f1ddbc4e8b
@@ -445,23 +445,30 @@ class PostStoreClass extends EventEmitter {
|
|||||||
|
|
||||||
getCurrentUsersLatestPost(channelId, rootId) {
|
getCurrentUsersLatestPost(channelId, rootId) {
|
||||||
const userId = UserStore.getCurrentId();
|
const userId = UserStore.getCurrentId();
|
||||||
var postList = makePostListNonNull(this.getAllPosts(channelId));
|
|
||||||
var i = 0;
|
|
||||||
var len = postList.order.length;
|
|
||||||
var lastPost = null;
|
|
||||||
|
|
||||||
for (i; i < len; i++) {
|
const postList = makePostListNonNull(this.getAllPosts(channelId));
|
||||||
|
const len = postList.order.length;
|
||||||
|
|
||||||
|
let lastPost = null;
|
||||||
|
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
const post = postList.posts[postList.order[i]];
|
const post = postList.posts[postList.order[i]];
|
||||||
if (post.user_id === userId && (post.props && !post.props.from_webhook || !post.props)) {
|
|
||||||
if (rootId) {
|
// don't edit webhook posts or deleted posts
|
||||||
if (post.root_id === rootId || post.id === rootId) {
|
if (post.user_id !== userId ||
|
||||||
lastPost = post;
|
(post.props && post.props.from_webhook) ||
|
||||||
break;
|
post.state === Constants.POST_DELETED) {
|
||||||
}
|
continue;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (rootId) {
|
||||||
|
if (post.root_id === rootId || post.id === rootId) {
|
||||||
lastPost = post;
|
lastPost = post;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
lastPost = post;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,26 +478,33 @@ class PostStoreClass extends EventEmitter {
|
|||||||
getEmptyDraft() {
|
getEmptyDraft() {
|
||||||
return {message: '', uploadsInProgress: [], previews: []};
|
return {message: '', uploadsInProgress: [], previews: []};
|
||||||
}
|
}
|
||||||
|
|
||||||
storeCurrentDraft(draft) {
|
storeCurrentDraft(draft) {
|
||||||
var channelId = ChannelStore.getCurrentId();
|
var channelId = ChannelStore.getCurrentId();
|
||||||
BrowserStore.setGlobalItem('draft_' + channelId, draft);
|
BrowserStore.setGlobalItem('draft_' + channelId, draft);
|
||||||
}
|
}
|
||||||
|
|
||||||
getCurrentDraft() {
|
getCurrentDraft() {
|
||||||
var channelId = ChannelStore.getCurrentId();
|
var channelId = ChannelStore.getCurrentId();
|
||||||
return this.getDraft(channelId);
|
return this.getDraft(channelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
storeDraft(channelId, draft) {
|
storeDraft(channelId, draft) {
|
||||||
BrowserStore.setGlobalItem('draft_' + channelId, draft);
|
BrowserStore.setGlobalItem('draft_' + channelId, draft);
|
||||||
}
|
}
|
||||||
|
|
||||||
getDraft(channelId) {
|
getDraft(channelId) {
|
||||||
return BrowserStore.getGlobalItem('draft_' + channelId, this.getEmptyDraft());
|
return BrowserStore.getGlobalItem('draft_' + channelId, this.getEmptyDraft());
|
||||||
}
|
}
|
||||||
|
|
||||||
storeCommentDraft(parentPostId, draft) {
|
storeCommentDraft(parentPostId, draft) {
|
||||||
BrowserStore.setGlobalItem('comment_draft_' + parentPostId, draft);
|
BrowserStore.setGlobalItem('comment_draft_' + parentPostId, draft);
|
||||||
}
|
}
|
||||||
|
|
||||||
getCommentDraft(parentPostId) {
|
getCommentDraft(parentPostId) {
|
||||||
return BrowserStore.getGlobalItem('comment_draft_' + parentPostId, this.getEmptyDraft());
|
return BrowserStore.getGlobalItem('comment_draft_' + parentPostId, this.getEmptyDraft());
|
||||||
}
|
}
|
||||||
|
|
||||||
clearDraftUploads() {
|
clearDraftUploads() {
|
||||||
BrowserStore.actionOnGlobalItemsWithPrefix('draft_', (key, value) => {
|
BrowserStore.actionOnGlobalItemsWithPrefix('draft_', (key, value) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
@@ -499,6 +513,7 @@ class PostStoreClass extends EventEmitter {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
clearCommentDraftUploads() {
|
clearCommentDraftUploads() {
|
||||||
BrowserStore.actionOnGlobalItemsWithPrefix('comment_draft_', (key, value) => {
|
BrowserStore.actionOnGlobalItemsWithPrefix('comment_draft_', (key, value) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
@@ -507,6 +522,7 @@ class PostStoreClass extends EventEmitter {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getCommentCount(post) {
|
getCommentCount(post) {
|
||||||
const posts = this.getAllPosts(post.channel_id).posts;
|
const posts = this.getAllPosts(post.channel_id).posts;
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user