Adds a more proper infinate scroller
It probally does more, but I can't remember what lol
This commit is contained in:
parent
d28ccb68be
commit
ec6ab101c0
22 changed files with 572 additions and 430 deletions
|
@ -67,7 +67,6 @@ class Group extends Channel{
|
|||
super(-1,owner);
|
||||
this.owner=owner;
|
||||
this.headers=this.guild.headers;
|
||||
this.messages=[];
|
||||
this.name=JSON.recipients[0]?.username;
|
||||
if(JSON.recipients[0]){
|
||||
this.user=new User(JSON.recipients[0],this.localuser);
|
||||
|
@ -85,6 +84,7 @@ class Group extends Channel{
|
|||
this.lastmessageid=JSON.last_message_id;
|
||||
this.lastmessageid??="0";
|
||||
this.mentions=0;
|
||||
this.setUpInfinateScroller();
|
||||
}
|
||||
createguildHTML(){
|
||||
const div=document.createElement("div")
|
||||
|
@ -104,9 +104,9 @@ class Group extends Channel{
|
|||
if(this.guild!==this.localuser.lookingguild){
|
||||
this.guild.loadGuild();
|
||||
}
|
||||
const prom=Message.wipeChanel();
|
||||
this.guild.prevchannel=this;
|
||||
this.localuser.channelfocus=this;
|
||||
const prom=this.infinate.delete();
|
||||
await this.putmessages();
|
||||
await prom;
|
||||
if(id!==Channel.genid){
|
||||
|
@ -118,38 +118,28 @@ class Group extends Channel{
|
|||
}
|
||||
messageCreate(messagep){
|
||||
const messagez=new Message(messagep.d,this);
|
||||
this.idToNext[this.lastmessageid]=messagez.id;
|
||||
this.idToPrev[messagez.id]=this.lastmessageid;
|
||||
this.lastmessageid=messagez.id;
|
||||
this.messageids[messagez.id]=messagez;
|
||||
if(messagez.author===this.localuser.user){
|
||||
this.lastreadmessageid=messagez.id;
|
||||
}
|
||||
this.messages.unshift(messagez);
|
||||
const scrolly=document.getElementById("messagecontainer");
|
||||
this.messageids[messagez.id]=messagez;
|
||||
if(this.localuser.lookingguild.prevchannel===this){
|
||||
var shouldScroll=scrolly.scrollTop+scrolly.clientHeight>scrolly.scrollHeight-20;
|
||||
document.getElementById("messages").appendChild(messagez.buildhtml(this.messages[1]));
|
||||
}
|
||||
if(shouldScroll){
|
||||
scrolly.scrollTop = scrolly.scrollHeight;
|
||||
}
|
||||
console.log(document.getElementById("channels").children)
|
||||
if(this.localuser.lookingguild===this.guild){
|
||||
const channellist=document.getElementById("channels").children[0]
|
||||
for(const thing of channellist.children){
|
||||
if(thing["myinfo"]===this){
|
||||
channellist.prepend(thing);
|
||||
break;
|
||||
}
|
||||
if(this.myhtml){
|
||||
this.myhtml.classList.remove("cunread");
|
||||
}
|
||||
}else{
|
||||
if(this.myhtml){
|
||||
this.myhtml.classList.add("cunread");
|
||||
}
|
||||
}
|
||||
this.unreads();
|
||||
this.infinate.addedBottom();
|
||||
if(messagez.author===this.localuser.user){
|
||||
return;
|
||||
}
|
||||
if(this.localuser.lookingguild.prevchannel===this&&document.hasFocus()){
|
||||
return;
|
||||
}
|
||||
console.log(this.notification);
|
||||
if(this.notification==="all"){
|
||||
this.notify(messagez);
|
||||
}else if(this.notification==="mentions"&&messagez.mentionsuser(this.localuser.user)){
|
||||
|
@ -183,9 +173,9 @@ class Group extends Channel{
|
|||
console.log(this);
|
||||
div.append(buildpfp)
|
||||
sentdms.append(div);
|
||||
div.onclick=function(){
|
||||
this["noti"].guild.loadGuild();
|
||||
this["noti"].getHTML();
|
||||
div.onclick=_=>{
|
||||
this.guild.loadGuild();
|
||||
this.getHTML();
|
||||
}
|
||||
}else if(current){
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue