PMHandler now tracks unread messages and lights pm icon to notify user.

This commit is contained in:
rainbow napkin 2025-10-06 04:48:17 -04:00
parent 2feea72694
commit 64f9d713da
3 changed files with 92 additions and 15 deletions

View file

@ -32,10 +32,23 @@ class pmPanel extends panelObj{
*/
this.activeSesh = "";
/**
* Random UUID to identify the panel with the pmHandler
*/
this.uuid = crypto.randomUUID();
//Tell PMHandler to start tracking this panel
this.client.pmHandler.panelList.set(this.uuid, null);
this.defineListeners();
}
closer(){
//Tell PMHandler to start tracking this panel
this.client.pmHandler.panelList.delete(this.uuid);
//Run derived closer
super.closer();
}
docSwitch(){
@ -146,6 +159,9 @@ class pmPanel extends panelObj{
//Set the first one as active
this.activeSesh = seshList[0][1].id;
//Tell PMHandler what sesh we have open for notification reasons
this.client.pmHandler.readSesh(this.uuid, this.activeSesh);
}
//For each session tracked by the pmHandler
@ -202,6 +218,9 @@ class pmPanel extends panelObj{
//Set new sesh as active sesh
event.target.classList.add('positive');
//Tell PMHandler what sesh we have open for notification reasons
this.client.pmHandler.readSesh(this.uuid, this.activeSesh);
//Re-render message buffer
this.renderMessages();
}
@ -296,18 +315,6 @@ class startSeshPopup{
startSesh(event){
//If we clicked or hit enter
if(event.key == null || event.key == "Enter"){
/*
//Cook a new sesh from
const newSesh = new pmSesh({
//Split usernames by space
sender: this.client.user.user,
recipients: this.usernamePrompt.value.split(" ")
});
//Pop new sesh into pmHandler
this.client.pmHandler.seshList.set(newSesh.id, newSesh);
*/
//Send message out to server
this.client.pmSocket.emit("pm", {
recipients: this.usernamePrompt.value.split(" "),