remember colasped catagories

This commit is contained in:
MathMan05 2024-09-02 17:59:27 -05:00
parent c2d657d889
commit a47772dd01
8 changed files with 91 additions and 8 deletions

View file

@ -248,6 +248,13 @@ class Channel {
this.lastmessageid = undefined; this.lastmessageid = undefined;
} }
this.setUpInfiniteScroller(); this.setUpInfiniteScroller();
this.perminfo ??= {};
}
get perminfo() {
return this.guild.perminfo.channels[this.id];
}
set perminfo(e) {
this.guild.perminfo.channels[this.id] = e;
} }
isAdmin() { isAdmin() {
return this.guild.isAdmin(); return this.guild.isAdmin();
@ -393,21 +400,32 @@ class Channel {
} }
childrendiv.classList.add("channels"); childrendiv.classList.add("channels");
setTimeout(_ => { setTimeout(_ => {
childrendiv.style.height = childrendiv.scrollHeight + "px"; if (!this.perminfo.collapsed) {
childrendiv.style.height = childrendiv.scrollHeight + "px";
}
}, 100); }, 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") { if (childrendiv.style.height !== "0px") {
decoration.classList.add("hiddencat"); decoration.classList.add("hiddencat");
//childrendiv.classList.add("colapsediv"); //childrendiv.classList.add("colapsediv");
this.perminfo.collapsed = true;
this.localuser.userinfo.updateLocal();
childrendiv.style.height = "0px"; childrendiv.style.height = "0px";
} }
else { else {
decoration.classList.remove("hiddencat"); decoration.classList.remove("hiddencat");
this.perminfo.collapsed = false;
this.localuser.userinfo.updateLocal();
//childrendiv.classList.remove("colapsediv") //childrendiv.classList.remove("colapsediv")
console.log("This ran?");
childrendiv.style.height = childrendiv.scrollHeight + "px"; childrendiv.style.height = childrendiv.scrollHeight + "px";
} }
}; };
div.appendChild(childrendiv);
} }
else { else {
div.classList.add("channel"); div.classList.add("channel");

View file

@ -117,6 +117,7 @@ class Guild {
} }
}); });
} }
this.perminfo ??= { channels: {} };
for (const thing of json.channels) { for (const thing of json.channels) {
const temp = new Channel(thing, this); const temp = new Channel(thing, this);
this.channels.push(temp); 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) { notisetting(settings) {
this.message_notifications = settings.message_notifications; this.message_notifications = settings.message_notifications;
} }

View file

@ -38,12 +38,19 @@ class Localuser {
name: "Unknown", name: "Unknown",
}; };
mfa_enabled; mfa_enabled;
get perminfo() {
return this.userinfo.localuserStore;
}
set perminfo(e) {
this.userinfo.localuserStore = e;
}
constructor(userinfo) { constructor(userinfo) {
if (userinfo === -1) { if (userinfo === -1) {
return; return;
} }
this.token = userinfo.token; this.token = userinfo.token;
this.userinfo = userinfo; this.userinfo = userinfo;
this.perminfo.guilds ??= {};
this.serverurls = this.userinfo.serverurls; this.serverurls = this.userinfo.serverurls;
this.initialized = false; this.initialized = false;
this.info = this.serverurls; this.info = this.serverurls;
@ -99,6 +106,7 @@ class Localuser {
user.relationshipType = thing.type; user.relationshipType = thing.type;
} }
this.pingEndpoint(); this.pingEndpoint();
this.userinfo.updateLocal();
} }
outoffocus() { outoffocus() {
const servers = document.getElementById("servers"); const servers = document.getElementById("servers");

View file

@ -109,6 +109,7 @@ class Specialuser {
this.token = json.token; this.token = json.token;
this.loggedin = json.loggedin; this.loggedin = json.loggedin;
this.json = json; this.json = json;
this.json.localuserStore ??= {};
if (!this.serverurls || !this.email || !this.token) { if (!this.serverurls || !this.email || !this.token) {
console.error("There are fundamentally missing pieces of info missing from this user"); console.error("There are fundamentally missing pieces of info missing from this user");
} }
@ -128,6 +129,13 @@ class Specialuser {
get username() { get username() {
return this.json.username; return this.json.username;
} }
set localuserStore(e) {
this.json.localuserStore = e;
this.updateLocal();
}
get localuserStore() {
return this.json.localuserStore;
}
get uid() { get uid() {
return this.email + this.serverurls.wellknown; return this.email + this.serverurls.wellknown;
} }

View file

@ -260,6 +260,13 @@ class Channel{
this.lastmessageid=undefined; this.lastmessageid=undefined;
} }
this.setUpInfiniteScroller(); this.setUpInfiniteScroller();
this.perminfo??={};
}
get perminfo(){
return this.guild.perminfo.channels[this.id];
}
set perminfo(e){
this.guild.perminfo.channels[this.id]=e;
} }
isAdmin(){ isAdmin(){
return this.guild.isAdmin(); return this.guild.isAdmin();
@ -408,20 +415,32 @@ class Channel{
} }
childrendiv.classList.add("channels"); childrendiv.classList.add("channels");
setTimeout(_=>{ setTimeout(_=>{
childrendiv.style.height = childrendiv.scrollHeight + "px"; if(!this.perminfo.collapsed){
childrendiv.style.height = childrendiv.scrollHeight + "px";
}
},100); },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"){ if(childrendiv.style.height!=="0px"){
decoration.classList.add("hiddencat"); decoration.classList.add("hiddencat");
//childrendiv.classList.add("colapsediv"); //childrendiv.classList.add("colapsediv");
this.perminfo.collapsed=true;
this.localuser.userinfo.updateLocal();
childrendiv.style.height = "0px"; childrendiv.style.height = "0px";
}else{ }else{
decoration.classList.remove("hiddencat"); decoration.classList.remove("hiddencat");
this.perminfo.collapsed=false;
this.localuser.userinfo.updateLocal();
//childrendiv.classList.remove("colapsediv") //childrendiv.classList.remove("colapsediv")
console.log("This ran?")
childrendiv.style.height = childrendiv.scrollHeight + "px"; childrendiv.style.height = childrendiv.scrollHeight + "px";
} }
}; };
div.appendChild(childrendiv);
}else{ }else{
div.classList.add("channel"); div.classList.add("channel");
if(this.hasunreads){ if(this.hasunreads){

View file

@ -94,6 +94,7 @@ class Guild{
if(json.stickers.length){ if(json.stickers.length){
console.log(json.stickers,":3"); console.log(json.stickers,":3");
} }
this.emojis = json.emojis; this.emojis = json.emojis;
this.owner=owner; this.owner=owner;
this.headers=this.owner.headers; this.headers=this.owner.headers;
@ -125,7 +126,7 @@ class Guild{
} }
}); });
} }
this.perminfo??={channels:{}};
for(const thing of json.channels){ for(const thing of json.channels){
const temp=new Channel(thing,this); const temp=new Channel(thing,this);
this.channels.push(temp); 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){ notisetting(settings){
this.message_notifications=settings.message_notifications; this.message_notifications=settings.message_notifications;
} }

View file

@ -43,12 +43,19 @@ class Localuser{
name: "Unknown", name: "Unknown",
}; };
mfa_enabled:boolean; mfa_enabled:boolean;
get perminfo(){
return this.userinfo.localuserStore;
}
set perminfo(e){
this.userinfo.localuserStore=e;
}
constructor(userinfo:Specialuser|-1){ constructor(userinfo:Specialuser|-1){
if(userinfo===-1){ if(userinfo===-1){
return; return;
} }
this.token=userinfo.token; this.token=userinfo.token;
this.userinfo=userinfo; this.userinfo=userinfo;
this.perminfo.guilds??={};
this.serverurls=this.userinfo.serverurls; this.serverurls=this.userinfo.serverurls;
this.initialized=false; this.initialized=false;
this.info=this.serverurls; this.info=this.serverurls;
@ -109,6 +116,7 @@ class Localuser{
} }
this.pingEndpoint(); this.pingEndpoint();
this.userinfo.updateLocal();
} }
outoffocus():void{ outoffocus():void{
const servers=document.getElementById("servers") as HTMLDivElement; const servers=document.getElementById("servers") as HTMLDivElement;
@ -1447,4 +1455,4 @@ class Localuser{
dialog.show(); dialog.show();
} }
} }
export {Localuser}; export {Localuser};

View file

@ -111,6 +111,7 @@ class Specialuser{
this.token=json.token; this.token=json.token;
this.loggedin=json.loggedin; this.loggedin=json.loggedin;
this.json=json; this.json=json;
this.json.localuserStore??={};
if(!this.serverurls||!this.email||!this.token){ if(!this.serverurls||!this.email||!this.token){
console.error("There are fundamentally missing pieces of info missing from this user"); console.error("There are fundamentally missing pieces of info missing from this user");
} }
@ -130,6 +131,13 @@ class Specialuser{
get username(){ get username(){
return this.json.username; return this.json.username;
} }
set localuserStore(e){
this.json.localuserStore=e;
this.updateLocal();
}
get localuserStore(){
return this.json.localuserStore;
}
get uid(){ get uid(){
return this.email+this.serverurls.wellknown; return this.email+this.serverurls.wellknown;
} }