re-add format parameter.

This broke custom formats in the date widget.
This commit is contained in:
Joerg Thalheim 2017-10-23 15:24:17 +01:00
parent 750532a1d8
commit 1cfa040fbd
2 changed files with 8 additions and 7 deletions

View File

@ -76,7 +76,7 @@ local function update(widget, reg, disablecache)
cache.time, cache.data = t, data cache.time, cache.data = t, data
end end
end end
-- Check for cached output newer than the last update -- Check for cached output newer than the last update
local c = widget_cache[reg.wtype] local c = widget_cache[reg.wtype]
if c and c.time and c.data and t < c.time+reg.timer and not disablecache then if c and c.time and c.data and t < c.time+reg.timer and not disablecache then
@ -85,14 +85,15 @@ local function update(widget, reg, disablecache)
if reg.wtype.async then if reg.wtype.async then
if not reg.lock then if not reg.lock then
reg.lock = true reg.lock = true
return reg.wtype.async(reg.warg, return reg.wtype.async(reg.format,
reg.warg,
function(data) function(data)
update_value(format_data(data), t, c) update_value(format_data(data), t, c)
reg.lock=false reg.lock=false
end) end)
end end
else else
return update_value(format_data(reg.wtype(nil, reg.warg)), t, c) return update_value(format_data(reg.wtype(reg.format, reg.warg)), t, c)
end end
end end
end end

View File

@ -17,7 +17,7 @@ local pkg_all = {}
-- {{{ Packages widget type -- {{{ Packages widget type
function pkg_all.async(warg, callback) function pkg_all.async(format, warg, callback)
if not warg then return end if not warg then return end
-- Initialize counters -- Initialize counters
@ -44,7 +44,7 @@ function pkg_all.async(warg, callback)
size = math.max(size-first, 0) size = math.max(size-first, 0)
return {size, lines} return {size, lines}
end end
-- Select command -- Select command
local _pkg = manager[warg] local _pkg = manager[warg]
spawn.easy_async(_pkg.cmd, function(stdout) callback(parse(stdout, _pkg.sub)) end) spawn.easy_async(_pkg.cmd, function(stdout) callback(parse(stdout, _pkg.sub)) end)
@ -54,8 +54,8 @@ end
-- {{{ Packages widget type -- {{{ Packages widget type
local function worker(format, warg) local function worker(format, warg)
local ret = nil local ret = nil
pkg_all.async(warg, function(data) ret = data end) pkg_all.async(format, warg, function(data) ret = data end)
while ret==nil do end while ret==nil do end
return ret return ret