mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(replies-preview): stable sort when recency yields identical Infinity values
This commit is contained in:
@@ -27,8 +27,12 @@ export function getPreviewDisplayReplies<T extends CommentLike>(replies: T[], vi
|
||||
return Number.NEGATIVE_INFINITY;
|
||||
};
|
||||
|
||||
const newestFirst = [...replies].sort((a, b) => getRecency(b) - getRecency(a));
|
||||
return newestFirst.slice(0, visibleCount).reverse();
|
||||
const tagged = replies.map((reply, i) => ({ reply, recency: getRecency(reply), i }));
|
||||
tagged.sort((a, b) => (a.recency !== b.recency ? b.recency - a.recency : a.i - b.i));
|
||||
return tagged
|
||||
.slice(0, visibleCount)
|
||||
.reverse()
|
||||
.map((t) => t.reply);
|
||||
}
|
||||
|
||||
export interface ComputeOmittedParams {
|
||||
|
||||
Reference in New Issue
Block a user