Bug fixes, blocking and various other changes

This commit is contained in:
MathMan05 2024-08-21 11:37:26 -05:00
parent 42a438f6dc
commit dbee2f3628
22 changed files with 679 additions and 370 deletions

View file

@ -43,7 +43,7 @@ class Channel{
typing:number;
message_notifications:number;
allthewayup:boolean;
static contextmenu=new Contextmenu("channel menu");
static contextmenu=new Contextmenu<Channel,undefined>("channel menu");
replyingto:Message|null;
infinite:InfiniteScroller;
idToPrev:Map<SnowFlake<Message>,SnowFlake<Message>>=new Map();
@ -70,16 +70,16 @@ class Channel{
this.contextmenu.addbutton("Delete channel",function(this:Channel){
console.log(this)
this.deleteChannel();
},null,_=>{console.log(_);return _.isAdmin()});
},null,function(){return this.isAdmin()});
this.contextmenu.addbutton("Edit channel",function(this:Channel){
this.editChannel();
},null,_=>{return _.isAdmin()});
},null,function(){return this.isAdmin()});
this.contextmenu.addbutton("Make invite",function(this:Channel){
this.createInvite();
},null,(_:Channel)=>{
return _.hasPermission("CREATE_INSTANT_INVITE")&&_.type!==4
},null,function(){
return this.hasPermission("CREATE_INSTANT_INVITE")&&this.type!==4
});
/*
this.contextmenu.addbutton("Test button",function(){
@ -170,7 +170,7 @@ class Channel{
}
setUpInfiniteScroller(){
this.infinite=new InfiniteScroller(async function(this:Channel,id:string,offset:number):Promise<string|undefined>{
const snowflake=SnowFlake.getSnowFlakeFromID(id,Message) as SnowFlake<Message>;
const snowflake=(this.messages.get(id) as Message).snowflake;
if(offset===1){
if(this.idToPrev.has(snowflake)){
return this.idToPrev.get(snowflake)?.id;
@ -196,13 +196,15 @@ class Channel{
if(messgage){
const html=messgage.buildhtml();
return html;
}else{
console.error(id+" not found")
}
}catch(e){
console.error(e);
}
}.bind(this),
async function(this:Channel,id:string){
const message=SnowFlake.getSnowFlakeFromID(id,Message).getObject();
const message=this.messages.get(id);
try{
if(message){
message.deleteDiv();
@ -383,7 +385,7 @@ class Channel{
decdiv.classList.add("channeleffects");
decdiv.classList.add("channel");
Channel.contextmenu.bind(decdiv,this);
Channel.contextmenu.bindContextmenu(decdiv,this,undefined);
decdiv["all"]=this;
@ -409,7 +411,7 @@ class Channel{
if(this.hasunreads){
div.classList.add("cunread");
}
Channel.contextmenu.bind(div,this);
Channel.contextmenu.bindContextmenu(div,this,undefined);
if(admin){this.coatDropDiv(div);}
div["all"]=this;
const myhtml=document.createElement("span");
@ -817,12 +819,6 @@ class Channel{
async grabArround(id:string){//currently unused and no plans to use it yet
throw new Error("please don't call this, no one has implemented it :P")
}
buildmessage(message:Message,next:Message){
const built=message.buildhtml(next);
if(built){
(document.getElementById("messages") as HTMLDivElement).prepend(built);
}
}
async buildmessages(){
/*
if(((!this.lastmessage)||(!this.lastmessage.snowflake)||(!this.goBackIds(this.lastmessage.snowflake,50,false)))&&this.lastreadmessageid){