fixes issue where saving and loading would cause an error when the display is not enabled, minor code cleanup
This commit is contained in:
parent
c678537581
commit
1ef635fcfe
@ -26,6 +26,7 @@ function onLoad(saved_data)
|
||||
local loaded_data = JSON.decode(saved_data)
|
||||
display = not loaded_data.saved_display
|
||||
|
||||
self.clearButtons()
|
||||
toggleCounter()
|
||||
end
|
||||
|
||||
@ -33,9 +34,7 @@ function onLoad(saved_data)
|
||||
end
|
||||
|
||||
function onSave()
|
||||
local data_to_save = {saved_display = display}
|
||||
local saved_data = JSON.encode(data_to_save)
|
||||
return saved_data
|
||||
return JSON.encode({saved_display = display})
|
||||
end
|
||||
|
||||
function toggleCounter()
|
||||
@ -45,7 +44,10 @@ function toggleCounter()
|
||||
createUpdateDisplay()
|
||||
loopId = Wait.time(|| createUpdateDisplay(), 2, -1)
|
||||
else
|
||||
Wait.stop(loopId)
|
||||
if loopId ~= nil then
|
||||
Wait.stop(loopId)
|
||||
end
|
||||
|
||||
self.clearButtons()
|
||||
loopId = nil
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user