From 8ec58dcb1e3691df4e9f7467a25f8f96548c033f Mon Sep 17 00:00:00 2001 From: Binarybaron Date: Thu, 15 May 2025 18:26:23 +0200 Subject: [PATCH] fix(gui): Fetch alerts only once --- src-gui/src/renderer/api.ts | 5 +++++ src-gui/src/renderer/background.ts | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src-gui/src/renderer/api.ts b/src-gui/src/renderer/api.ts index afcfec0c..73f41615 100644 --- a/src-gui/src/renderer/api.ts +++ b/src-gui/src/renderer/api.ts @@ -162,7 +162,12 @@ export async function updatePublicRegistry(): Promise { store.dispatch(registryConnectionFailed()); logger.error(error, "Error fetching providers"); } +} +/** + * Fetch all alerts + */ +export async function updateAlerts(): Promise { try { const alerts = await fetchAlertsViaHttp(); store.dispatch(setAlerts(alerts)); diff --git a/src-gui/src/renderer/background.ts b/src-gui/src/renderer/background.ts index 2ad6015d..0f0fe595 100644 --- a/src-gui/src/renderer/background.ts +++ b/src-gui/src/renderer/background.ts @@ -3,7 +3,7 @@ import { TauriSwapProgressEventWrapper, TauriContextStatusEvent, TauriLogEvent, import { contextStatusEventReceived, receivedCliLog, rpcSetBalance, timelockChangeEventReceived, rpcSetBackgroundRefundState, approvalEventReceived } from "store/features/rpcSlice"; import { swapProgressEventReceived } from "store/features/swapSlice"; import logger from "utils/logger"; -import { fetchAllConversations, updatePublicRegistry, updateRates } from "./api"; +import { fetchAllConversations, updateAlerts, updatePublicRegistry, updateRates } from "./api"; import { checkContextAvailability, getSwapInfo, initializeContext, updateAllNodeStatuses } from "./rpc"; import { store } from "./store/storeRenderer"; @@ -31,6 +31,9 @@ export async function setupBackgroundTasks(): Promise { setIntervalImmediate(updateRates, UPDATE_RATE_INTERVAL); setIntervalImmediate(fetchAllConversations, FETCH_CONVERSATIONS_INTERVAL); + // Fetch all alerts + updateAlerts(); + // // Setup Tauri event listeners // Check if the context is already available. This is to prevent unnecessary re-initialization