sharedstate: fix issue with falsy values
Setting a shared value to false would retain the old value since the logic uses lua's fake "ternary"
This commit is contained in:
parent
ebd217dcc2
commit
f6451345cd
@ -8,6 +8,10 @@ get_value, resolve_key, resolve_index
|
||||
--schema: similar to state_table, nested table only contains value
|
||||
local state_queue={}
|
||||
|
||||
local function ternary(condition, val_if_true, val_if_false)
|
||||
if condition then return val_if_true else return val_if_false end
|
||||
end
|
||||
|
||||
-- we're protecting internal variables here, i'm *that* scared of writing bad
|
||||
-- code again.
|
||||
-- this section is purely for making sure the tables are in a consistent state
|
||||
@ -90,7 +94,7 @@ do
|
||||
entry["callback"]=callback
|
||||
|
||||
else
|
||||
entry["value"]=value or entry["value"]
|
||||
entry["value"]=ternary(value ~= nil, value, entry["value"])
|
||||
callback_value(key)
|
||||
entry["callback"]=callback or entry["callback"]
|
||||
entry["old_value"]=value
|
||||
|
Loading…
x
Reference in New Issue
Block a user