diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-12-30 19:59:38 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-12-30 19:59:38 +0800 |
commit | 12967640cb2c3a6720b3e1df3673336df995a590 (patch) | |
tree | 9c2f4d3672528f1ec1c350ccf0ac75e1fe9e72ae /script/service/telemetry.lua | |
parent | 76af92ca93ff4c9bf4b6fc62bbc49481a17ea044 (diff) | |
download | lua-language-server-12967640cb2c3a6720b3e1df3673336df995a590.zip |
update
Diffstat (limited to 'script/service/telemetry.lua')
-rw-r--r-- | script/service/telemetry.lua | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/script/service/telemetry.lua b/script/service/telemetry.lua index 93e10487..3093d49f 100644 --- a/script/service/telemetry.lua +++ b/script/service/telemetry.lua @@ -72,9 +72,12 @@ local function pushErrorLog(link) )) end +local validMap = {} +local isValid = false + timer.wait(5, function () timer.loop(300, function () - if not config.get(uri, 'Lua.telemetry.enable') then + if not isValid then return end local suc, link = pcall(net.connect, 'tcp', 'moe-moe.love', 11577) @@ -93,7 +96,7 @@ timer.wait(5, function () end end)() timer.loop(1, function () - if not config.get(uri, 'Lua.telemetry.enable') then + if not isValid then return end net.update() @@ -102,8 +105,26 @@ end) local m = {} -function m.updateConfig(uri) - if config.get(uri, 'Lua.telemetry.enable') ~= nil then +function m.updateConfig(uri, value) + validMap[uri] = value + isValid = config.get(nil, 'Lua.telemetry.enable') + if isValid == false then + return + end + -- one false, all false + for _, v in pairs(validMap) do + if v == false then + isValid = false + return + end + end + for _, v in pairs(validMap) do + if v == true then + isValid = true + break + end + end + if isValid ~= nil then return end if m.hasShowedMessage then @@ -151,9 +172,9 @@ function m.updateConfig(uri) end) end -config.watch(function (uri, key) +config.watch(function (uri, key, value) if key == 'Lua.telemetry.enable' then - m.updateConfig(uri) + m.updateConfig(uri, value) end end) |