improved menu stability

This commit is contained in:
Xertis 2025-01-28 23:59:24 +03:00 committed by GitHub
parent e205182da6
commit efdd0226f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -196,15 +196,30 @@ function check_dependencies(packinfo)
return return
end end
function check_deleted()
for i = 1, math.max(#packs_included, #packs_excluded) do
local pack = packs_included[i]
if pack and not table.has(packs_all, pack) then
table.remove(packs_included, i)
table.insert(rem_packs, pack)
end
pack = packs_excluded[i]
if pack and not table.has(packs_all, pack) then
table.remove(packs_excluded, i)
table.insert(rem_packs, pack)
end
end
end
function refresh() function refresh()
packs_installed = pack.get_installed() packs_installed = pack.get_installed()
packs_available = pack.get_available() packs_available = pack.get_available()
base_packs = pack.get_base_packs() base_packs = pack.get_base_packs()
packs_all = {unpack(packs_installed)} packs_all = {unpack(packs_installed)}
required = {} required = {}
for i,k in ipairs(packs_available) do
table.insert(packs_all, k) table.merge(packs_all, packs_available)
end
local packs_cur = document.packs_cur local packs_cur = document.packs_cur
local packs_add = document.packs_add local packs_add = document.packs_add
@ -260,6 +275,7 @@ function refresh()
place_pack(packs_add, packinfo, callback, string.format('reposition_func("%s")', packinfo.id)) place_pack(packs_add, packinfo, callback, string.format('reposition_func("%s")', packinfo.id))
end end
check_deleted()
apply_movements(packs_cur, packs_add) apply_movements(packs_cur, packs_add)
refresh_changes() refresh_changes()
end end