get rid of snowflake stuff more
This commit is contained in:
parent
03041cf9fd
commit
004beb4955
13 changed files with 23 additions and 47 deletions
|
@ -24,12 +24,11 @@ class Channel{
|
|||
owner:Guild;
|
||||
headers:Localuser["headers"];
|
||||
name:string;
|
||||
snowflake:SnowFlake<Channel>;
|
||||
snowflake:SnowFlake;
|
||||
parent_id?:string;
|
||||
parent:Channel|null;
|
||||
children:Channel[];
|
||||
guild_id:string;
|
||||
messageids:Map<SnowFlake<Message>,Message>;
|
||||
permission_overwrites:Map<string,Permissions>;
|
||||
permission_overwritesar:[Role,Permissions][];
|
||||
topic:string;
|
||||
|
@ -229,14 +228,13 @@ class Channel{
|
|||
this.owner=owner;
|
||||
this.headers=this.owner.headers;
|
||||
this.name=json.name;
|
||||
this.snowflake=new SnowFlake(json.id,this);
|
||||
this.snowflake=new SnowFlake(json.id);
|
||||
if(json.parent_id){
|
||||
this.parent_id=json.parent_id;
|
||||
}
|
||||
this.parent=null;
|
||||
this.children=[];
|
||||
this.guild_id=json.guild_id;
|
||||
this.messageids=new Map();
|
||||
this.permission_overwrites=new Map();
|
||||
this.permission_overwritesar=[];
|
||||
for(const thing of json.permission_overwrites){
|
||||
|
@ -767,9 +765,6 @@ class Channel{
|
|||
this.lastmessageid=message.id;
|
||||
}
|
||||
prev=message;
|
||||
if(this.messageids.get(message.snowflake)===undefined){
|
||||
this.messageids.set(message.snowflake,message);
|
||||
}
|
||||
}
|
||||
}
|
||||
delChannel(json:channeljson){
|
||||
|
@ -803,7 +798,6 @@ class Channel{
|
|||
this.idToPrev.set(messager.id,previd);
|
||||
this.idToNext.set(previd,messager.id);
|
||||
previd=messager.id;
|
||||
this.messageids.set(messager.snowflake,messager);
|
||||
if(willbreak){
|
||||
break;
|
||||
}
|
||||
|
@ -843,7 +837,6 @@ class Channel{
|
|||
this.idToNext.set(messager.id,previd);
|
||||
this.idToPrev.set(previd,messager.id);
|
||||
previd=messager.id;
|
||||
this.messageids.set(messager.snowflake,messager);
|
||||
|
||||
if(Number(i)===response.length-1&&response.length<100){
|
||||
this.topid=previd;
|
||||
|
@ -958,7 +951,6 @@ class Channel{
|
|||
|
||||
this.children=[];
|
||||
this.guild_id=json.guild_id;
|
||||
this.messageids=new Map();
|
||||
this.permission_overwrites=new Map();
|
||||
for(const thing of json.permission_overwrites){
|
||||
if(thing.id==="1182819038095799904"||thing.id==="1182820803700625444"){
|
||||
|
@ -1061,7 +1053,6 @@ class Channel{
|
|||
}
|
||||
|
||||
this.lastmessageid=messagez.id;
|
||||
this.messageids.set(messagez.snowflake,messagez);
|
||||
|
||||
if(messagez.author===this.localuser.user){
|
||||
this.lastreadmessageid=messagez.id;
|
||||
|
|
|
@ -19,7 +19,7 @@ class Direct extends Guild{
|
|||
this.headers=this.localuser.headers;
|
||||
this.channels=[];
|
||||
this.channelids={};
|
||||
this.snowflake=new SnowFlake("@me",this);
|
||||
this.snowflake=new SnowFlake("@me");
|
||||
this.properties={};
|
||||
this.roles=[];
|
||||
this.roleids=new Map();
|
||||
|
@ -94,12 +94,11 @@ class Group extends Channel{
|
|||
this.user=this.localuser.user;
|
||||
}
|
||||
this.name??=this.localuser.user.username;
|
||||
this.snowflake=new SnowFlake(json.id,this);
|
||||
this.snowflake=new SnowFlake(json.id);
|
||||
this.parent_id=null;
|
||||
this.parent=null;
|
||||
this.children=[];
|
||||
this.guild_id="@me";
|
||||
this.messageids=new Map();
|
||||
this.permission_overwrites=new Map();
|
||||
this.lastmessageid=json.last_message_id;
|
||||
this.mentions=0;
|
||||
|
@ -148,7 +147,6 @@ class Group extends Channel{
|
|||
this.idToPrev.set(messagez.id,this.lastmessageid);
|
||||
}
|
||||
this.lastmessageid=messagez.id;
|
||||
this.messageids.set(messagez.snowflake,messagez);
|
||||
if(messagez.author===this.localuser.user){
|
||||
this.lastreadmessageid=messagez.id;
|
||||
if(this.myhtml){
|
||||
|
|
|
@ -15,7 +15,7 @@ class Guild{
|
|||
headers:Localuser["headers"];
|
||||
channels:Channel[];
|
||||
channelids:{[key:string]:Channel};
|
||||
snowflake:SnowFlake<Guild>;
|
||||
snowflake:SnowFlake;
|
||||
properties;
|
||||
roles:Role[];
|
||||
roleids:Map<string,Role>;
|
||||
|
@ -100,7 +100,7 @@ class Guild{
|
|||
this.headers=this.owner.headers;
|
||||
this.channels=[];
|
||||
this.channelids={};
|
||||
this.snowflake=new SnowFlake(json.id,this);
|
||||
this.snowflake=new SnowFlake(json.id);
|
||||
this.properties=json.properties;
|
||||
this.roles=[];
|
||||
this.roleids=new Map();
|
||||
|
@ -394,10 +394,10 @@ class Guild{
|
|||
return this.member.isAdmin();
|
||||
}
|
||||
async markAsRead(){
|
||||
const build:{read_states:{channel_id:SnowFlake<Channel>,message_id:string|null|undefined,read_state_type:number}[]}={read_states: []};
|
||||
const build:{read_states:{channel_id:string,message_id:string|null|undefined,read_state_type:number}[]}={read_states: []};
|
||||
for(const thing of this.channels){
|
||||
if(thing.hasunreads){
|
||||
build.read_states.push({channel_id: thing.snowflake,message_id: thing.lastmessageid,read_state_type: 0});
|
||||
build.read_states.push({channel_id: thing.id,message_id: thing.lastmessageid,read_state_type: 0});
|
||||
thing.lastreadmessageid=thing.lastmessageid;
|
||||
if(!thing.myhtml)continue;
|
||||
thing.myhtml.classList.remove("cunread");
|
||||
|
|
|
@ -20,7 +20,7 @@ class Message{
|
|||
mentions:User[];
|
||||
mention_roles:Role[];
|
||||
attachments:File[];//probably should be its own class tbh, should be Attachments[]
|
||||
snowflake:SnowFlake<Message>;
|
||||
snowflake:SnowFlake;
|
||||
message_reference;
|
||||
type:number;
|
||||
timestamp:number;
|
||||
|
@ -119,7 +119,7 @@ class Message{
|
|||
this.content=new MarkDown(messagejson[thing],this.channel);
|
||||
continue;
|
||||
}else if(thing ==="id"){
|
||||
this.snowflake=new SnowFlake(messagejson.id,this);
|
||||
this.snowflake=new SnowFlake(messagejson.id);
|
||||
continue;
|
||||
}else if(thing==="member"){
|
||||
Member.new(messagejson.member as memberjson,this.guild).then(_=>{
|
||||
|
@ -235,7 +235,6 @@ class Message{
|
|||
this.channel.idToPrev.set(next,prev);
|
||||
this.channel.idToNext.set(prev,next);
|
||||
}
|
||||
this.channel.messageids.delete(this.snowflake);
|
||||
if(prev){
|
||||
const prevmessage=this.channel.messages.get(prev);
|
||||
if(prevmessage){
|
||||
|
|
|
@ -8,7 +8,7 @@ class Role{
|
|||
permissions:Permissions;
|
||||
owner:Guild;
|
||||
color:number;
|
||||
readonly snowflake:SnowFlake<Role>;
|
||||
readonly snowflake:SnowFlake;
|
||||
name:string;
|
||||
info:Guild["info"];
|
||||
hoist:boolean;
|
||||
|
@ -24,7 +24,7 @@ class Role{
|
|||
this.info=owner.info;
|
||||
for(const thing of Object.keys(json)){
|
||||
if(thing==="id"){
|
||||
this.snowflake=new SnowFlake(json.id,this);
|
||||
this.snowflake=new SnowFlake(json.id);
|
||||
continue;
|
||||
}
|
||||
this[thing]=json[thing];
|
||||
|
|
|
@ -10,7 +10,7 @@ import{ presencejson, userjson }from"./jsontypes.js";
|
|||
class User{
|
||||
owner:Localuser;
|
||||
hypotheticalpfp:boolean;
|
||||
snowflake:SnowFlake<User>;
|
||||
snowflake:SnowFlake;
|
||||
avatar:string|null;
|
||||
username:string;
|
||||
nickname:string|null=null;
|
||||
|
@ -153,7 +153,7 @@ class User{
|
|||
continue;
|
||||
}
|
||||
if(thing === "id"){
|
||||
this.snowflake=new SnowFlake(userjson[thing],this);
|
||||
this.snowflake=new SnowFlake(userjson[thing]);
|
||||
continue;
|
||||
}
|
||||
this[thing]=userjson[thing];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue