diff --git a/apps/confessions-client/components/Login.tsx b/apps/confessions-client/components/Login.tsx index d3ff164..1c2b1af 100644 --- a/apps/confessions-client/components/Login.tsx +++ b/apps/confessions-client/components/Login.tsx @@ -3,7 +3,7 @@ import { usePassportPopupMessages, useSemaphoreGroupProof, } from "@pcd/passport-interface"; -import { useEffect, useState } from "react"; +import { useCallback, useEffect, useState } from "react"; import { login } from "../src/api"; import { PASSPORT_URL, SEMAPHORE_GROUP_URL } from "../src/util"; import { ConfessionsError, ErrorOverlay } from "./shared/ErrorOverlay"; @@ -17,14 +17,18 @@ import { ConfessionsError, ErrorOverlay } from "./shared/ErrorOverlay"; */ export function Login({ onLoggedIn }: { onLoggedIn: (_: string) => void }) { const [error, setError] = useState(); - const [pcdStr, _passportPendingPCDStr] = usePassportPopupMessages(); + const [valid, setValid] = useState(); + const onVerified = useCallback((valid: boolean) => { + setValid(valid); + }, []); - const { - proof, - valid, - error: proofError, - } = useSemaphoreGroupProof(pcdStr, SEMAPHORE_GROUP_URL, "zuzalu-confessions"); + const { proof, error: proofError } = useSemaphoreGroupProof( + pcdStr, + SEMAPHORE_GROUP_URL, + "zuzalu-confessions", + onVerified + ); useEffect(() => { if (valid === undefined) return; // verifying diff --git a/apps/confessions-client/components/PublishConfession.tsx b/apps/confessions-client/components/PublishConfession.tsx index 897bf8c..8141892 100644 --- a/apps/confessions-client/components/PublishConfession.tsx +++ b/apps/confessions-client/components/PublishConfession.tsx @@ -27,14 +27,18 @@ export function PublishConfession({ const [error, setError] = useState(); const [confessionInput, setConfessionInput] = useState(""); const [confession, setConfession] = useState(""); - + const [valid, setValid] = useState(); const [pcdStr, _passportPendingPCDStr] = usePassportPopupMessages(); + const onVerified = useCallback((valid: boolean) => { + setValid(valid); + }, []); - const { - proof, - valid, - error: proofError, - } = useSemaphoreGroupProof(pcdStr, SEMAPHORE_GROUP_URL, "zuzalu-confessions"); + const { proof, error: proofError } = useSemaphoreGroupProof( + pcdStr, + SEMAPHORE_GROUP_URL, + "zuzalu-confessions", + onVerified + ); useEffect(() => { if (valid === undefined) return; diff --git a/apps/confessions-client/package.json b/apps/confessions-client/package.json index d67845d..92fc1d2 100644 --- a/apps/confessions-client/package.json +++ b/apps/confessions-client/package.json @@ -11,7 +11,7 @@ "write-env-local": "./write-env-local.sh" }, "dependencies": { - "@pcd/passport-interface": "0.4.0", + "@pcd/passport-interface": "0.4.1", "@pcd/pcd-types": "0.4.0", "@pcd/semaphore-group-pcd": "0.4.0", "@pcd/semaphore-identity-pcd": "0.4.0", @@ -35,4 +35,4 @@ "eslint": "7.32.0", "typescript": "^4.5.3" } -} \ No newline at end of file +} diff --git a/yarn.lock b/yarn.lock index 3b3b942..1d58336 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1656,10 +1656,10 @@ react "^18.2.0" typescript "^4.5.2" -"@pcd/passport-interface@0.4.0": - version "0.4.0" - resolved "https://registry.yarnpkg.com/@pcd/passport-interface/-/passport-interface-0.4.0.tgz#a4401d5d44363e7399da5641f5be0d390b7ae23a" - integrity sha512-Msm4Idm+WWvflaHMX95ZBnxI8mVOO3nVwHd2l7rN83a3masuP7IybA2j4oVfjyjXIwu/WUWys5l5+93ORpskyQ== +"@pcd/passport-interface@0.4.1": + version "0.4.1" + resolved "https://registry.yarnpkg.com/@pcd/passport-interface/-/passport-interface-0.4.1.tgz#7761ec01773a7f3d9d96086c5c058deb082c91e0" + integrity sha512-74+irjgs7dWjJnAwQxH32dzr1Cg2XyEjda9wOyTNriYcuKYfvHDdZ0z7gseJ25QCUEbzLPAaUPpDYyLTM2oH9A== dependencies: "@pcd/passport-crypto" "0.4.0" "@pcd/pcd-types" "0.4.0"