From 83ed0286d65e3a80b4e1107ae8364c033b80d018 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Sat, 7 Feb 2026 17:02:28 -0600 Subject: [PATCH] fix some perf issues --- src/webpage/infiniteScroller.ts | 15 ++++++++++++++- src/webpage/localuser.ts | 1 + src/webpage/rights.ts | 3 +++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/webpage/infiniteScroller.ts b/src/webpage/infiniteScroller.ts index d52d761..162038d 100644 --- a/src/webpage/infiniteScroller.ts +++ b/src/webpage/infiniteScroller.ts @@ -152,7 +152,9 @@ class InfiniteScroller { }, {root, threshold: 0.1}, ); - root.addEventListener("scroll", () => { + let time = Date.now(); + const handleScroll = async () => { + await new Promise((res) => requestAnimationFrame(res)); if (this.scrollBottom < 5) { const scroll = this.scroller; if (!scroll) return; @@ -161,6 +163,17 @@ class InfiniteScroller { if (this.backElm.get(last) || !this.backElm.has(last)) return; this.reachesBottom(); } + }; + let last = 0; + root.addEventListener("scroll", async () => { + const now = Date.now(); + const thisid = ++last; + if (now - time < 500) { + await new Promise((res) => setTimeout(res, 500)); + if (thisid !== last) return; + } + time = now; + handleScroll(); }); } diff --git a/src/webpage/localuser.ts b/src/webpage/localuser.ts index 595b752..3049ae8 100644 --- a/src/webpage/localuser.ts +++ b/src/webpage/localuser.ts @@ -681,6 +681,7 @@ class Localuser { relationshipsUpdate = () => {}; rights: Rights; updateRights(rights: string | number) { + if (this.rights.isSameAs(rights)) return; this.rights.update(rights); this.perminfo.user.rights = rights; } diff --git a/src/webpage/rights.ts b/src/webpage/rights.ts index 86d3524..27bc22b 100644 --- a/src/webpage/rights.ts +++ b/src/webpage/rights.ts @@ -6,6 +6,9 @@ class Rights { constructor(allow: string | number) { this.update(allow); } + isSameAs(allow: string | number) { + return this.allow === BigInt(allow); + } update(allow: string | number) { try { this.allow = BigInt(allow);