Fix lodaing missing messages after search bug (#5080)
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
c0fde5f7e5
Коммит
4257114a37
@@ -256,7 +256,7 @@ export function emitLoadMorePostsFocusedTopEvent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function loadMorePostsTop(id, isFocusPost) {
|
export function loadMorePostsTop(id, isFocusPost) {
|
||||||
const earliestPostId = PostStore.getEarliestPost(id).id;
|
const earliestPostId = PostStore.getEarliestPostFromPage(id).id;
|
||||||
if (PostStore.requestVisibilityIncrease(id, Constants.POST_CHUNK_SIZE)) {
|
if (PostStore.requestVisibilityIncrease(id, Constants.POST_CHUNK_SIZE)) {
|
||||||
loadPostsBefore(earliestPostId, 0, Constants.POST_CHUNK_SIZE, isFocusPost);
|
loadPostsBefore(earliestPostId, 0, Constants.POST_CHUNK_SIZE, isFocusPost);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,6 +167,7 @@ export function loadPostsPage(channelId = ChannelStore.getCurrentId(), max = Con
|
|||||||
before: true,
|
before: true,
|
||||||
numRequested: numPosts,
|
numRequested: numPosts,
|
||||||
checkLatest: true,
|
checkLatest: true,
|
||||||
|
checkEarliest: true,
|
||||||
post_list: data
|
post_list: data
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -195,6 +196,7 @@ export function loadPostsBefore(postId, offset, numPost, isPost) {
|
|||||||
type: ActionTypes.RECEIVED_POSTS,
|
type: ActionTypes.RECEIVED_POSTS,
|
||||||
id: channelId,
|
id: channelId,
|
||||||
before: true,
|
before: true,
|
||||||
|
checkEarliest: true,
|
||||||
numRequested: numPost,
|
numRequested: numPost,
|
||||||
post_list: data,
|
post_list: data,
|
||||||
isPost
|
isPost
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ class PostStoreClass extends EventEmitter {
|
|||||||
this.selectedPostId = null;
|
this.selectedPostId = null;
|
||||||
this.postsInfo = {};
|
this.postsInfo = {};
|
||||||
this.latestPageTime = {};
|
this.latestPageTime = {};
|
||||||
|
this.earliestPostFromPage = {};
|
||||||
this.currentFocusedPostId = null;
|
this.currentFocusedPostId = null;
|
||||||
}
|
}
|
||||||
emitChange() {
|
emitChange() {
|
||||||
@@ -116,20 +117,8 @@ class PostStoreClass extends EventEmitter {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
getEarliestPost(id) {
|
getEarliestPostFromPage(id) {
|
||||||
if (this.postsInfo.hasOwnProperty(id)) {
|
return this.earliestPostFromPage[id];
|
||||||
const postList = this.postsInfo[id].postList;
|
|
||||||
|
|
||||||
for (let i = postList.order.length - 1; i >= 0; i--) {
|
|
||||||
const postId = postList.order[i];
|
|
||||||
|
|
||||||
if (postList.posts[postId].state !== Constants.POST_DELETED) {
|
|
||||||
return postList.posts[postId];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getLatestPost(id) {
|
getLatestPost(id) {
|
||||||
@@ -207,7 +196,7 @@ class PostStoreClass extends EventEmitter {
|
|||||||
return this.currentFocusedPostId;
|
return this.currentFocusedPostId;
|
||||||
}
|
}
|
||||||
|
|
||||||
storePosts(id, newPosts, checkLatest) {
|
storePosts(id, newPosts, checkLatest, checkEarliest) {
|
||||||
if (isPostListNull(newPosts)) {
|
if (isPostListNull(newPosts)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -225,6 +214,17 @@ class PostStoreClass extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (checkEarliest) {
|
||||||
|
const currentEarliest = this.earliestPostFromPage[id] || {create_at: Number.MAX_SAFE_INTEGER};
|
||||||
|
const orderLength = newPosts.order.length;
|
||||||
|
if (orderLength >= 1) {
|
||||||
|
const newEarliestPost = newPosts.posts[newPosts.order[orderLength - 1]];
|
||||||
|
if (newEarliestPost.create_at < currentEarliest.create_at) {
|
||||||
|
this.earliestPostFromPage[id] = newEarliestPost;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const combinedPosts = makePostListNonNull(this.getAllPosts(id));
|
const combinedPosts = makePostListNonNull(this.getAllPosts(id));
|
||||||
|
|
||||||
for (const pid in newPosts.posts) {
|
for (const pid in newPosts.posts) {
|
||||||
@@ -638,10 +638,10 @@ PostStore.dispatchToken = AppDispatcher.register((payload) => {
|
|||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case ActionTypes.RECEIVED_POSTS: {
|
case ActionTypes.RECEIVED_POSTS: {
|
||||||
if (PostStore.currentFocusedPostId !== null && action.isPost) {
|
if (PostStore.currentFocusedPostId !== null && action.isPost) {
|
||||||
PostStore.storePosts(PostStore.currentFocusedPostId, makePostListNonNull(action.post_list), action.checkLatest);
|
PostStore.storePosts(PostStore.currentFocusedPostId, makePostListNonNull(action.post_list), action.checkLatest, action.checkEarliest);
|
||||||
PostStore.checkBounds(PostStore.currentFocusedPostId, action.numRequested, makePostListNonNull(action.post_list), action.before);
|
PostStore.checkBounds(PostStore.currentFocusedPostId, action.numRequested, makePostListNonNull(action.post_list), action.before);
|
||||||
}
|
}
|
||||||
PostStore.storePosts(action.id, makePostListNonNull(action.post_list), action.checkLatest);
|
PostStore.storePosts(action.id, makePostListNonNull(action.post_list), action.checkLatest, action.checkEarliest);
|
||||||
PostStore.checkBounds(action.id, action.numRequested, makePostListNonNull(action.post_list), action.before);
|
PostStore.checkBounds(action.id, action.numRequested, makePostListNonNull(action.post_list), action.before);
|
||||||
PostStore.emitChange();
|
PostStore.emitChange();
|
||||||
break;
|
break;
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user