mirror of
https://github.com/britzl/monarch.git
synced 2025-06-27 10:27:49 +02:00
Add a check for missing resources in collection proxies. (#107)
* Update monarch.lua * Update monarch.lua * Update monarch.lua
This commit is contained in:
parent
4c6e26fd71
commit
679482f84d
@ -462,8 +462,7 @@ local function preload(screen)
|
|||||||
screen.preloading = true
|
screen.preloading = true
|
||||||
if screen.proxy then
|
if screen.proxy then
|
||||||
log("preload() proxy")
|
log("preload() proxy")
|
||||||
local missing_resources = collectionproxy.missing_resources(screen.proxy)
|
if M.has_missing_resources(screen.id) then
|
||||||
if #missing_resources > 0 then
|
|
||||||
local error_message = ("preload() collection proxy %s is missing resources"):format(tostring(screen.id))
|
local error_message = ("preload() collection proxy %s is missing resources"):format(tostring(screen.id))
|
||||||
log(error_message)
|
log(error_message)
|
||||||
screen.preloading = false
|
screen.preloading = false
|
||||||
@ -1131,6 +1130,20 @@ function M.preload(id, options, cb)
|
|||||||
return true -- return true for legacy reasons (before queue existed)
|
return true -- return true for legacy reasons (before queue existed)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Check if a screen has missing resources, always returns false for factory
|
||||||
|
-- @param id (string|hash) - Id of the screen to preload
|
||||||
|
function M.has_missing_resources(id)
|
||||||
|
assert(id, "You must provide a screen id")
|
||||||
|
id = tohash(id)
|
||||||
|
assert(screens[id], ("There is no screen registered with id %s"):format(tostring(id)))
|
||||||
|
|
||||||
|
local screen = screens[id]
|
||||||
|
if screen.proxy then
|
||||||
|
local missing_resources = collectionproxy.missing_resources(screen.proxy)
|
||||||
|
return #missing_resources > 0
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
--- Unload a preloaded monarch screen
|
--- Unload a preloaded monarch screen
|
||||||
-- @param id (string|hash) - Id of the screen to unload
|
-- @param id (string|hash) - Id of the screen to unload
|
||||||
|
Loading…
x
Reference in New Issue
Block a user