diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-09 00:14:48 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-09 00:14:48 +1000 |
| commit | a6f26b3d379029660a651d5fff4822b0044cc49f (patch) | |
| tree | 39f7ff864aa937cafcc2cac6dd3ec46b83342153 /src/services/news.ts | |
| parent | updates: fix cache file extension (diff) | |
| download | caelestia-shell-a6f26b3d379029660a651d5fff4822b0044cc49f.tar.gz caelestia-shell-a6f26b3d379029660a651d5fff4822b0044cc49f.tar.bz2 caelestia-shell-a6f26b3d379029660a651d5fff4822b0044cc49f.zip | |
weather: store api key directly in config
Also only notify once when no api key for both weather and news
Diffstat (limited to 'src/services/news.ts')
| -rw-r--r-- | src/services/news.ts | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/services/news.ts b/src/services/news.ts index a08f19c..5845aff 100644 --- a/src/services/news.ts +++ b/src/services/news.ts @@ -21,6 +21,7 @@ export default class News extends GObject.Object { } readonly #cachePath = `${CACHE}/news.json`; + #notified = false; #loading: boolean = false; #articles: Article[] = []; @@ -37,15 +38,18 @@ export default class News extends GObject.Object { async getNews() { if (!config.apiKey.get()) { - notify({ - summary: "A newsdata.io API key is required", - body: "You can get one by creating an account at https://newsdata.io", - icon: "dialog-error-symbolic", - urgency: "critical", - actions: { - "Get API key": () => execAsync("app2unit -O -- https://newsdata.io").catch(console.error), - }, - }); + if (!this.#notified) { + notify({ + summary: "A newsdata.io API key is required", + body: "You can get one by creating an account at https://newsdata.io", + icon: "dialog-warning-symbolic", + urgency: "critical", + actions: { + "Get API key": () => execAsync("app2unit -O -- https://newsdata.io").catch(console.error), + }, + }); + this.#notified = true; + } return; } |