giving some love to DMs
This commit is contained in:
parent
384b666ac2
commit
515a11f110
2 changed files with 75 additions and 1 deletions
|
@ -4,7 +4,9 @@ import { Message } from "./message.js";
|
||||||
import { User } from "./user.js";
|
import { User } from "./user.js";
|
||||||
import { Permissions } from "./permissions.js";
|
import { Permissions } from "./permissions.js";
|
||||||
import { SnowFlake } from "./snowflake.js";
|
import { SnowFlake } from "./snowflake.js";
|
||||||
|
import { Contextmenu } from "./contextmenu.js";
|
||||||
class Direct extends Guild {
|
class Direct extends Guild {
|
||||||
|
channelids;
|
||||||
constructor(json, owner) {
|
constructor(json, owner) {
|
||||||
super(-1, owner, null);
|
super(-1, owner, null);
|
||||||
this.message_notifications = 0;
|
this.message_notifications = 0;
|
||||||
|
@ -35,6 +37,13 @@ class Direct extends Guild {
|
||||||
this.printServers();
|
this.printServers();
|
||||||
return thischannel;
|
return thischannel;
|
||||||
}
|
}
|
||||||
|
delChannel(json) {
|
||||||
|
const channel = this.channelids[json.id];
|
||||||
|
super.delChannel(json);
|
||||||
|
if (channel) {
|
||||||
|
channel.del();
|
||||||
|
}
|
||||||
|
}
|
||||||
giveMember(_member) {
|
giveMember(_member) {
|
||||||
console.error("not a real guild, can't give member object");
|
console.error("not a real guild, can't give member object");
|
||||||
}
|
}
|
||||||
|
@ -76,6 +85,21 @@ dmPermissions.setPermission("STREAM", 1);
|
||||||
dmPermissions.setPermission("USE_VAD", 1);
|
dmPermissions.setPermission("USE_VAD", 1);
|
||||||
class Group extends Channel {
|
class Group extends Channel {
|
||||||
user;
|
user;
|
||||||
|
static contextmenu = new Contextmenu("channel menu");
|
||||||
|
static setupcontextmenu() {
|
||||||
|
this.contextmenu.addbutton("Copy DM id", function () {
|
||||||
|
navigator.clipboard.writeText(this.id);
|
||||||
|
});
|
||||||
|
this.contextmenu.addbutton("Mark as read", function () {
|
||||||
|
this.readbottom();
|
||||||
|
});
|
||||||
|
this.contextmenu.addbutton("Close DM", function () {
|
||||||
|
this.deleteChannel();
|
||||||
|
});
|
||||||
|
this.contextmenu.addbutton("Copy user ID", function () {
|
||||||
|
navigator.clipboard.writeText(this.user.id);
|
||||||
|
});
|
||||||
|
}
|
||||||
constructor(json, owner) {
|
constructor(json, owner) {
|
||||||
super(-1, owner, json.id);
|
super(-1, owner, json.id);
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
|
@ -109,6 +133,7 @@ class Group extends Channel {
|
||||||
}
|
}
|
||||||
createguildHTML() {
|
createguildHTML() {
|
||||||
const div = document.createElement("div");
|
const div = document.createElement("div");
|
||||||
|
Group.contextmenu.bindContextmenu(div, this, undefined);
|
||||||
this.html = new WeakRef(div);
|
this.html = new WeakRef(div);
|
||||||
div.classList.add("channeleffects");
|
div.classList.add("channeleffects");
|
||||||
const myhtml = document.createElement("span");
|
const myhtml = document.createElement("span");
|
||||||
|
@ -202,6 +227,15 @@ class Group extends Channel {
|
||||||
}
|
}
|
||||||
all = new WeakRef(document.createElement("div"));
|
all = new WeakRef(document.createElement("div"));
|
||||||
noti = new WeakRef(document.createElement("div"));
|
noti = new WeakRef(document.createElement("div"));
|
||||||
|
del() {
|
||||||
|
const all = this.all.deref();
|
||||||
|
if (all) {
|
||||||
|
all.remove();
|
||||||
|
}
|
||||||
|
if (this.myhtml) {
|
||||||
|
this.myhtml.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
unreads() {
|
unreads() {
|
||||||
const sentdms = document.getElementById("sentdms"); //Need to change sometime
|
const sentdms = document.getElementById("sentdms"); //Need to change sometime
|
||||||
const current = this.all.deref();
|
const current = this.all.deref();
|
||||||
|
@ -244,3 +278,4 @@ class Group extends Channel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export { Direct, Group };
|
export { Direct, Group };
|
||||||
|
Group.setupcontextmenu();
|
||||||
|
|
|
@ -3,11 +3,13 @@ import{ Channel }from"./channel.js";
|
||||||
import{ Message }from"./message.js";
|
import{ Message }from"./message.js";
|
||||||
import{ Localuser }from"./localuser.js";
|
import{ Localuser }from"./localuser.js";
|
||||||
import{User}from"./user.js";
|
import{User}from"./user.js";
|
||||||
import{ dirrectjson, memberjson, messagejson }from"./jsontypes.js";
|
import{ channeljson, dirrectjson, memberjson, messagejson }from"./jsontypes.js";
|
||||||
import{ Permissions }from"./permissions.js";
|
import{ Permissions }from"./permissions.js";
|
||||||
import { SnowFlake } from "./snowflake.js";
|
import { SnowFlake } from "./snowflake.js";
|
||||||
|
import { Contextmenu } from "./contextmenu.js";
|
||||||
|
|
||||||
class Direct extends Guild{
|
class Direct extends Guild{
|
||||||
|
channelids:{[key:string]:Group};
|
||||||
constructor(json:dirrectjson[],owner:Localuser){
|
constructor(json:dirrectjson[],owner:Localuser){
|
||||||
super(-1,owner,null);
|
super(-1,owner,null);
|
||||||
this.message_notifications=0;
|
this.message_notifications=0;
|
||||||
|
@ -38,6 +40,13 @@ class Direct extends Guild{
|
||||||
this.printServers();
|
this.printServers();
|
||||||
return thischannel;
|
return thischannel;
|
||||||
}
|
}
|
||||||
|
delChannel(json:channeljson){
|
||||||
|
const channel=this.channelids[json.id];
|
||||||
|
super.delChannel(json);
|
||||||
|
if(channel){
|
||||||
|
channel.del();
|
||||||
|
}
|
||||||
|
}
|
||||||
giveMember(_member:memberjson){
|
giveMember(_member:memberjson){
|
||||||
console.error("not a real guild, can't give member object");
|
console.error("not a real guild, can't give member object");
|
||||||
}
|
}
|
||||||
|
@ -82,6 +91,24 @@ dmPermissions.setPermission("USE_VAD",1);
|
||||||
|
|
||||||
class Group extends Channel{
|
class Group extends Channel{
|
||||||
user:User;
|
user:User;
|
||||||
|
static contextmenu=new Contextmenu<Group,undefined>("channel menu");
|
||||||
|
static setupcontextmenu(){
|
||||||
|
this.contextmenu.addbutton("Copy DM id",function(this:Group){
|
||||||
|
navigator.clipboard.writeText(this.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.contextmenu.addbutton("Mark as read",function(this:Group){
|
||||||
|
this.readbottom();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.contextmenu.addbutton("Close DM",function(this:Group){
|
||||||
|
this.deleteChannel();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.contextmenu.addbutton("Copy user ID",function(){
|
||||||
|
navigator.clipboard.writeText(this.user.id);
|
||||||
|
})
|
||||||
|
}
|
||||||
constructor(json:dirrectjson,owner:Direct){
|
constructor(json:dirrectjson,owner:Direct){
|
||||||
super(-1,owner,json.id);
|
super(-1,owner,json.id);
|
||||||
this.owner=owner;
|
this.owner=owner;
|
||||||
|
@ -113,6 +140,7 @@ class Group extends Channel{
|
||||||
}
|
}
|
||||||
createguildHTML(){
|
createguildHTML(){
|
||||||
const div=document.createElement("div");
|
const div=document.createElement("div");
|
||||||
|
Group.contextmenu.bindContextmenu(div,this,undefined);
|
||||||
this.html=new WeakRef(div);
|
this.html=new WeakRef(div);
|
||||||
div.classList.add("channeleffects");
|
div.classList.add("channeleffects");
|
||||||
const myhtml=document.createElement("span");
|
const myhtml=document.createElement("span");
|
||||||
|
@ -123,6 +151,7 @@ class Group extends Channel{
|
||||||
div.onclick=_=>{
|
div.onclick=_=>{
|
||||||
this.getHTML();
|
this.getHTML();
|
||||||
};
|
};
|
||||||
|
|
||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
async getHTML(){
|
async getHTML(){
|
||||||
|
@ -205,6 +234,15 @@ class Group extends Channel{
|
||||||
}
|
}
|
||||||
all:WeakRef<HTMLElement>=new WeakRef(document.createElement("div"));
|
all:WeakRef<HTMLElement>=new WeakRef(document.createElement("div"));
|
||||||
noti:WeakRef<HTMLElement>=new WeakRef(document.createElement("div"));
|
noti:WeakRef<HTMLElement>=new WeakRef(document.createElement("div"));
|
||||||
|
del(){
|
||||||
|
const all=this.all.deref();
|
||||||
|
if(all){
|
||||||
|
all.remove();
|
||||||
|
}
|
||||||
|
if(this.myhtml){
|
||||||
|
this.myhtml.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
unreads(){
|
unreads(){
|
||||||
const sentdms=document.getElementById("sentdms") as HTMLDivElement;//Need to change sometime
|
const sentdms=document.getElementById("sentdms") as HTMLDivElement;//Need to change sometime
|
||||||
const current=this.all.deref();
|
const current=this.all.deref();
|
||||||
|
@ -246,3 +284,4 @@ class Group extends Channel{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export{Direct, Group};
|
export{Direct, Group};
|
||||||
|
Group.setupcontextmenu();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue