Reorder
This commit is contained in:
parent
efdf980558
commit
882af50507
1 changed files with 11 additions and 11 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue