1
0
mirror of https://github.com/flarum/core.git synced 2025-07-15 13:56:23 +02:00

fix: sort posts by number instead of creation datetime (#3282)

Co-authored-by: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com>
This commit is contained in:
David Wheatley
2022-02-09 21:58:11 +01:00
committed by GitHub
parent 58829a3ed1
commit 397e4786da
4 changed files with 5 additions and 5 deletions

View File

@ -210,7 +210,7 @@ export default class DiscussionPage<CustomAttrs extends IDiscussionPageAttrs = I
record.relationships.discussion.data.id === discussionId
)
.map((record) => app.store.getById<Post>('posts', record.id))
.sort((a?: Post, b?: Post) => (a?.createdAt()?.getTime() ?? 0) - (b?.createdAt()?.getTime() ?? 0))
.sort((a?: Post, b?: Post) => (a?.number() ?? 0) - (b?.number() ?? 0))
.slice(0, 20);
}

View File

@ -289,7 +289,7 @@ class PostStreamState {
if (loadIds.length) {
return app.store.find('posts', loadIds).then((newPosts) => {
return loaded.concat(newPosts).sort((a, b) => a.createdAt() - b.createdAt());
return loaded.concat(newPosts).sort((a, b) => a.number() - b.number());
});
}