Various bug fixes
This commit is contained in:
parent
cbf657afeb
commit
3b55b28260
7 changed files with 97 additions and 16 deletions
|
@ -346,18 +346,22 @@ class channel{
|
||||||
}
|
}
|
||||||
this.children=build;
|
this.children=build;
|
||||||
}
|
}
|
||||||
grabmoremessages(){
|
async grabmoremessages(){
|
||||||
if(this.messages.length===0){
|
if(this.messages.length===0||this.allthewayup){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const out=this;
|
const out=this;
|
||||||
fetch("https://api.old.server.spacebar.chat/api/channels/"+this.id+"/messages?before="+this.messages[this.messages.length-1].id+"&limit=100",{
|
|
||||||
|
await fetch("https://api.old.server.spacebar.chat/api/channels/"+this.id+"/messages?before="+this.messages[this.messages.length-1].id+"&limit=100",{
|
||||||
method:"GET",
|
method:"GET",
|
||||||
headers:{Authorization:token}
|
headers:{Authorization:token}
|
||||||
}).then((j)=>{return j.json()}).then(function(responce){
|
}).then((j)=>{return j.json()}).then(function(responce){
|
||||||
//messages.innerHTML = '';
|
//messages.innerHTML = '';
|
||||||
//responce.reverse()
|
//responce.reverse()
|
||||||
let next
|
let next
|
||||||
|
if(responce.length===0){
|
||||||
|
out.allthewayup=true;
|
||||||
|
}
|
||||||
for(const i in responce){
|
for(const i in responce){
|
||||||
let messager
|
let messager
|
||||||
if(!next){
|
if(!next){
|
||||||
|
@ -381,6 +385,7 @@ class channel{
|
||||||
}
|
}
|
||||||
//out.buildmessages();
|
//out.buildmessages();
|
||||||
})
|
})
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
buildmessage(message,next){
|
buildmessage(message,next){
|
||||||
const built=message.buildhtml(next);
|
const built=message.buildhtml(next);
|
||||||
|
|
|
@ -18,6 +18,7 @@ class dirrect extends guild{
|
||||||
this.channelids[temp.id]=temp;
|
this.channelids[temp.id]=temp;
|
||||||
}
|
}
|
||||||
this.headchannels=this.channels;
|
this.headchannels=this.channels;
|
||||||
|
this.mentions=0;
|
||||||
}
|
}
|
||||||
createChannelpac(JSON){
|
createChannelpac(JSON){
|
||||||
const thischannel=new group(JSON,owner);
|
const thischannel=new group(JSON,owner);
|
||||||
|
@ -44,6 +45,11 @@ class dirrect extends guild{
|
||||||
isAdmin(){
|
isAdmin(){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
unreaddms(){
|
||||||
|
for(const thing of this.channels){
|
||||||
|
thing.unreads();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
class group extends channel{
|
class group extends channel{
|
||||||
constructor(JSON,owner){
|
constructor(JSON,owner){
|
||||||
|
@ -91,7 +97,7 @@ class group extends channel{
|
||||||
messageCreate(messagep,focus){
|
messageCreate(messagep,focus){
|
||||||
const messagez=new cmessage(messagep.d);
|
const messagez=new cmessage(messagep.d);
|
||||||
this.lastmessageid=messagez.id;
|
this.lastmessageid=messagez.id;
|
||||||
if(messagez.user===thisuser.user){
|
if(messagez.author===thisuser.user){
|
||||||
this.lastreadmessageid=messagez.id;
|
this.lastreadmessageid=messagez.id;
|
||||||
}
|
}
|
||||||
this.messages.unshift(messagez);
|
this.messages.unshift(messagez);
|
||||||
|
@ -116,5 +122,42 @@ class group extends channel{
|
||||||
console.log(thing.myinfo,this,thing.myinfo===this);
|
console.log(thing.myinfo,this,thing.myinfo===this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.unreads();
|
||||||
|
}
|
||||||
|
unreads(){
|
||||||
|
const sentdms=document.getElementById("sentdms");
|
||||||
|
let current=null;
|
||||||
|
for(const thing of sentdms.children){
|
||||||
|
console.log(thing.all)
|
||||||
|
if(thing.all===this){
|
||||||
|
current=thing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(current,this.hasunreads);
|
||||||
|
if(this.hasunreads){
|
||||||
|
if(current){current.noti.innerText=this.mentions;return;}
|
||||||
|
const div=document.createElement("div");
|
||||||
|
div.classList.add("servernoti");
|
||||||
|
const noti=document.createElement("div");
|
||||||
|
noti.classList.add("unread","notiunread","pinged");
|
||||||
|
noti.innerText=this.mentions;
|
||||||
|
div.noti=noti;
|
||||||
|
div.append(noti)
|
||||||
|
const buildpfp=this.user.buildpfp();
|
||||||
|
div.all=this;
|
||||||
|
buildpfp.classList.add("mentioned");
|
||||||
|
console.log(this);
|
||||||
|
div.append(buildpfp)
|
||||||
|
sentdms.append(div);
|
||||||
|
div.onclick=function(){
|
||||||
|
this.all.owner.loadGuild();
|
||||||
|
this.all.getHTML();
|
||||||
|
}
|
||||||
|
}else if(current){
|
||||||
|
console.log("remove")
|
||||||
|
current.remove();
|
||||||
|
}else{
|
||||||
|
console.log(sentdms.children)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,6 +110,7 @@ class guild{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(read);
|
console.log(read);
|
||||||
|
if(!html){return;}
|
||||||
if(read){
|
if(read){
|
||||||
html.children[0].classList.remove("notiunread");
|
html.children[0].classList.remove("notiunread");
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -651,11 +651,15 @@ document.getElementById("messagecontainer").addEventListener("scroll",(e)=>{
|
||||||
const messagecontainer=document.getElementById("messagecontainer")
|
const messagecontainer=document.getElementById("messagecontainer")
|
||||||
if(messagecontainer.scrollTop<2000){
|
if(messagecontainer.scrollTop<2000){
|
||||||
if(!triggered){
|
if(!triggered){
|
||||||
thisuser.lookingguild.prevchannel.grabmoremessages();
|
thisuser.lookingguild.prevchannel.grabmoremessages().then(()=>{
|
||||||
|
triggered=false;
|
||||||
|
if(messagecontainer.scrollTop===0){
|
||||||
|
messagecontainer.scrollTop=1;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
triggered=true;
|
triggered=true;
|
||||||
}else{
|
}else{
|
||||||
triggered=false;
|
|
||||||
if(Math.abs(messagecontainer.scrollHeight-messagecontainer.scrollTop-messagecontainer.clientHeight) < 3){
|
if(Math.abs(messagecontainer.scrollHeight-messagecontainer.scrollTop-messagecontainer.clientHeight) < 3){
|
||||||
thisuser.lookingguild.prevchannel.readbottom();
|
thisuser.lookingguild.prevchannel.readbottom();
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ class localuser{
|
||||||
this.typing=[];
|
this.typing=[];
|
||||||
}
|
}
|
||||||
resolveGuildidFromChannelID(ID){
|
resolveGuildidFromChannelID(ID){
|
||||||
const resolve=this.guilds.find(guild => guild.channelids[ID])
|
let resolve=this.guilds.find(guild => guild.channelids[ID])
|
||||||
resolve??=undefined;
|
resolve??=undefined;
|
||||||
return resolve;
|
return resolve;
|
||||||
}
|
}
|
||||||
|
@ -98,11 +98,17 @@ class localuser{
|
||||||
this.all.loadGuild();
|
this.all.loadGuild();
|
||||||
this.all.loadChannel();
|
this.all.loadChannel();
|
||||||
}
|
}
|
||||||
|
const sentdms=document.createElement("div");
|
||||||
|
sentdms.classList.add("sentdms");
|
||||||
|
serverlist.append(sentdms);
|
||||||
|
sentdms.id="sentdms";
|
||||||
|
|
||||||
const br=document.createElement("hr")
|
const br=document.createElement("hr")
|
||||||
br.classList.add("lightbr")
|
br.classList.add("lightbr");
|
||||||
serverlist.appendChild(br)
|
serverlist.appendChild(br)
|
||||||
for(const thing of this.guilds){
|
for(const thing of this.guilds){
|
||||||
if(thing instanceof dirrect){
|
if(thing instanceof dirrect){
|
||||||
|
thing.unreaddms();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const divy=document.createElement("div");
|
const divy=document.createElement("div");
|
||||||
|
@ -151,7 +157,7 @@ class localuser{
|
||||||
console.log(this.guildhtml)
|
console.log(this.guildhtml)
|
||||||
for(const thing of this.guilds){
|
for(const thing of this.guilds){
|
||||||
if(thing.id==="@me"){continue;}
|
if(thing.id==="@me"){continue;}
|
||||||
thing.unreads(this.guildhtml[thing.id])
|
thing.unreads(this.guildhtml[thing.id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
typeingStart(typing){
|
typeingStart(typing){
|
||||||
|
|
|
@ -4,6 +4,7 @@ class cmessage{
|
||||||
this[thing]=messagejson[thing];
|
this[thing]=messagejson[thing];
|
||||||
}
|
}
|
||||||
this.author=new user(this.author);
|
this.author=new user(this.author);
|
||||||
|
console.log(this.type)
|
||||||
}
|
}
|
||||||
messageevents(obj){
|
messageevents(obj){
|
||||||
obj.classList.add("messagediv")
|
obj.classList.add("messagediv")
|
||||||
|
@ -16,6 +17,7 @@ class cmessage{
|
||||||
//premessage??=messages.lastChild;
|
//premessage??=messages.lastChild;
|
||||||
const build = document.createElement('table');
|
const build = document.createElement('table');
|
||||||
const div=document.createElement("div");
|
const div=document.createElement("div");
|
||||||
|
|
||||||
if(this.message_reference){
|
if(this.message_reference){
|
||||||
const replyline=document.createElement("div");
|
const replyline=document.createElement("div");
|
||||||
const line=document.createElement("hr");
|
const line=document.createElement("hr");
|
||||||
|
@ -50,9 +52,10 @@ class cmessage{
|
||||||
this.messageevents(div);
|
this.messageevents(div);
|
||||||
messagelist.push(div)
|
messagelist.push(div)
|
||||||
build.classList.add("message");
|
build.classList.add("message");
|
||||||
if(this.content!=""||this.attachments.length!=0){
|
div.appendChild(build);
|
||||||
|
if({0:true,19:true}[this.type]||this.attachments.length!=0){
|
||||||
const pfpRow = document.createElement('th');
|
const pfpRow = document.createElement('th');
|
||||||
div.appendChild(build)
|
|
||||||
let pfpparent, current
|
let pfpparent, current
|
||||||
if(premessage!=null){
|
if(premessage!=null){
|
||||||
pfpparent=premessage.pfpparent;
|
pfpparent=premessage.pfpparent;
|
||||||
|
@ -122,7 +125,8 @@ class cmessage{
|
||||||
div.appendChild(attatch)
|
div.appendChild(attatch)
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
}else{
|
}else if(this.type===7){
|
||||||
|
|
||||||
const text=document.createElement("th");
|
const text=document.createElement("th");
|
||||||
|
|
||||||
const texttxt=document.createElement("table");
|
const texttxt=document.createElement("table");
|
||||||
|
@ -133,9 +137,15 @@ class cmessage{
|
||||||
div.txt=messaged;
|
div.txt=messaged;
|
||||||
messaged.innerText="welcome: "+this.author.username;
|
messaged.innerText="welcome: "+this.author.username;
|
||||||
const messagedwrap=document.createElement("tr")
|
const messagedwrap=document.createElement("tr")
|
||||||
messagedwrap.appendChild(messaged)
|
messagedwrap.appendChild(messaged);
|
||||||
texttxt.appendChild(messagedwrap)
|
|
||||||
|
|
||||||
|
const time=document.createElement("span");
|
||||||
|
time.innerText=" "+formatTime(new Date(this.timestamp));
|
||||||
|
time.classList.add("timestamp");
|
||||||
|
messagedwrap.append(time);
|
||||||
|
|
||||||
|
texttxt.appendChild(messagedwrap)
|
||||||
|
console.log(div)
|
||||||
}
|
}
|
||||||
div.userid=this.author.id;
|
div.userid=this.author.id;
|
||||||
div.all=this;
|
div.all=this;
|
||||||
|
@ -162,6 +172,6 @@ function formatTime(date) {
|
||||||
} else if (isYesterday) {
|
} else if (isYesterday) {
|
||||||
return `Yesterday at ${formatTime(date)}`;
|
return `Yesterday at ${formatTime(date)}`;
|
||||||
} else {
|
} else {
|
||||||
return date.toLocaleDateString();
|
return `${date.toLocaleDateString()} at ${formatTime(date)}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -594,11 +594,12 @@ span{
|
||||||
}
|
}
|
||||||
|
|
||||||
.unread{
|
.unread{
|
||||||
|
aspect-ratio : 1 / 1;
|
||||||
position:absolute;
|
position:absolute;
|
||||||
background:white;
|
background:white;
|
||||||
height:.075in;
|
height:.075in;
|
||||||
width:.075in;
|
width:.075in;
|
||||||
transition:transform .2s;
|
transition:transform .2s,background .2s,height .2s,width .2s;
|
||||||
transform:translate(-.20in,.2in);
|
transform:translate(-.20in,.2in);
|
||||||
z-index:10;
|
z-index:10;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
|
@ -609,6 +610,17 @@ span{
|
||||||
.notiunread{
|
.notiunread{
|
||||||
transform:translate(0in,.2in);
|
transform:translate(0in,.2in);
|
||||||
}
|
}
|
||||||
|
.pinged{
|
||||||
|
aspect-ratio : 1 / 1;
|
||||||
|
transform:translate(0in,.4in);
|
||||||
|
background:red;
|
||||||
|
height:.15in;
|
||||||
|
width:.15in;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
.cunread{
|
.cunread{
|
||||||
box-shadow: inset .024in 0 white;
|
box-shadow: inset .024in 0 white;
|
||||||
}
|
}
|
||||||
|
.servernoti{
|
||||||
|
position:relative;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue