Skip to content

armgit / ente

Public Imported from GitHub
0

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

Reorder

Manav Rathi882af5050702
diff --git a/web/apps/cast/src/pages/index.tsx b/web/apps/cast/src/pages/index.tsx
index f1ec1a7468..dd0389949e 100644
--- a/web/apps/cast/src/pages/index.tsx
+++ b/web/apps/cast/src/pages/index.tsx
@@ -14,6 +14,10 @@ export default function Index() {
const router = useRouter();
+ useEffect(() => {
+ init();
+ }, []);
+
const init = () => {
register().then((r) => {
setPublicKeyB64(r.publicKeyB64);
@@ -22,16 +26,19 @@ export default function Index() {
});
};
- useEffect(() => {
- init();
- }, []);
-
useEffect(() => {
castReceiverLoadingIfNeeded().then((cast) =>
advertiseCode(cast, () => pairingCode),
);
}, []);
+ useEffect(() => {
+ if (!publicKeyB64 || !privateKeyB64 || !pairingCode) return;
+
+ const interval = setInterval(pollTick, 2000);
+ return () => clearInterval(interval);
+ }, [publicKeyB64, privateKeyB64, pairingCode]);
+
const pollTick = async () => {
const registration = { publicKeyB64, privateKeyB64, pairingCode };
try {
@@ -52,13 +59,6 @@ export default function Index() {
}
};
- useEffect(() => {
- if (!publicKeyB64 || !privateKeyB64 || !pairingCode) return;
-
- const interval = setInterval(pollTick, 2000);
- return () => clearInterval(interval);
- }, [publicKeyB64, privateKeyB64, pairingCode]);
-
return (
<>
<div