various updates
This commit is contained in:
parent
164aa48ea4
commit
cd15064d3a
16 changed files with 312 additions and 150 deletions
|
@ -28,12 +28,13 @@ class Localuser{
|
|||
guildids:Map<string,Guild>;
|
||||
user:User;
|
||||
status:string;
|
||||
channelfocus:Channel|null;
|
||||
lookingguild:Guild|null;
|
||||
channelfocus:Channel|undefined;
|
||||
lookingguild:Guild|undefined;
|
||||
guildhtml:Map<string, HTMLDivElement>;
|
||||
ws:WebSocket|undefined;
|
||||
connectionSucceed=0;
|
||||
errorBackoff=0;
|
||||
channelids=new Map<string,Channel>()
|
||||
readonly userMap=new Map<string,User>();
|
||||
instancePing={
|
||||
name: "Unknown",
|
||||
|
@ -68,8 +69,8 @@ class Localuser{
|
|||
this.userinfo.username=this.user.username;
|
||||
this.userinfo.pfpsrc=this.user.getpfpsrc();
|
||||
this.status=this.ready.d.user_settings.status;
|
||||
this.channelfocus=null;
|
||||
this.lookingguild=null;
|
||||
this.channelfocus=undefined;
|
||||
this.lookingguild=undefined;
|
||||
this.guildhtml=new Map();
|
||||
const members={};
|
||||
for(const thing of ready.d.merged_members){
|
||||
|
@ -94,15 +95,11 @@ class Localuser{
|
|||
}
|
||||
|
||||
for(const thing of ready.d.read_state.entries){
|
||||
const channel=this.resolveChannelFromID(thing.id);
|
||||
const channel=this.channelids.get(thing.channel_id);
|
||||
if(!channel){
|
||||
continue;
|
||||
}
|
||||
const guild=channel.guild;
|
||||
if(guild===undefined){
|
||||
continue;
|
||||
}
|
||||
guild.channelids[thing.channel_id].readStateInfo(thing);
|
||||
channel.readStateInfo(thing);
|
||||
}
|
||||
for(const thing of ready.d.relationships){
|
||||
const user=new User(thing.user,this);
|
||||
|
@ -121,8 +118,8 @@ class Localuser{
|
|||
if(this.channelfocus){
|
||||
this.channelfocus.infinite.delete();
|
||||
}
|
||||
this.lookingguild=null;
|
||||
this.channelfocus=null;
|
||||
this.lookingguild=undefined;
|
||||
this.channelfocus=undefined;
|
||||
}
|
||||
unload():void{
|
||||
this.initialized=false;
|
||||
|
@ -315,9 +312,7 @@ class Localuser{
|
|||
case"MESSAGE_DELETE":
|
||||
{
|
||||
temp.d.guild_id??="@me";
|
||||
const guild=this.guildids.get(temp.d.guild_id);
|
||||
if(!guild) break;
|
||||
const channel=guild.channelids[temp.d.channel_id];
|
||||
const channel=this.channelids.get(temp.d.channel_id);
|
||||
if(!channel) break;
|
||||
const message=channel.messages.get(temp.d.id);
|
||||
if(!message) break;
|
||||
|
@ -330,9 +325,7 @@ class Localuser{
|
|||
case"MESSAGE_UPDATE":
|
||||
{
|
||||
temp.d.guild_id??="@me";
|
||||
const guild=this.guildids.get(temp.d.guild_id);
|
||||
if(!guild) break;
|
||||
const channel=guild.channelids[temp.d.channel_id];
|
||||
const channel=this.channelids.get(temp.d.channel_id);
|
||||
if(!channel) break;
|
||||
const message=channel.messages.get(temp.d.id);
|
||||
if(!message) break;
|
||||
|
@ -390,7 +383,7 @@ class Localuser{
|
|||
temp.d.guild_id??="@me";
|
||||
const guild=this.guildids.get(temp.d.guild_id);
|
||||
if(!guild) break;
|
||||
const channel=guild.channelids[temp.d.channel_id];
|
||||
const channel=this.channelids.get(temp.d.channel_id);
|
||||
if(!channel) break;
|
||||
const message=channel.messages.get(temp.d.message_id);
|
||||
if(!message) break;
|
||||
|
@ -406,9 +399,7 @@ class Localuser{
|
|||
case"MESSAGE_REACTION_REMOVE":
|
||||
{
|
||||
temp.d.guild_id??="@me";
|
||||
const guild=this.guildids.get(temp.d.guild_id);
|
||||
if(!guild) break;
|
||||
const channel=guild.channelids[temp.d.channel_id];
|
||||
const channel=this.channelids.get(temp.d.channel_id);
|
||||
if(!channel) break;
|
||||
const message=channel.messages.get(temp.d.message_id);
|
||||
if(!message) break;
|
||||
|
@ -418,9 +409,7 @@ class Localuser{
|
|||
case"MESSAGE_REACTION_REMOVE_ALL":
|
||||
{
|
||||
temp.d.guild_id??="@me";
|
||||
const guild=this.guildids.get(temp.d.guild_id);
|
||||
if(!guild) break;
|
||||
const channel=guild.channelids[temp.d.channel_id];
|
||||
const channel=this.channelids.get(temp.d.channel_id);
|
||||
if(!channel) break;
|
||||
const message=channel.messages.get(temp.d.message_id);
|
||||
if(!message) break;
|
||||
|
@ -430,9 +419,7 @@ class Localuser{
|
|||
case"MESSAGE_REACTION_REMOVE_EMOJI":
|
||||
{
|
||||
temp.d.guild_id??="@me";
|
||||
const guild=this.guildids.get(temp.d.guild_id);
|
||||
if(!guild) break;
|
||||
const channel=guild.channelids[temp.d.channel_id];
|
||||
const channel=this.channelids.get(temp.d.channel_id);
|
||||
if(!channel) break;
|
||||
const message=channel.messages.get(temp.d.message_id);
|
||||
if(!message) break;
|
||||
|
@ -457,13 +444,6 @@ class Localuser{
|
|||
}
|
||||
}
|
||||
heartbeat_interval:number;
|
||||
resolveChannelFromID(ID:string):Channel|undefined{
|
||||
const resolve=this.guilds.find(guild=>guild.channelids[ID]);
|
||||
if(resolve){
|
||||
return resolve.channelids[ID];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
updateChannel(json:channeljson):void{
|
||||
const guild=this.guildids.get(json.guild_id);
|
||||
if(guild){
|
||||
|
@ -489,13 +469,10 @@ class Localuser{
|
|||
}
|
||||
gotoid:string|undefined;
|
||||
async goToChannel(id:string){
|
||||
let guild:undefined|Guild;
|
||||
for(const thing of this.guilds){
|
||||
if(thing.channelids[id]){
|
||||
guild=thing;
|
||||
}
|
||||
}
|
||||
if(guild){
|
||||
|
||||
const channel=this.channelids.get(id);
|
||||
if(channel){
|
||||
const guild=channel.guild;
|
||||
guild.loadGuild();
|
||||
guild.loadChannel(id);
|
||||
}else{
|
||||
|
@ -523,7 +500,7 @@ class Localuser{
|
|||
return;
|
||||
}
|
||||
guild.loadChannel(location[5]);
|
||||
this.channelfocus=guild.channelids[location[5]];
|
||||
this.channelfocus=this.channelids.get(location[5]);
|
||||
}
|
||||
}
|
||||
loaduser():void{
|
||||
|
@ -762,10 +739,11 @@ class Localuser{
|
|||
}
|
||||
messageCreate(messagep):void{
|
||||
messagep.d.guild_id??="@me";
|
||||
const guild=this.guildids.get(messagep.d.guild_id);
|
||||
if(!guild)return;
|
||||
guild.channelids[messagep.d.channel_id].messageCreate(messagep);
|
||||
this.unreads();
|
||||
const channel=this.channelids.get(messagep.d.channel_id);
|
||||
if(channel){
|
||||
channel.messageCreate(messagep);
|
||||
this.unreads();
|
||||
}
|
||||
}
|
||||
unreads():void{
|
||||
for(const thing of this.guilds){
|
||||
|
@ -778,9 +756,7 @@ class Localuser{
|
|||
}
|
||||
async typingStart(typing):Promise<void>{
|
||||
//
|
||||
const guild=this.guildids.get(typing.d.guild_id);
|
||||
if(!guild)return;
|
||||
const channel=guild.channelids[typing.d.channel_id];
|
||||
const channel=this.channelids.get(typing.d.channel_id);
|
||||
if(!channel) return;
|
||||
channel.typingStart(typing);
|
||||
//this.typing.set(memb,Date.now());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue