From cd0874dc6bdc7a7f8d70a960edb9964665b25999 Mon Sep 17 00:00:00 2001 From: RodericAguilar <84584545+RodericAguilar@users.noreply.github.com> Date: Mon, 28 Jul 2025 11:54:56 +0200 Subject: [PATCH] refactor(esx_notify): move sound toggle to config and apply camelCase --- [core]/esx_notify/Config.lua | 3 +++ [core]/esx_notify/Notify.lua | 4 +--- [core]/esx_notify/fxmanifest.lua | 2 +- [core]/esx_notify/nui/js/script.js | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 [core]/esx_notify/Config.lua diff --git a/[core]/esx_notify/Config.lua b/[core]/esx_notify/Config.lua new file mode 100644 index 00000000..90f6d653 --- /dev/null +++ b/[core]/esx_notify/Config.lua @@ -0,0 +1,3 @@ +Config = {} + +Config.notificationSoundEnabled = true \ No newline at end of file diff --git a/[core]/esx_notify/Notify.lua b/[core]/esx_notify/Notify.lua index f0045251..0061974e 100644 --- a/[core]/esx_notify/Notify.lua +++ b/[core]/esx_notify/Notify.lua @@ -1,7 +1,5 @@ local Debug = ESX.GetConfig().EnableDebug ----@type boolean Whether the notification sound should be played. -local NotificationSoundEnabled = true ---@param notificatonType string the notification type ---@param length number the length of the notification @@ -39,7 +37,7 @@ local function Notify(notificatonType, length, message, title) length = length or 5000, message = message or "ESX-Notify", title = title or "New Notification", - NotificationSoundEnabled = NotificationSoundEnabled + notificationSoundEnabled = Config.notificationSoundEnabled })) end diff --git a/[core]/esx_notify/fxmanifest.lua b/[core]/esx_notify/fxmanifest.lua index 55862551..39492e81 100644 --- a/[core]/esx_notify/fxmanifest.lua +++ b/[core]/esx_notify/fxmanifest.lua @@ -8,7 +8,7 @@ description 'A beautiful and simple NUI notification system for ESX' shared_script '@es_extended/imports.lua' -client_scripts { 'Notify.lua' } +client_scripts { 'Notify.lua', 'Config.lua'} ui_page 'nui/index.html' diff --git a/[core]/esx_notify/nui/js/script.js b/[core]/esx_notify/nui/js/script.js index 73902b80..1152ed14 100644 --- a/[core]/esx_notify/nui/js/script.js +++ b/[core]/esx_notify/nui/js/script.js @@ -83,7 +83,7 @@ w.addEventListener("message", (event) => { title: event.data.title || "New Notification", message: event.data.message, length: event.data.length, - NotificationSoundEnabled: event.data.NotificationSoundEnabled, + notificationSoundEnabled: event.data.notificationSoundEnabled, }) }) @@ -174,7 +174,7 @@ const notification = (data) => { width: "0%", }) - if (data.NotificationSoundEnabled) { + if (data.notificationSoundEnabled) { playNotificationSound(data.type) }