commit 07b566a1afb131d9137e543291de3a7368292360
parent 1f3aac3b57af7f99de6d78fd43acea0b4cfdfcb1
Author: Sebastian <sebasjm@gmail.com>
Date: Mon, 26 Aug 2024 09:35:30 -0300
evic when pushing form
Diffstat:
2 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/packages/kyc-ui/src/app.tsx b/packages/kyc-ui/src/app.tsx
@@ -17,6 +17,7 @@
import {
CacheEvictor,
TalerExchangeCacheEviction,
+ assertUnreachable,
canonicalizeBaseUrl,
getGlobalLogLevel,
setGlobalLogLevelFromString
@@ -36,19 +37,10 @@ import { SettingsProvider } from "./context/settings.js";
import { strings } from "./i18n/strings.js";
import { Frame } from "./pages/Frame.js";
import { KycUiSettings, fetchSettings } from "./settings.js";
+import { revalidateKycInfo } from "./hooks/kyc.js";
const WITH_LOCAL_STORAGE_CACHE = false;
-const evictExchangeSwrCache: CacheEvictor<TalerExchangeCacheEviction> = {
- async notifySuccess(op) {
- // switch (op) {
- // default: {
- // assertUnreachable(op);
- // }
- // }
- },
-};
-
export function App(): VNode {
const [settings, setSettings] = useState<KycUiSettings>();
useEffect(() => {
@@ -158,3 +150,21 @@ function getInitialBackendBaseURL(
return canonicalizeBaseUrl(window.origin);
}
}
+
+const evictExchangeSwrCache: CacheEvictor<TalerExchangeCacheEviction> = {
+ async notifySuccess(op) {
+ switch (op) {
+ case TalerExchangeCacheEviction.CREATE_DESCISION:{
+ await revalidateKycInfo()
+ return;
+ }
+ case TalerExchangeCacheEviction.UPLOAD_KYC_FORM: {
+ return;
+ }
+ default: {
+ assertUnreachable(op);
+ }
+ }
+ },
+};
+
diff --git a/packages/taler-util/src/http-client/exchange.ts b/packages/taler-util/src/http-client/exchange.ts
@@ -76,6 +76,7 @@ export type TalerExchangeErrorsByMethod<
export enum TalerExchangeCacheEviction {
CREATE_DESCISION,
+ UPLOAD_KYC_FORM,
}
declare const __pubId: unique symbol;
@@ -726,8 +727,12 @@ export class TalerExchangeHttpClient {
});
switch (resp.status) {
- case HttpStatusCode.NoContent:
+ case HttpStatusCode.NoContent: {
+ this.cacheEvictor.notifySuccess(
+ TalerExchangeCacheEviction.UPLOAD_KYC_FORM,
+ );
return opEmptySuccess(resp);
+ }
case HttpStatusCode.NotFound:
return opKnownHttpFailure(resp.status, resp);
case HttpStatusCode.Conflict: