Skip to content

Commit

Permalink
Allows TSU function to not have to return true when a state was changed
Browse files Browse the repository at this point in the history
This require usage of allstates' Update/Remove/RemoveAll
  • Loading branch information
mrbuds committed Jun 28, 2024
1 parent b249b70 commit 3b04d7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion WeakAuras/GenericTrigger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -639,9 +639,10 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2
else
ok, returnValue = xpcall(data.triggerFunc, errorHandler, allStates, event, arg1, arg2, ...);
end
if (ok and returnValue) then
if (ok and (returnValue or (returnValue ~= false and allStates.__changed))) then
updateTriggerState = true;
end
allStates.__changed = nil
for key, state in pairs(allStates) do
if (type(state) ~= "table") then
errorHandler(string.format(L["All States table contains a non table at key: '%s'."], key))
Expand Down
6 changes: 6 additions & 0 deletions WeakAuras/TSUHelpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ local remove = function(states, key)
if state then
state.show = false
state.changed = true
states.__changed = true
changed = true
end
return changed
Expand All @@ -36,6 +37,9 @@ local removeAll = function(states)
state.changed = true
changed = true
end
if changed then
states.__changed = true
end
return changed
end

Expand Down Expand Up @@ -65,6 +69,7 @@ local update = function(states, key, newState)
changed = recurseUpdate(state, newState)
if changed then
state.changed = true
states.__changed = true
end
end
return changed
Expand All @@ -74,6 +79,7 @@ end
local create = function(states, key, newState)
states[key] = newState
states[key].changed = true
states.__changed = true
fixMissingFields(states[key])
return true
end
Expand Down

0 comments on commit 3b04d7a

Please sign in to comment.