From 82b8e83ca635bd27954565e2c29c77e0a75b3fc0 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Mon, 22 Apr 2024 12:50:25 -0300
Subject: fix #8398

---
 packages/challenger-ui/src/app.tsx | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

(limited to 'packages/challenger-ui/src/app.tsx')

diff --git a/packages/challenger-ui/src/app.tsx b/packages/challenger-ui/src/app.tsx
index d85893c07..2b5c5c815 100644
--- a/packages/challenger-ui/src/app.tsx
+++ b/packages/challenger-ui/src/app.tsx
@@ -15,6 +15,9 @@
  */
 
 import {
+  CacheEvictor,
+  ChallengerCacheEviction,
+  assertUnreachable,
   canonicalizeBaseUrl,
   getGlobalLogLevel,
   setGlobalLogLevelFromString,
@@ -33,13 +36,28 @@ import { Routing } from "./Routing.js";
 // import { BrowserHashNavigationProvider } from "./context/navigation.js";
 import { SettingsProvider } from "./context/settings.js";
 // import { TalerWalletIntegrationBrowserProvider } from "./context/wallet-integration.js";
-import { h } from "preact";
+import { VNode, h } from "preact";
 import { strings } from "./i18n/strings.js";
 import { ChallengerUiSettings, fetchSettings } from "./settings.js";
 import { Frame } from "./pages/Frame.js";
+import { revalidateChallengeSession } from "./hooks/challenge.js";
 const WITH_LOCAL_STORAGE_CACHE = false;
 
-export function App() {
+const evictBankSwrCache: CacheEvictor<ChallengerCacheEviction> = {
+  async notifySuccess(op) {
+    switch (op) {
+      case ChallengerCacheEviction.CREATE_CHALLENGE: {
+        await Promise.all([revalidateChallengeSession()]);
+        return;
+      }
+      default: {
+        assertUnreachable(op);
+      }
+    }
+  },
+};
+
+export function App(): VNode {
   const [settings, setSettings] = useState<ChallengerUiSettings>();
   useEffect(() => {
     fetchSettings(setSettings);
@@ -60,6 +78,9 @@ export function App() {
         <ChallengerApiProvider
           baseUrl={new URL("/", baseUrl)}
           frameOnError={Frame}
+          evictors={{
+            challenger: evictBankSwrCache,
+          }}
         >
           <SWRConfig
             value={{
-- 
cgit v1.2.3

