From 0ced3f594c06e4db3bb67ca2ae7ba85361ab7695 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Tue, 10 Dec 2024 11:44:56 -0600 Subject: [PATCH] bug fix --- src/webpage/channel.ts | 5 ++++- src/webpage/message.ts | 6 ++++++ src/webpage/user.ts | 11 ++++++++++- translations/en.json | 4 +++- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/webpage/channel.ts b/src/webpage/channel.ts index 779ade6..3031b08 100644 --- a/src/webpage/channel.ts +++ b/src/webpage/channel.ts @@ -761,7 +761,7 @@ class Channel extends SnowFlake{ typebox.classList.remove("typeboxreplying"); } } - async getmessage(id: string): Promise{ + async getmessage(id: string): Promise{ const message = this.messages.get(id); if(message){ return message; @@ -771,6 +771,9 @@ class Channel extends SnowFlake{ { headers: this.headers } ); const json = await gety.json(); + if(json.length===0){ + return undefined; + } return new Message(json[0], this); } } diff --git a/src/webpage/message.ts b/src/webpage/message.ts index 5517a93..540ef40 100644 --- a/src/webpage/message.ts +++ b/src/webpage/message.ts @@ -439,6 +439,12 @@ class Message extends SnowFlake{ replyline.classList.add("flexltr","replyflex"); // TODO: Fix this this.channel.getmessage(this.message_reference.message_id).then(message=>{ + if(!message){ + minipfp.remove(); + username.textContent=I18n.getTranslation("message.deleted"); + username.classList.remove("username"); + return; + } if(message.author.relationshipType === 2){ username.textContent = "Blocked user"; return; diff --git a/src/webpage/user.ts b/src/webpage/user.ts index 003fe4a..3126ebd 100644 --- a/src/webpage/user.ts +++ b/src/webpage/user.ts @@ -164,7 +164,12 @@ class User extends SnowFlake{ this.contextmenu.addbutton(()=>I18n.getTranslation("user.friendReq"), function(this: User){ this.changeRelationship(1); },null,function(){ - return this.relationshipType===0; + return this.relationshipType===0||this.relationshipType===3; + }); + this.contextmenu.addbutton(()=>I18n.getTranslation("friends.removeFriend"), function(this: User){ + this.changeRelationship(0); + },null,function(){ + return this.relationshipType===1; }); this.contextmenu.addbutton( ()=>I18n.getTranslation("user.kick"), @@ -363,11 +368,15 @@ class User extends SnowFlake{ } if(member){ member.bind(html); + }else{ + User.contextmenu.bindContextmenu(html, this, undefined); } }) .catch(err=>{ console.log(err); }); + }else{ + User.contextmenu.bindContextmenu(html, this, undefined); } if(guild){ this.profileclick(html, guild); diff --git a/translations/en.json b/translations/en.json index 3bf4cde..1a16dee 100644 --- a/translations/en.json +++ b/translations/en.json @@ -322,7 +322,8 @@ "reactionAdd":"Add reaction", "delete":"Delete message", "edit":"Edit message", - "edited":"(edited)" + "edited":"(edited)", + "deleted":"Deleted message" }, "instanceStats":{ "name":"Instance stats: $1", @@ -364,6 +365,7 @@ "blocked":"Blocked", "blockedusers":"Blocked Users:", "addfriend":"Add Friend", + "removeFriend":"Remove Friend", "addfriendpromt":"Add friends by username:", "notfound":"User not found", "discnotfound":"Discriminator not found",