fix(esx_menu_dialog): drop the timeout id bookkeeping

With the callback checking whether a menu is still open, cancelling the
previous timers by id is no longer needed.

The table it kept them in was never emptied, so every open iterated over
every id ever created and called ClearTimeout on all of them. That is
quadratic, and clearTimeout only marks an id in xLib's CancelledTimeouts,
which is cleared when the timer fires. Ids that had already fired stayed
in there for good, in a table shared by every resource.
This commit is contained in:
Selt
2026-07-30 02:38:25 +02:00
parent e801856d1a
commit f5ed52d03b
+2 -8
View File
@@ -1,10 +1,6 @@
local Timeouts, OpenedMenus, MenuType = {}, {}, "dialog"
local OpenedMenus, MenuType = {}, "dialog"
local function openMenu(namespace, name, data)
for i = 1, #Timeouts, 1 do
ESX.ClearTimeout(Timeouts[i])
end
OpenedMenus[namespace .. "_" .. name] = true
SendNUIMessage({
@@ -14,13 +10,11 @@ local function openMenu(namespace, name, data)
data = data,
})
local timeoutId = ESX.SetTimeout(200, function()
ESX.SetTimeout(200, function()
if next(OpenedMenus) then
SetNuiFocus(true, true)
end
end)
table.insert(Timeouts, timeoutId)
end
local function closeMenu(namespace, name)