From a6f26b3d379029660a651d5fff4822b0044cc49f Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Wed, 9 Apr 2025 00:14:48 +1000 Subject: weather: store api key directly in config Also only notify once when no api key for both weather and news --- src/services/news.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/services/news.ts') 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; } -- cgit v1.2.3-freya