Skip to content

Commit

Permalink
Merge pull request #3 from Alt791350/main
Browse files Browse the repository at this point in the history
Added a global mute option
  • Loading branch information
v42-Josh authored Nov 16, 2023
2 parents 8475192 + a6f8092 commit 4008b66
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
7 changes: 7 additions & 0 deletions client/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 3 additions & 1 deletion config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = {
Expand Down
11 changes: 10 additions & 1 deletion html/assets/js/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const notifications = document.querySelector(".notifications");

let globalMute = false

const alerts = {};

const removeToast = (toast) => {
Expand All @@ -14,7 +16,7 @@ const createToast = (id, details, notify) => {
sound.volume = notify['volume'];

function playSound() {
if (!notify['mute']) {
if (!globalMute && !notify['mute']) {
sound.play()
}
}
Expand Down Expand Up @@ -81,8 +83,15 @@ window.addEventListener('message', function (event) {
case 'notify':
createToast(event.data.type, event.data, event.data.details)
break;
case 'setGlobalMute':
globalMute = (event.data.globalMute === true)
break;
case 'testNotify':
testNotification(event.data.type, event.data, event.data.details);
break
}
});

$(() => {
$.post('https://v42-notify/nui-ready')
})

0 comments on commit 4008b66

Please sign in to comment.