From f994e95e66d5d3fc022423a11d78b4ff2fedb1a0 Mon Sep 17 00:00:00 2001 From: Martin Zwigl Date: Thu, 27 Feb 2025 23:46:22 +0100 Subject: [PATCH] :construction: improve clk-info --- apps/coin_info/clkinfo.js | 35 +++++++++++++++++++++-------------- apps/coin_info/metadata.json | 2 +- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/apps/coin_info/clkinfo.js b/apps/coin_info/clkinfo.js index c0705f082..c2e38bd88 100644 --- a/apps/coin_info/clkinfo.js +++ b/apps/coin_info/clkinfo.js @@ -12,10 +12,11 @@ } function showClkInfo() { - this.interval = setTimeout(()=>{ - this.emit("redraw"); - this.interval = setInterval(()=>{ - this.emit("redraw"); + const self = this; + this.interval = setTimeout(() => { + self.emit("redraw"); + self.interval = setInterval(() => { + self.emit("redraw"); }, 60000); }, 60000 - (Date.now() % 60000)); } @@ -25,16 +26,22 @@ this.interval = null; } - var coinInfoItems = { - name: "CoinInfo", - items: settings.tokenSelected.sort().map(token => { - return { name : token, - get : () => retrieveClkInfo(token), - show : showClkInfo(), - hide : hideClkInfo(), + function createClkInfoItems() { + let clkItems = []; + settings.tokens.sort().forEach(token => { + const clkItem = { + name: token, + get: () => retrieveClkInfo(token), + show: showClkInfo, + hide: hideClkInfo, } - }) - }; + clkItems.push(clkItem) + }); + return clkItems; + } - return coinInfoItems; + return { + name: "CoinInfo", + items: createClkInfoItems + }; }) diff --git a/apps/coin_info/metadata.json b/apps/coin_info/metadata.json index 8f460c7d6..0a57b9d3c 100644 --- a/apps/coin_info/metadata.json +++ b/apps/coin_info/metadata.json @@ -1,7 +1,7 @@ { "id": "coin_info", "name": "Crypto-Coins Info", "shortName":"Coins Info", - "version": "0.03.7", + "version": "0.03.8", "description": "Crypto-Coins Infos with the help of the Coinmarketcap API", "icon": "app.png", "tags": "clkinfo",