diff --git a/gui/main.js b/gui/main.js index b3a0119e..566453de 100644 --- a/gui/main.js +++ b/gui/main.js @@ -100,7 +100,8 @@ const configDefaultSettings = "max_retry_attempts" : 5, \ "enable_auto_retry" : "False", \ "tx_delay" : 0, \ - "auto_start": 0 \ + "auto_start": 0, \ + "notification": 1 \ }'; if (!fs.existsSync(configPath)) { diff --git a/gui/preload-chat.js b/gui/preload-chat.js index 4f72dd7e..56ef144e 100644 --- a/gui/preload-chat.js +++ b/gui/preload-chat.js @@ -1274,7 +1274,10 @@ var TimeDifference = (new Date().getTime()/1000) - obj.timestamp if (config.enable_auto_retry.toUpperCase() == "TRUE") { checkForWaitingMessages(obj.dxcallsign); } - + if (obj.new == 1) + { + showOsPopUp("Ping from " + obj.dxcallsign,"You've been ping'd!"); + } var new_message = `

snr: ${obj.snr} - ${timestamp}

@@ -1325,6 +1328,11 @@ var TimeDifference = (new Date().getTime()/1000) - obj.timestamp var message_html = obj.msg.replaceAll(/\n/g, "
"); if (obj.type == "received") { + if (obj.new == 1) + { + showOsPopUp("Message received from " + obj.dxcallsign,obj.msg); + } + var new_message = `
@@ -2783,6 +2791,26 @@ function checkForWaitingMessages(dxcall) { }); } +function checkForWaitingMessages() +{ + var newmsgs; + db.find({ + selector: { + new: {$eq: 1}, + }, limit:1, + }) + .then(function (result) { + if (result.docs.length >0) + newmsgs=true; + else + newmsgs=false; + //console.log ("New messages count to clear for " + dxcall + ": " + result.docs.length) + }) + .catch(function (err) { + console.log(err); + }); + return newmsgs; +} function clearUnreadMessages(dxcall) { //console.log(dxcall); @@ -2806,4 +2834,13 @@ function clearUnreadMessages(dxcall) { .catch(function (err) { console.log(err); }); +} + +//Have the operating system show a notification popup +function showOsPopUp(title, message) +{ + if (config.notification == 0) return; + const NOTIFICATION_TITLE = title; + const NOTIFICATION_BODY = message; + new Notification(NOTIFICATION_TITLE, { body: NOTIFICATION_BODY }); } \ No newline at end of file diff --git a/gui/preload-main.js b/gui/preload-main.js index b11eac5b..24a72ed7 100644 --- a/gui/preload-main.js +++ b/gui/preload-main.js @@ -390,6 +390,12 @@ window.addEventListener("DOMContentLoaded", () => { document.getElementById("AutoStartSwitch").checked = false; } + if (config.notification == 1) { + document.getElementById("NotificationSwitch").checked = true; + } else { + document.getElementById("NotificationSwitch").checked = false; + } + // theme selector changeGuiDesign(config.theme); @@ -1213,6 +1219,17 @@ window.addEventListener("DOMContentLoaded", () => { FD.saveConfig(config, configPath); }); + //Handle change of Notification settings + document.getElementById("NotificationSwitch").addEventListener("click", () => { + if (document.getElementById("NotificationSwitch").checked == true) { + config.notification = 1; + } else { + config.notification = 0; + } + //fs.writeFileSync(configPath, JSON.stringify(config, null, 2)); + FD.saveConfig(config, configPath); + }); + // enable fsk Switch clicked document.getElementById("fskModeSwitch").addEventListener("click", () => { if (document.getElementById("fskModeSwitch").checked == true) { @@ -3072,7 +3089,7 @@ ipcRenderer.on("action-show-cq-toast-received", (event, data) => { let dxcallsign = data["data"][0]["dxcallsign"]; let dxgrid = data["data"][0]["dxgrid"]; let content = `cq from ${dxcallsign} (${dxgrid})`; - + showOsPopUp("CQ from " + dxcallsign,"Say hello!"); displayToast( (type = "success"), (icon = "bi-broadcast"), @@ -3759,4 +3776,13 @@ function autostart_tnc() { //Now start TNC document.getElementById("startTNC").click(); } +} + +//Have the operating system show a notification popup +function showOsPopUp(title, message) +{ + if (config.notification == 0) return; + const NOTIFICATION_TITLE = title; + const NOTIFICATION_BODY = message; + new Notification(NOTIFICATION_TITLE, { body: NOTIFICATION_BODY }); } \ No newline at end of file diff --git a/gui/src/index.html b/gui/src/index.html index eff74b0d..ddd8137b 100644 --- a/gui/src/index.html +++ b/gui/src/index.html @@ -2907,6 +2907,23 @@
+
+ + +