improve loading of channels

This commit is contained in:
MathMan05
2024-08-17 20:57:08 -05:00
parent 9e9ebb506b
commit 032e1b5be6
12 changed files with 276 additions and 100 deletions

View File

@@ -21,7 +21,7 @@ class InfiniteScroller{
//div.classList.add("flexttb")
const scroll=document.createElement("div");
scroll.classList.add("flexttb","scroller")
div.append(scroll);
div.appendChild(scroll);
this.div=div;
this.interval=setInterval(this.updatestuff.bind(this),100);
@@ -49,7 +49,7 @@ class InfiniteScroller{
}
async firstElement(id:string){
const html=await this.getHTMLFromID(id);
this.scroll.append(html);
this.scroll.appendChild(html);
this.HTMLElements.push([html,id]);
}
currrunning:boolean=false;
@@ -81,6 +81,11 @@ class InfiniteScroller{
}else{
again=true;
const html=await this.getHTMLFromID(nextid);
if(!html){
this.destroyFromID(nextid);
console.error("html isn't defined");
throw Error("html isn't defined");
}
this.scroll.prepend(html);
this.HTMLElements.unshift([html,nextid]);
this.scrollTop+=60;
@@ -109,7 +114,7 @@ class InfiniteScroller{
}else{
again=true;
const html=await this.getHTMLFromID(nextid);
this.scroll.append(html);
this.scroll.appendChild(html);
this.HTMLElements.push([html,nextid]);
this.scrollBottom+=60;
if(scrollBottom<30){
@@ -129,14 +134,19 @@ class InfiniteScroller{
}
}
async watchForChange():Promise<void>{
try{
if(this.currrunning){
return;
}else{
this.currrunning=true;
}
if(!this.div){this.currrunning=false;return}
await Promise.allSettled([this.watchForBottom(),this.watchForTop()])
await Promise.allSettled([this.watchForTop(),this.watchForBottom()])
if(!this.currrunning){console.error("something really bad happened")}
this.currrunning=false;
}catch(e){
console.error(e);
}
}
async focus(id:string,flash=true){
let element:HTMLElement;
@@ -145,7 +155,6 @@ class InfiniteScroller{
element=thing[0];
}
}
console.log(element,id,":3");
if(element){
if(flash){