From cdf95566bd6d6b544dc26f61e5e9708067692bcc Mon Sep 17 00:00:00 2001 From: Ben Whittaker Date: Tue, 5 Oct 2021 20:57:10 -0400 Subject: [PATCH] Layout: Add `forgetLazyState` method --- apps/weather/app.js | 2 +- modules/Layout.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/weather/app.js b/apps/weather/app.js index 0f0512ba7..aab71f703 100644 --- a/apps/weather/app.js +++ b/apps/weather/app.js @@ -74,7 +74,7 @@ function update() { if (current) { draw(); } else { - delete layout.rects; + layout.forgetLazyState(); if (NRF.getSecurityStatus().connected) { E.showMessage("Weather unknown\n\nIs Gadgetbridge\nweather reporting\nset up on your\nphone?"); } else { diff --git a/modules/Layout.js b/modules/Layout.js index 087aff249..09e2a3d8c 100644 --- a/modules/Layout.js +++ b/modules/Layout.js @@ -73,6 +73,7 @@ Other functions: * `layout.update()` - update positions of everything if contents have changed * `layout.debug(obj)` - draw outlines for objects on screen * `layout.clear(obj)` - clear the given object (you can also just specify `bgCol` to clear before each render) +* `layout.forgetLazyState()` - if lazy rendering is enabled, makes the next call to `render()` perform a full re-render */ @@ -258,6 +259,10 @@ Layout.prototype.render = function (l) { } }; +Layout.prototype.forgetLazyState = function () { + this.rects = {}; +} + Layout.prototype.layout = function (l) { // l = current layout element // exw,exh = extra width/height available