Messages now play notification sounds.
This commit is contained in:
parent
976e157cf1
commit
e85fb18ce5
|
|
@ -37,6 +37,11 @@ class pmPanel extends panelObj{
|
||||||
*/
|
*/
|
||||||
this.uuid = crypto.randomUUID();
|
this.uuid = crypto.randomUUID();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PM TX Sound
|
||||||
|
*/
|
||||||
|
this.txSound = '/nonfree/imsend.ogg';
|
||||||
|
|
||||||
//Tell PMHandler to start tracking this panel
|
//Tell PMHandler to start tracking this panel
|
||||||
this.client.pmHandler.panelList.set(this.uuid, null);
|
this.client.pmHandler.panelList.set(this.uuid, null);
|
||||||
|
|
||||||
|
|
@ -131,6 +136,10 @@ class pmPanel extends panelObj{
|
||||||
|
|
||||||
//Send message out to server
|
//Send message out to server
|
||||||
this.client.pmSocket.emit("pm", preprocessedMessage);
|
this.client.pmSocket.emit("pm", preprocessedMessage);
|
||||||
|
|
||||||
|
if(localStorage.getItem('txPMSound') == 'true'){
|
||||||
|
utils.ux.playSound(this.txSound);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Clear our prompt
|
//Clear our prompt
|
||||||
|
|
@ -247,6 +256,13 @@ class pmPanel extends panelObj{
|
||||||
* @param {Object} message - Message to render
|
* @param {Object} message - Message to render
|
||||||
*/
|
*/
|
||||||
renderMessage(message){
|
renderMessage(message){
|
||||||
|
//If we have an empty message
|
||||||
|
console.log(message);
|
||||||
|
if(message.msg == null || message.msg == ''){
|
||||||
|
//BAIL!!
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Run postprocessing functions on chat message
|
//Run postprocessing functions on chat message
|
||||||
const postprocessedMessage = client.chatBox.chatPostprocessor.postprocess(message, true);
|
const postprocessedMessage = client.chatBox.chatPostprocessor.postprocess(message, true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,21 @@ class pmHandler{
|
||||||
*/
|
*/
|
||||||
this.panelList = new Map();
|
this.panelList = new Map();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PM RX Sound
|
||||||
|
*/
|
||||||
|
this.rxSound = '/nonfree/imrecv.ogg';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open Sesh Sound
|
||||||
|
*/
|
||||||
|
this.openSeshSound = '/nonfree/opensesh.ogg';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* End Sesh Sound
|
||||||
|
*/
|
||||||
|
this.endSeshSound = '/nonfree/closesesh.ogg';
|
||||||
|
|
||||||
this.defineListeners();
|
this.defineListeners();
|
||||||
this.setupInput();
|
this.setupInput();
|
||||||
}
|
}
|
||||||
|
|
@ -118,17 +133,30 @@ class pmHandler{
|
||||||
//Generate a new sesh
|
//Generate a new sesh
|
||||||
const sesh = new pmSesh(data, client);
|
const sesh = new pmSesh(data, client);
|
||||||
|
|
||||||
|
|
||||||
//Notify user of new message/sesh
|
//Notify user of new message/sesh
|
||||||
this.handlePing();
|
this.handlePing((data.msg == '' || data.msg == null));
|
||||||
|
|
||||||
//Add it to the sesh list
|
//Add it to the sesh list
|
||||||
this.seshList.set(sesh.id, sesh);
|
this.seshList.set(sesh.id, sesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//If this isn't an empty message (sesh-starter), and PM's always make noise, and we didn't send the message
|
||||||
|
if(data.msg != '' && data.msg != null && localStorage.getItem('rxPMSound') == 'all' && data.user != this.client.user.user){
|
||||||
|
//make sum noize!
|
||||||
|
utils.ux.playSound(this.rxSound);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePing(){
|
handlePing(newSesh = false){
|
||||||
//Light up the icon
|
//Light up the icon
|
||||||
this.pmIcon.classList.add('positive-low');
|
this.pmIcon.classList.add('positive-low');
|
||||||
|
|
||||||
|
if(newSesh && (localStorage.getItem('newSeshSound') == 'true')){
|
||||||
|
utils.ux.playSound(this.openSeshSound);
|
||||||
|
}else if(localStorage.getItem('rxPMSound') == 'unread'){
|
||||||
|
utils.ux.playSound(this.rxSound);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handles UI updates after reading all messages
|
//Handles UI updates after reading all messages
|
||||||
|
|
|
||||||
|
|
@ -297,6 +297,11 @@ class canopyUXUtils{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
playSound(url){
|
||||||
|
const audio = new Audio(url);
|
||||||
|
audio.play();
|
||||||
|
}
|
||||||
|
|
||||||
newTableRow(cellContent){
|
newTableRow(cellContent){
|
||||||
//Create an empty table row to hold the cells
|
//Create an empty table row to hold the cells
|
||||||
const entryRow = document.createElement('tr');
|
const entryRow = document.createElement('tr');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue