diff options
Diffstat (limited to 'widgets')
| -rw-r--r-- | widgets/calendar.lua | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/widgets/calendar.lua b/widgets/calendar.lua index 11dcb63..5e08a7b 100644 --- a/widgets/calendar.lua +++ b/widgets/calendar.lua @@ -209,7 +209,10 @@ function M.draw(cr, rect, colors) local ey = grid_bottom + ev_size * 1.1 - if #cal.events == 0 then + -- The cache spans the month for the grid; the table is the week ahead. + local events = data.calendar_upcoming(cal.events, today, 8) + + if #events == 0 then card.font(cr, card.FONT_UI, ev_size, false) card.rgba(cr, colors.label, 0.8) card.text(cr, inner.x, ey, 'nothing this week') @@ -225,7 +228,7 @@ function M.draw(cr, rect, colors) -- 'all day' is wider than '13:00'. card.font(cr, card.FONT_MONO, ev_size, false) local time_w = 0 - for _, e in ipairs(cal.events) do + for _, e in ipairs(events) do local w = card.advance(cr, when(e)) if w > time_w then time_w = w end end @@ -253,16 +256,16 @@ function M.draw(cr, rect, colors) local probe = ey while probe <= floor_y do room = room + 1; probe = probe + ev_step end - local shown = #cal.events + local shown = #events -- The overflow line costs a row, so it is only worth taking when it reports -- more than the row it displaces. if room < shown then shown = (room >= 2) and (room - 1) or room end - local hidden = #cal.events - shown + local hidden = #events - shown for i = 1, shown do - local e = cal.events[i] + local e = events[i] if ey > floor_y then break end local colour = cal_colour(e.calendar, colors, cal.colors) |
