getMostRecentAvailableActions
Definition
-- @/lua/ge/extensions/core/quickAccess.lua:1932
local function getMostRecentAvailableActions(category, limit, dynamicItems)
if limit == nil or limit == 0 then
return {}
end
local skipActions = {}
for _, item in ipairs(dynamicItems or {}) do
if item.dynamicSlotSetting.mode == "uniqueAction" then
table.insert(skipActions, {uniqueID = item.dynamicSlotSetting.uniqueID, level = item.dynamicSlotSetting.level})
end
end
if dynamicItems and not limit then
limit = #dynamicItems - #skipActions
end
-- Default limit if not provided
limit = limit or maxRecentActionsLimits[category] or 4
-- Copy the actions from the category
local actions = {}
for i, action in ipairs(recentActions[category] or {}) do
action._sortIdx = i
table.insert(actions, action)
end
-- Sort by timestamp (most recent first)
table.sort(actions, function(a, b)
return (a.timestamp or 0) > (b.timestamp or 0)
end)
-- Filter to available actions and limit the count
local result = {}
for _, action in ipairs(actions) do
-- Check if action is available (exists in menuTreeCopy)
local actionInfo = getActionInfo(action.level, action.uniqueID)
if actionInfo then
-- compare the action with the skipActions
local compare = {uniqueID = action.uniqueID, level = action.level}
if actionInfo.originalActionInfo then
compare = {uniqueID = actionInfo.originalActionInfo.uniqueID, level = actionInfo.originalActionInfo.level}
end
local skip = false
for _, skipAction in ipairs(skipActions) do
if (skipAction.uniqueID == compare.uniqueID and skipAction.level == compare.level) then
skip = true
break
end
end
if not skip and #result < limit then
table.insert(result, action)
end
-- Stop once we have enough actions
if #result >= limit then
break
end
end
end
table.sort(result, function(a, b)
return a._sortIdx < b._sortIdx
end)
return result
end
Callers
@/lua/ge/extensions/core/quickAccess.lua
end
local recentActions = M.getMostRecentAvailableActions("all", 3)
table.sort(recentActions, function(a, b) return a.timestamp > b.timestamp end)
local recentActions = getMostRecentAvailableActions("all", recentActionItems, dynamicItems)
local recentActionsIdx = 1
--[[
local recent = getMostRecentAvailableActions("all", maxRecentActionsLimits.all)
dump("All")