Skip to content
Snippets Groups Projects
Commit 1038d4c7 authored by echicken's avatar echicken :chicken:
Browse files

Skip cache stuff if 0 ttl; keep some methods private.

parent 3e3488fc
No related branches found
No related tags found
No related merge requests found
...@@ -67,13 +67,19 @@ function getWeather() { ...@@ -67,13 +67,19 @@ function getWeather() {
const settings = loadSettings(); const settings = loadSettings();
const addr = locator.getAddress() || settings.fallback_ip; const addr = locator.getAddress() || settings.fallback_ip;
const url = getURL(settings, addr); const url = getURL(settings, addr);
const cachedWeather = readCache(url, addr, settings.cache_ttl); if (settings.cache_ttl > 0) {
if (cachedWeather !== undefined) return cachedWeather; const cachedWeather = readCache(url, addr, settings.cache_ttl);
if (cachedWeather !== undefined) return cachedWeather;
}
const weather = fetchWeather(url, addr); const weather = fetchWeather(url, addr);
const text = uReplace(weather); const text = uReplace(weather);
const ansi = xterm.convertColors(text); const ansi = xterm.convertColors(text);
writeCache(url, addr, ansi); if (settings.cache_ttl > 0) writeCache(url, addr, ansi);
return ansi; return ansi;
} }
this; const exports = {
\ No newline at end of file getWeather: getWeather,
};
exports;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment