From 5d4d83031baf79e2f3e75feaae1618e6246d8ffe Mon Sep 17 00:00:00 2001 From: Alt791350 <53434978+Alt791350@users.noreply.github.com> Date: Thu, 16 Nov 2023 16:11:30 +0100 Subject: [PATCH 1/3] feat: added global mute fix: added NUI ready callback --- client/client.lua | 7 +++++++ config.lua | 4 +++- html/assets/js/app.js | 13 ++++++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/client/client.lua b/client/client.lua index bb85a4a..9f9392c 100644 --- a/client/client.lua +++ b/client/client.lua @@ -53,4 +53,11 @@ if Config.Debug then end, false) end +RegisterNUICallback('nui-ready', function() + SendNUIMessage({ + action = 'setGlobalMute', + globalMute = Config.GlobalMute + }) +end) + exports('notify', notify) diff --git a/config.lua b/config.lua index bf4d08e..9e0e9fd 100644 --- a/config.lua +++ b/config.lua @@ -2,7 +2,9 @@ Config = {} Config.DeaultNotify = 'primary'; -- Default notification (if there is no notify type given) Config.Debug = false -- Set to true is you want to enable /notify command. Usage: '/notify error'; -Config.EsxNotifcation = false --Set this to true to use ESX notifications +Config.EsxNotifcation = false --Set this to true to use ESX notifications + +Config.GlobalMute = false -- If set to true, this mutes all notifications regardless of notification settings Config.Notifications = { -- Restart your server for new notifications! ['error'] = { diff --git a/html/assets/js/app.js b/html/assets/js/app.js index 4108669..cdedc50 100644 --- a/html/assets/js/app.js +++ b/html/assets/js/app.js @@ -1,5 +1,7 @@ const notifications = document.querySelector(".notifications"); +let globalMute = false + const alerts = {}; const removeToast = (toast) => { @@ -13,8 +15,9 @@ const createToast = (id, details, notify) => { var sound = new Audio(notify['sound']); sound.volume = notify['volume']; + console.log(globalMute) function playSound() { - if (!notify['mute']) { + if (!globalMute && !notify['mute']) { sound.play() } } @@ -81,8 +84,16 @@ window.addEventListener('message', function (event) { case 'notify': createToast(event.data.type, event.data, event.data.details) break; + case 'setGlobalMute': + console.log(event.data.globalMute) + globalMute = (event.data.globalMute === true) + break; case 'testNotify': testNotification(event.data.type, event.data, event.data.details); break } }); + +$(() => { + $.post('https://v42-notify/nui-ready') +}) \ No newline at end of file From ecfc0cfef12cc143075cba709ff3035513a01f34 Mon Sep 17 00:00:00 2001 From: Alt791350 <53434978+Alt791350@users.noreply.github.com> Date: Thu, 16 Nov 2023 16:30:48 +0100 Subject: [PATCH 2/3] Update html/assets/js/app.js Co-authored-by: v42 <135979159+v42-Josh@users.noreply.github.com> --- html/assets/js/app.js | 1 - 1 file changed, 1 deletion(-) diff --git a/html/assets/js/app.js b/html/assets/js/app.js index cdedc50..4dc2e7d 100644 --- a/html/assets/js/app.js +++ b/html/assets/js/app.js @@ -85,7 +85,6 @@ window.addEventListener('message', function (event) { createToast(event.data.type, event.data, event.data.details) break; case 'setGlobalMute': - console.log(event.data.globalMute) globalMute = (event.data.globalMute === true) break; case 'testNotify': From a6f8092be3f464bb13f72bfb5ab915bbb87c5962 Mon Sep 17 00:00:00 2001 From: Alt791350 <53434978+Alt791350@users.noreply.github.com> Date: Thu, 16 Nov 2023 16:30:55 +0100 Subject: [PATCH 3/3] Update html/assets/js/app.js Co-authored-by: v42 <135979159+v42-Josh@users.noreply.github.com> --- html/assets/js/app.js | 1 - 1 file changed, 1 deletion(-) diff --git a/html/assets/js/app.js b/html/assets/js/app.js index 4dc2e7d..6d93812 100644 --- a/html/assets/js/app.js +++ b/html/assets/js/app.js @@ -15,7 +15,6 @@ const createToast = (id, details, notify) => { var sound = new Audio(notify['sound']); sound.volume = notify['volume']; - console.log(globalMute) function playSound() { if (!globalMute && !notify['mute']) { sound.play()