From a47772dd0155ce3774484c44a57e5926047626a8 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Mon, 2 Sep 2024 17:59:27 -0500 Subject: [PATCH] remember colasped catagories --- .dist/channel.js | 24 +++++++++++++++++++++--- .dist/guild.js | 7 +++++++ .dist/localuser.js | 8 ++++++++ .dist/login.js | 8 ++++++++ webpage/channel.ts | 25 ++++++++++++++++++++++--- webpage/guild.ts | 9 ++++++++- webpage/localuser.ts | 10 +++++++++- webpage/login.ts | 8 ++++++++ 8 files changed, 91 insertions(+), 8 deletions(-) diff --git a/.dist/channel.js b/.dist/channel.js index 214dec7..2c04af2 100644 --- a/.dist/channel.js +++ b/.dist/channel.js @@ -248,6 +248,13 @@ class Channel { this.lastmessageid = undefined; } this.setUpInfiniteScroller(); + this.perminfo ??= {}; + } + get perminfo() { + return this.guild.perminfo.channels[this.id]; + } + set perminfo(e) { + this.guild.perminfo.channels[this.id] = e; } isAdmin() { return this.guild.isAdmin(); @@ -393,21 +400,32 @@ class Channel { } childrendiv.classList.add("channels"); setTimeout(_ => { - childrendiv.style.height = childrendiv.scrollHeight + "px"; + if (!this.perminfo.collapsed) { + childrendiv.style.height = childrendiv.scrollHeight + "px"; + } }, 100); - decdiv.onclick = function () { + div.appendChild(childrendiv); + if (this.perminfo.collapsed) { + decoration.classList.add("hiddencat"); + childrendiv.style.height = "0px"; + } + decdiv.onclick = () => { if (childrendiv.style.height !== "0px") { decoration.classList.add("hiddencat"); //childrendiv.classList.add("colapsediv"); + this.perminfo.collapsed = true; + this.localuser.userinfo.updateLocal(); childrendiv.style.height = "0px"; } else { decoration.classList.remove("hiddencat"); + this.perminfo.collapsed = false; + this.localuser.userinfo.updateLocal(); //childrendiv.classList.remove("colapsediv") + console.log("This ran?"); childrendiv.style.height = childrendiv.scrollHeight + "px"; } }; - div.appendChild(childrendiv); } else { div.classList.add("channel"); diff --git a/.dist/guild.js b/.dist/guild.js index 9ec540f..b1d0190 100644 --- a/.dist/guild.js +++ b/.dist/guild.js @@ -117,6 +117,7 @@ class Guild { } }); } + this.perminfo ??= { channels: {} }; for (const thing of json.channels) { const temp = new Channel(thing, this); this.channels.push(temp); @@ -130,6 +131,12 @@ class Guild { } } } + get perminfo() { + return this.localuser.perminfo.guilds[this.id]; + } + set perminfo(e) { + this.localuser.perminfo.guilds[this.id] = e; + } notisetting(settings) { this.message_notifications = settings.message_notifications; } diff --git a/.dist/localuser.js b/.dist/localuser.js index 89f4422..304583e 100644 --- a/.dist/localuser.js +++ b/.dist/localuser.js @@ -38,12 +38,19 @@ class Localuser { name: "Unknown", }; mfa_enabled; + get perminfo() { + return this.userinfo.localuserStore; + } + set perminfo(e) { + this.userinfo.localuserStore = e; + } constructor(userinfo) { if (userinfo === -1) { return; } this.token = userinfo.token; this.userinfo = userinfo; + this.perminfo.guilds ??= {}; this.serverurls = this.userinfo.serverurls; this.initialized = false; this.info = this.serverurls; @@ -99,6 +106,7 @@ class Localuser { user.relationshipType = thing.type; } this.pingEndpoint(); + this.userinfo.updateLocal(); } outoffocus() { const servers = document.getElementById("servers"); diff --git a/.dist/login.js b/.dist/login.js index 2a18c73..ea5f810 100644 --- a/.dist/login.js +++ b/.dist/login.js @@ -109,6 +109,7 @@ class Specialuser { this.token = json.token; this.loggedin = json.loggedin; this.json = json; + this.json.localuserStore ??= {}; if (!this.serverurls || !this.email || !this.token) { console.error("There are fundamentally missing pieces of info missing from this user"); } @@ -128,6 +129,13 @@ class Specialuser { get username() { return this.json.username; } + set localuserStore(e) { + this.json.localuserStore = e; + this.updateLocal(); + } + get localuserStore() { + return this.json.localuserStore; + } get uid() { return this.email + this.serverurls.wellknown; } diff --git a/webpage/channel.ts b/webpage/channel.ts index 3109c1a..4101610 100644 --- a/webpage/channel.ts +++ b/webpage/channel.ts @@ -260,6 +260,13 @@ class Channel{ this.lastmessageid=undefined; } this.setUpInfiniteScroller(); + this.perminfo??={}; + } + get perminfo(){ + return this.guild.perminfo.channels[this.id]; + } + set perminfo(e){ + this.guild.perminfo.channels[this.id]=e; } isAdmin(){ return this.guild.isAdmin(); @@ -408,20 +415,32 @@ class Channel{ } childrendiv.classList.add("channels"); setTimeout(_=>{ - childrendiv.style.height = childrendiv.scrollHeight + "px"; + if(!this.perminfo.collapsed){ + childrendiv.style.height = childrendiv.scrollHeight + "px"; + } },100); - decdiv.onclick=function(){ + div.appendChild(childrendiv); + if(this.perminfo.collapsed){ + decoration.classList.add("hiddencat"); + childrendiv.style.height = "0px"; + } + decdiv.onclick=()=>{ if(childrendiv.style.height!=="0px"){ decoration.classList.add("hiddencat"); //childrendiv.classList.add("colapsediv"); + this.perminfo.collapsed=true; + this.localuser.userinfo.updateLocal(); childrendiv.style.height = "0px"; }else{ decoration.classList.remove("hiddencat"); + this.perminfo.collapsed=false; + this.localuser.userinfo.updateLocal(); //childrendiv.classList.remove("colapsediv") + console.log("This ran?") childrendiv.style.height = childrendiv.scrollHeight + "px"; } }; - div.appendChild(childrendiv); + }else{ div.classList.add("channel"); if(this.hasunreads){ diff --git a/webpage/guild.ts b/webpage/guild.ts index bde6865..9aa47ee 100644 --- a/webpage/guild.ts +++ b/webpage/guild.ts @@ -94,6 +94,7 @@ class Guild{ if(json.stickers.length){ console.log(json.stickers,":3"); } + this.emojis = json.emojis; this.owner=owner; this.headers=this.owner.headers; @@ -125,7 +126,7 @@ class Guild{ } }); } - + this.perminfo??={channels:{}}; for(const thing of json.channels){ const temp=new Channel(thing,this); this.channels.push(temp); @@ -139,6 +140,12 @@ class Guild{ } } } + get perminfo(){ + return this.localuser.perminfo.guilds[this.id]; + } + set perminfo(e){ + this.localuser.perminfo.guilds[this.id]=e; + } notisetting(settings){ this.message_notifications=settings.message_notifications; } diff --git a/webpage/localuser.ts b/webpage/localuser.ts index d4cf451..1b482fd 100644 --- a/webpage/localuser.ts +++ b/webpage/localuser.ts @@ -43,12 +43,19 @@ class Localuser{ name: "Unknown", }; mfa_enabled:boolean; + get perminfo(){ + return this.userinfo.localuserStore; + } + set perminfo(e){ + this.userinfo.localuserStore=e; + } constructor(userinfo:Specialuser|-1){ if(userinfo===-1){ return; } this.token=userinfo.token; this.userinfo=userinfo; + this.perminfo.guilds??={}; this.serverurls=this.userinfo.serverurls; this.initialized=false; this.info=this.serverurls; @@ -109,6 +116,7 @@ class Localuser{ } this.pingEndpoint(); + this.userinfo.updateLocal(); } outoffocus():void{ const servers=document.getElementById("servers") as HTMLDivElement; @@ -1447,4 +1455,4 @@ class Localuser{ dialog.show(); } } -export {Localuser}; \ No newline at end of file +export {Localuser}; diff --git a/webpage/login.ts b/webpage/login.ts index 4ea614c..d9a4649 100644 --- a/webpage/login.ts +++ b/webpage/login.ts @@ -111,6 +111,7 @@ class Specialuser{ this.token=json.token; this.loggedin=json.loggedin; this.json=json; + this.json.localuserStore??={}; if(!this.serverurls||!this.email||!this.token){ console.error("There are fundamentally missing pieces of info missing from this user"); } @@ -130,6 +131,13 @@ class Specialuser{ get username(){ return this.json.username; } + set localuserStore(e){ + this.json.localuserStore=e; + this.updateLocal(); + } + get localuserStore(){ + return this.json.localuserStore; + } get uid(){ return this.email+this.serverurls.wellknown; }