From b708569ff66e2381490e09ae9464a1dd55ba4d82 Mon Sep 17 00:00:00 2001
From: Linventif <gregoire.becue@proton.me>
Date: Fri, 28 Jun 2024 19:16:07 +0000
Subject: [PATCH] add: default value for WS and API fqdn

---
 lua/gmod_integration/client/cl_gui_admin.lua | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lua/gmod_integration/client/cl_gui_admin.lua b/lua/gmod_integration/client/cl_gui_admin.lua
index 5ac2b76..4eab47f 100644
--- a/lua/gmod_integration/client/cl_gui_admin.lua
+++ b/lua/gmod_integration/client/cl_gui_admin.lua
@@ -233,7 +233,10 @@ local possibleConfig = {
         ["value"] = function(setting, value)
             return value
         end,
+        ["resetIfEmpty"] = true,
+        ["defaultValue"] = "ws.gmod-integration.com",
         ["onEdit"] = function(setting, value)
+            if (!value || value == "") then return end
             saveConfig(setting, value)
         end,
         ["onEditDelay"] = 0.5,
@@ -244,10 +247,13 @@ local possibleConfig = {
         ["label"] = "API FQDN",
         ["description"] = "API FQDN that will be used for the API connection.",
         ["type"] = "textEntry",
+        ["resetIfEmpty"] = true,
+        ["defaultValue"] = "ws.gmod-integration.com",
         ["value"] = function(setting, value)
             return value
         end,
         ["onEdit"] = function(setting, value)
+            if (!value || value == "") then return end
             saveConfig(setting, value)
         end,
         ["onEditDelay"] = 0.5,
@@ -441,7 +447,13 @@ function gmInte.openConfigMenu(data)
                     end
                 end
                 local isLastID = 0
+                local initialValue = value
                 input.OnChange = function(self)
+                    if (self:GetValue() == initialValue) then return end
+                    if (actualConfig.resetIfEmpty && self:GetValue() == "" && actualConfig.defaultValue) then
+                        self:SetText(actualConfig.defaultValue)
+                        return
+                    end
                     isLastID = isLastID + 1
                     local isLocalLastID = isLastID
                     timer.Simple(actualConfig.onEditDelay || 0.5, function()