more bug fixes

This commit is contained in:
MathMan05 2024-05-28 11:18:05 -05:00
parent 8e89e9929b
commit cbf657afeb
2 changed files with 38 additions and 21 deletions

View file

@ -429,7 +429,9 @@ function initwebsocket(){
if(temp.op==0){ if(temp.op==0){
switch(temp.t){ switch(temp.t){
case "MESSAGE_CREATE": case "MESSAGE_CREATE":
if(thisuser){
thisuser.messageCreate(temp); thisuser.messageCreate(temp);
}
break; break;
case "READY": case "READY":
thisuser=new localuser(temp); thisuser=new localuser(temp);
@ -441,6 +443,7 @@ function initwebsocket(){
document.getElementById("loading").classList.remove("loading") document.getElementById("loading").classList.remove("loading")
break; break;
case "MESSAGE_UPDATE": case "MESSAGE_UPDATE":
if(thisuser){
if(window.location.pathname.split("/")[3]==temp.d.channel_id){ if(window.location.pathname.split("/")[3]==temp.d.channel_id){
const find=temp.d.id; const find=temp.d.id;
for(const message of messagelist){ for(const message of messagelist){
@ -451,11 +454,15 @@ function initwebsocket(){
} }
} }
} }
}
break; break;
case "TYPING_START": case "TYPING_START":
if(thisuser){
thisuser.typeingStart(temp); thisuser.typeingStart(temp);
}
break; break;
case "USER_UPDATE": case "USER_UPDATE":
if(thisuser){
const users=user.userids[temp.d.id]; const users=user.userids[temp.d.id];
console.log(users,temp.d.id) console.log(users,temp.d.id)
@ -463,15 +470,22 @@ function initwebsocket(){
users.userupdate(temp.d); users.userupdate(temp.d);
console.log("in here"); console.log("in here");
} }
}
break break
case "CHANNEL_UPDATE": case "CHANNEL_UPDATE":
if(thisuser){
thisuser.updateChannel(temp.d); thisuser.updateChannel(temp.d);
}
break; break;
case "CHANNEL_CREATE": case "CHANNEL_CREATE":
if(thisuser){
thisuser.createChannel(temp.d); thisuser.createChannel(temp.d);
}
break; break;
case "CHANNEL_DELETE": case "CHANNEL_DELETE":
if(thisuser){
thisuser.delChannel(temp.d); thisuser.delChannel(temp.d);
}
break; break;
} }

View file

@ -24,15 +24,18 @@ class localuser{
} }
for(const thing of ready.d.read_state.entries){ for(const thing of ready.d.read_state.entries){
console.log(thing) console.log(thing)
const guildid=this.resolveGuildidFromChannelID(thing.id).id; const guild=this.resolveGuildidFromChannelID(thing.id)
if(guild===undefined){
continue
}
const guildid=guild.id;
this.guildids[guildid].channelids[thing.channel_id].readStateInfo(thing); this.guildids[guildid].channelids[thing.channel_id].readStateInfo(thing);
} }
this.typing=[]; this.typing=[];
} }
resolveGuildidFromChannelID(ID){ resolveGuildidFromChannelID(ID){
const resolve=this.guilds.find(guild => guild.channelids[ID]) const resolve=this.guilds.find(guild => guild.channelids[ID])
resolve??={}; resolve??=undefined;
console.error("Failed to resolve "+ID);
return resolve; return resolve;
} }
updateChannel(JSON){ updateChannel(JSON){