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){
switch(temp.t){
case "MESSAGE_CREATE":
thisuser.messageCreate(temp);
if(thisuser){
thisuser.messageCreate(temp);
}
break;
case "READY":
thisuser=new localuser(temp);
@ -441,37 +443,49 @@ function initwebsocket(){
document.getElementById("loading").classList.remove("loading")
break;
case "MESSAGE_UPDATE":
if(window.location.pathname.split("/")[3]==temp.d.channel_id){
const find=temp.d.id;
for(const message of messagelist){
if(message.all.id===find){
message.all.content=temp.d.content;
message.txt.innerHTML=markdown(temp.d.content).innerHTML;
break;
if(thisuser){
if(window.location.pathname.split("/")[3]==temp.d.channel_id){
const find=temp.d.id;
for(const message of messagelist){
if(message.all.id===find){
message.all.content=temp.d.content;
message.txt.innerHTML=markdown(temp.d.content).innerHTML;
break;
}
}
}
}
}
break;
case "TYPING_START":
thisuser.typeingStart(temp);
if(thisuser){
thisuser.typeingStart(temp);
}
break;
case "USER_UPDATE":
const users=user.userids[temp.d.id];
console.log(users,temp.d.id)
if(thisuser){
const users=user.userids[temp.d.id];
console.log(users,temp.d.id)
if(users){
users.userupdate(temp.d);
console.log("in here");
if(users){
users.userupdate(temp.d);
console.log("in here");
}
}
break
case "CHANNEL_UPDATE":
thisuser.updateChannel(temp.d);
if(thisuser){
thisuser.updateChannel(temp.d);
}
break;
case "CHANNEL_CREATE":
thisuser.createChannel(temp.d);
if(thisuser){
thisuser.createChannel(temp.d);
}
break;
case "CHANNEL_DELETE":
thisuser.delChannel(temp.d);
if(thisuser){
thisuser.delChannel(temp.d);
}
break;
}

View file

@ -24,15 +24,18 @@ class localuser{
}
for(const thing of ready.d.read_state.entries){
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.typing=[];
}
resolveGuildidFromChannelID(ID){
const resolve=this.guilds.find(guild => guild.channelids[ID])
resolve??={};
console.error("Failed to resolve "+ID);
resolve??=undefined;
return resolve;
}
updateChannel(JSON){