#562 delay opening guide page until loaded
This commit is contained in:
@@ -264,7 +264,8 @@ function pocket.init_nav(smem)
|
|||||||
|
|
||||||
-- open an app
|
-- open an app
|
||||||
---@param app_id POCKET_APP_ID
|
---@param app_id POCKET_APP_ID
|
||||||
function nav.open_app(app_id)
|
---@param on_loaded? function
|
||||||
|
function nav.open_app(app_id, on_loaded)
|
||||||
-- reset help return on navigating out of an app
|
-- reset help return on navigating out of an app
|
||||||
if app_id == APP_ID.ROOT then self.help_return = nil end
|
if app_id == APP_ID.ROOT then self.help_return = nil end
|
||||||
|
|
||||||
@@ -277,7 +278,7 @@ function pocket.init_nav(smem)
|
|||||||
app = self.apps[app_id]
|
app = self.apps[app_id]
|
||||||
else self.loader_return = nil end
|
else self.loader_return = nil end
|
||||||
|
|
||||||
if not app.loaded then smem.q.mq_render.push_data(MQ__RENDER_DATA.LOAD_APP, app_id) end
|
if not app.loaded then smem.q.mq_render.push_data(MQ__RENDER_DATA.LOAD_APP, { app_id, on_loaded }) end
|
||||||
|
|
||||||
self.cur_app = app_id
|
self.cur_app = app_id
|
||||||
self.pane.set_value(app_id)
|
self.pane.set_value(app_id)
|
||||||
@@ -360,10 +361,10 @@ function pocket.init_nav(smem)
|
|||||||
function nav.open_help(key)
|
function nav.open_help(key)
|
||||||
self.help_return = self.cur_app
|
self.help_return = self.cur_app
|
||||||
|
|
||||||
nav.open_app(APP_ID.GUIDE)
|
nav.open_app(APP_ID.GUIDE, function ()
|
||||||
|
local show = self.help_map[key]
|
||||||
local load = self.help_map[key]
|
if show then show() end
|
||||||
if load then load() end
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- link the help map from the guide app
|
-- link the help map from the guide app
|
||||||
|
|||||||
@@ -165,15 +165,18 @@ function threads.thread__render(smem)
|
|||||||
local cmd = msg.message ---@type queue_data
|
local cmd = msg.message ---@type queue_data
|
||||||
|
|
||||||
if cmd.key == MQ__RENDER_DATA.LOAD_APP then
|
if cmd.key == MQ__RENDER_DATA.LOAD_APP then
|
||||||
log.debug("RENDER: load app " .. cmd.val)
|
log.debug("RENDER: load app " .. cmd.val[1])
|
||||||
|
|
||||||
local draw_start = util.time_ms()
|
local draw_start = util.time_ms()
|
||||||
|
|
||||||
pkt_state.ui_ok, pkt_state.ui_error = pcall(function () nav.load_app(cmd.val) end)
|
pkt_state.ui_ok, pkt_state.ui_error = pcall(function () nav.load_app(cmd.val[1]) end)
|
||||||
if not pkt_state.ui_ok then
|
if not pkt_state.ui_ok then
|
||||||
log.fatal(util.c("RENDER: app load failed with error ", pkt_state.ui_error))
|
log.fatal(util.c("RENDER: app load failed with error ", pkt_state.ui_error))
|
||||||
else
|
else
|
||||||
log.debug("RENDER: app loaded in " .. (util.time_ms() - draw_start) .. "ms")
|
log.debug("RENDER: app loaded in " .. (util.time_ms() - draw_start) .. "ms")
|
||||||
|
|
||||||
|
-- call the on loaded function if provided
|
||||||
|
if type(cmd.val[2]) == "function" then cmd.val[2]() end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif msg.qtype == mqueue.TYPE.PACKET then
|
elseif msg.qtype == mqueue.TYPE.PACKET then
|
||||||
|
|||||||
Reference in New Issue
Block a user