import type { ProxyLock } from "@yaakapp-internal/proxy-lib"; import { Button, Icon, LoadingIcon } from "@yaakapp-internal/ui"; import { useAtomValue } from "jotai"; import { useRpcMutation } from "../hooks/useRpcMutation"; import { encryptingPercent } from "../lib/encrypting"; import { lockedLine } from "../lib/locked"; import { proxyStateAtom } from "../lib/store"; import { getOsType } from "../lib/tauri"; /** * Over the list and the detail pane while captured traffic can't be read: its key is * unavailable, or traffic from before encryption is being encrypted. Retry reads the key again * and opens it. */ export function LockedState({ lock }: { lock: ProxyLock }) { const proxyState = useAtomValue(proxyStateAtom); const retry = useRpcMutation("take_over"); const encrypting = encryptingPercent(proxyState); return (
{encrypting != null ? ( ) : ( )}
{encrypting != null ? ( <> Encrypting stored traffic,{" "} {/* Sized for "100%" and right-aligned, so the centred line never changes width as the number ticks: a changing width re-rasterizes every glyph at a new sub-pixel offset, and the line shakes */} {encrypting} ) : ( "Traffic is locked" )}
{encrypting != null ? "Earlier traffic shows here once it's encrypted." : lockedLine(lock, getOsType())}
{encrypting == null && ( )} {encrypting == null && retry.error != null && (
{retry.error.message}
)}
); }