Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Code can become invalid after timeout

Manav Rathib917237db232
diff --git a/web/apps/cast/src/pages/index.tsx b/web/apps/cast/src/pages/index.tsx
index 98dabd97e8..5cf3f8f3a7 100644
--- a/web/apps/cast/src/pages/index.tsx
+++ b/web/apps/cast/src/pages/index.tsx
@@ -11,6 +11,9 @@ export default function Index() {
const [publicKeyB64, setPublicKeyB64] = useState<string | undefined>();
const [privateKeyB64, setPrivateKeyB64] = useState<string | undefined>();
const [pairingCode, setPairingCode] = useState<string | undefined>();
+ // TODO: This needs to change, since there is an interim period when the
+ // code becomes invalid.
+ const [haveInitializedCast, setHaveInitializedCast] = useState(false);
const router = useRouter();
@@ -27,10 +30,11 @@ export default function Index() {
};
useEffect(() => {
- if (pairingCode) {
- castReceiverLoadingIfNeeded().then((cast) =>
- advertiseCode(cast, () => pairingCode),
- );
+ if (pairingCode && !haveInitializedCast) {
+ castReceiverLoadingIfNeeded().then((cast) => {
+ setHaveInitializedCast(true);
+ advertiseCode(cast, () => pairingCode);
+ });
}
}, [pairingCode]);
@@ -54,10 +58,11 @@ export default function Index() {
storeCastData(data);
await router.push("/slideshow");
} catch (e) {
+ // Code has become invalid
log.error("Failed to get cast data", e);
// Start again from the beginning.
- // setPairingCode(undefined);
- // init();
+ setPairingCode(undefined);
+ init();
}
};