Fix PostStream loadRange doesn't return all posts (#2384)

- Also, ensure that posts are ordered by creation timestamp
This commit is contained in:
Alexander Skvortsov 2020-10-16 01:24:45 -04:00 committed by GitHub
commit 388b5adb05
2 changed files with 8 additions and 2 deletions

View File

@ -155,7 +155,7 @@ export default class DiscussionPage extends Page {
record.relationships.discussion.data.id === discussionId
)
.map((record) => app.store.getById('posts', record.id))
.sort((a, b) => a.id() - b.id())
.sort((a, b) => a.createdAt() - b.createdAt())
.slice(0, 20);
}

View File

@ -282,7 +282,13 @@ class PostStreamState {
}
});
return loadIds.length ? app.store.find('posts', loadIds) : Promise.resolve(loaded);
if (loadIds.length) {
return app.store.find('posts', loadIds).then((newPosts) => {
return loaded.concat(newPosts).sort((a, b) => a.createdAt() - b.createdAt());
});
}
return Promise.resolve(loaded);
}
/**