From fa1db8cf5d70c56b81c581560fc14d658d844ffd Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Sun, 18 Aug 2024 11:11:36 -0500 Subject: [PATCH] various fixes --- .dist/guild.js | 3 +++ .dist/infiniteScroller.js | 4 ++-- .dist/login.js | 28 ++++++++++++++++++++++++++++ webpage/guild.ts | 3 +++ webpage/infiniteScroller.ts | 6 +++--- webpage/login.ts | 27 ++++++++++++++++++++++++++- 6 files changed, 65 insertions(+), 6 deletions(-) diff --git a/.dist/guild.js b/.dist/guild.js index 5e97801..e7c1e5b 100644 --- a/.dist/guild.js +++ b/.dist/guild.js @@ -77,6 +77,9 @@ class Guild { if (json === -1) { return; } + if (json.stickers.length) { + console.log(json.stickers, ":3"); + } this.emojis = json.emojis; this.owner = owner; this.headers = this.owner.headers; diff --git a/.dist/infiniteScroller.js b/.dist/infiniteScroller.js index 9407073..ff39331 100644 --- a/.dist/infiniteScroller.js +++ b/.dist/infiniteScroller.js @@ -164,7 +164,7 @@ class InfiniteScroller { return; } const out = await Promise.allSettled([this.watchForTop(), this.watchForBottom()]); - const changed = (out[0] || out[1]); + const changed = (out[0].value || out[1].value); if (null === this.timeout && changed) { this.timeout = setTimeout(this.updatestuff.bind(this), 300); } @@ -217,7 +217,7 @@ class InfiniteScroller { await this.destroyFromID(thing[1]); } this.HTMLElements = []; - clearInterval(this.timeout); + clearTimeout(this.timeout); if (this.div) { this.div.remove(); } diff --git a/.dist/login.js b/.dist/login.js index 7091388..d7042f2 100644 --- a/.dist/login.js +++ b/.dist/login.js @@ -17,6 +17,34 @@ function getBulkUsers() { } return json; } +function trimswitcher() { + const json = getBulkInfo(); + const map = new Map(); + for (const thing in json.users) { + const user = json.users[thing]; + console.log(user, json.users); + let wellknown = user.serverurls.wellknown; + if (wellknown[wellknown.length - 1] !== "/") { + wellknown += "/"; + } + if (map.has(wellknown)) { + const otheruser = map.get(wellknown); + if (otheruser[1].serverurls.wellknown[otheruser[1].serverurls.wellknown.length - 1] === "/") { + delete json.users[otheruser[0]]; + map.set(wellknown, [thing, user]); + } + else { + delete json.users[thing]; + } + } + else { + map.set(wellknown, [thing, user]); + } + } + localStorage.setItem("userinfos", JSON.stringify(json)); + console.log(json); +} +trimswitcher(); function getBulkInfo() { return JSON.parse(localStorage.getItem("userinfos")); } diff --git a/webpage/guild.ts b/webpage/guild.ts index 8bef811..c8d6c20 100644 --- a/webpage/guild.ts +++ b/webpage/guild.ts @@ -86,6 +86,9 @@ class Guild{ if(json===-1){ return; } + if(json.stickers.length){ + console.log(json.stickers,":3") + } this.emojis = json.emojis this.owner=owner; this.headers=this.owner.headers; diff --git a/webpage/infiniteScroller.ts b/webpage/infiniteScroller.ts index 951d902..3d47d4f 100644 --- a/webpage/infiniteScroller.ts +++ b/webpage/infiniteScroller.ts @@ -163,8 +163,8 @@ class InfiniteScroller{ this.currrunning=true; } if(!this.div){this.currrunning=false;return} - const out=await Promise.allSettled([this.watchForTop(),this.watchForBottom()]) - const changed=(out[0]||out[1]); + const out=await Promise.allSettled([this.watchForTop(),this.watchForBottom()]) as {value:boolean}[]; + const changed=(out[0].value||out[1].value); if(null===this.timeout&&changed){ this.timeout=setTimeout(this.updatestuff.bind(this),300); } @@ -213,7 +213,7 @@ class InfiniteScroller{ await this.destroyFromID(thing[1]); } this.HTMLElements=[]; - clearInterval(this.timeout); + clearTimeout(this.timeout); if(this.div){ this.div.remove(); } diff --git a/webpage/login.ts b/webpage/login.ts index f01575b..e908a89 100644 --- a/webpage/login.ts +++ b/webpage/login.ts @@ -18,7 +18,32 @@ function getBulkUsers(){ } return json; } - +function trimswitcher(){ + const json=getBulkInfo() + const map=new Map(); + for(const thing in json.users){ + const user=json.users[thing]; + console.log(user,json.users); + let wellknown=user.serverurls.wellknown; + if(wellknown[wellknown.length-1]!=="/"){ + wellknown+="/"; + } + if(map.has(wellknown)){ + const otheruser=map.get(wellknown); + if(otheruser[1].serverurls.wellknown[otheruser[1].serverurls.wellknown.length-1]==="/"){ + delete json.users[otheruser[0]]; + map.set(wellknown,[thing,user]); + }else{ + delete json.users[thing]; + } + }else{ + map.set(wellknown,[thing,user]); + } + } + localStorage.setItem("userinfos",JSON.stringify(json)); + console.log(json); +} +trimswitcher(); function getBulkInfo(){ return JSON.parse(localStorage.getItem("userinfos")); }