store events in SortedMap to avoid sort on render

This commit is contained in:
Martti Malmi
2024-01-04 18:11:38 +02:00
parent 47d92fe171
commit 5d259cee95
6 changed files with 239 additions and 5 deletions

View File

@ -53,7 +53,6 @@ const Timeline = (props: TimelineProps) => {
return followDistance === props.followDistance;
};
const a = [...nts.filter(a => a.kind !== EventKind.LiveEvent)];
props.noSort || a.sort((a, b) => b.created_at - a.created_at);
return a
?.filter(a => (props.postsOnly ? !a.tags.some(b => b[0] === "e") : true))
.filter(a => (props.ignoreModeration || !isEventMuted(a)) && checkFollowDistance(a));

View File

@ -43,8 +43,7 @@ export function ThreadContextWrapper({ link, children }: { link: NostrLink; chil
const chains = new Map<u256, Array<TaggedNostrEvent>>();
if (feed.thread) {
feed.thread
?.sort((a, b) => b.created_at - a.created_at)
.filter(a => !isBlocked(a.pubkey))
?.filter(a => !isBlocked(a.pubkey))
.forEach(v => {
const replyTo = replyChainKey(v);
if (replyTo) {