mirror of
https://github.com/MathMan05/Fermi.git
synced 2026-07-28 09:59:20 +00:00
fix some perf issues
This commit is contained in:
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user