From 61dfc51a7ae12871f5ce9bdf1cae1b9db37c4fc1 Mon Sep 17 00:00:00 2001 From: tmgrask Date: Thu, 19 Sep 2024 16:23:32 -0400 Subject: [PATCH] fix type issue --- src/psiphon/inproxy.ts | 2 +- src/psiphon/mockContext.tsx | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/psiphon/inproxy.ts b/src/psiphon/inproxy.ts index 9e62755..52a37b7 100644 --- a/src/psiphon/inproxy.ts +++ b/src/psiphon/inproxy.ts @@ -45,7 +45,7 @@ export const InProxyErrorSchema = z.object({ action: z.enum(["inProxyMustUpgrade"]), }); -const InProxyStatusSchema = z.object({ +export const InProxyStatusSchema = z.object({ status: z.enum(["running", "stopped", "unknown"]), }); diff --git a/src/psiphon/mockContext.tsx b/src/psiphon/mockContext.tsx index 3a6c261..6224b1c 100644 --- a/src/psiphon/mockContext.tsx +++ b/src/psiphon/mockContext.tsx @@ -6,6 +6,7 @@ import { InProxyActivityStats, InProxyParameters, InProxyStatus, + InProxyStatusSchema, getDefaultInProxyParameters, getZeroedInProxyActivityStats, } from "@/src/psiphon/inproxy"; @@ -252,13 +253,17 @@ export function InProxyProvider({ children }: { children: React.ReactNode }) { } const getInProxyStatus = React.useCallback(() => { + let state; if (!inProxyState.synced) { - return { status: "unknown" }; + state = { status: "unknown" }; } else { - return inProxyState.running - ? { status: "running" } - : { status: "stopped" }; + if (inProxyState.running) { + state = { status: "running" }; + } else { + state = { status: "stopped" }; + } } + return InProxyStatusSchema.parse(state); }, [inProxyState]); async function sendFeedback(): Promise {