From 1038d4c7e8739b0adc6c7ed910276216a2ccbb84 Mon Sep 17 00:00:00 2001 From: echicken <echicken@bbs.electronicchicken.com> Date: Fri, 24 Feb 2023 15:35:35 +0000 Subject: [PATCH] Skip cache stuff if 0 ttl; keep some methods private. --- xtrn/wttr.in/wttr-lib.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/xtrn/wttr.in/wttr-lib.js b/xtrn/wttr.in/wttr-lib.js index c30a415180..e3d5115523 100644 --- a/xtrn/wttr.in/wttr-lib.js +++ b/xtrn/wttr.in/wttr-lib.js @@ -67,13 +67,19 @@ function getWeather() { const settings = loadSettings(); const addr = locator.getAddress() || settings.fallback_ip; const url = getURL(settings, addr); - const cachedWeather = readCache(url, addr, settings.cache_ttl); - if (cachedWeather !== undefined) return cachedWeather; + if (settings.cache_ttl > 0) { + const cachedWeather = readCache(url, addr, settings.cache_ttl); + if (cachedWeather !== undefined) return cachedWeather; + } const weather = fetchWeather(url, addr); const text = uReplace(weather); const ansi = xterm.convertColors(text); - writeCache(url, addr, ansi); + if (settings.cache_ttl > 0) writeCache(url, addr, ansi); return ansi; } -this; \ No newline at end of file +const exports = { + getWeather: getWeather, +}; + +exports; -- GitLab