From d7449b6e75ff9fe6b109db78692bb55e49347466 Mon Sep 17 00:00:00 2001 From: Juan Di Toro Date: Thu, 2 Nov 2023 19:34:16 +0100 Subject: [PATCH] fix: improve loading --- src/components/App.tsx | 12 +++++------- src/components/Browser.tsx | 16 +++++++--------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 0f37aba..2786b2e 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -22,8 +22,6 @@ const App: React.FC = () => { .filter((n) => n.name.toLowerCase() === "handshake") .at(0); - console.log({ ethStatus, handshakeStatus, networks }); - return (
@@ -38,15 +36,15 @@ const App: React.FC = () => { {ethStatus?.syncState === "syncing" || handshakeStatus?.syncState === "syncing" ? ( -
+
{ethStatus?.syncState === "syncing" ? ( - - {ethStatus.sync.toPrecision(1)}% Syncing Ethereum Network + + {ethStatus.sync.toFixed(0)}% Syncing Ethereum Network ) : null} {handshakeStatus?.syncState === "syncing" ? ( - - {handshakeStatus.sync.toPrecision(1)}% Syncing Handshake Network + + {handshakeStatus.sync.toFixed(1)}% Syncing Handshake Network ) : null}
diff --git a/src/components/Browser.tsx b/src/components/Browser.tsx index f3ba7aa..629e54d 100644 --- a/src/components/Browser.tsx +++ b/src/components/Browser.tsx @@ -180,8 +180,6 @@ export function Navigator() { } }, [contextUrl]); - console.log("Navigator mounted"); - return (
{ @@ -244,8 +242,8 @@ export function Browser() { .replace(/\/$/, ""); if (url !== realUrl) { setUrl(realUrl); - setIsLoadingPage(false); } + setIsLoadingPage(false); } catch (e) { // This will catch errors related to cross-origin requests, in which case we can't access the iframe's contentWindow.location console.warn( @@ -263,12 +261,12 @@ export function Browser() { if ( mutation.type === "attributes" && mutation.attributeName === "src" - ) { - setIsLoadingPage(true); + ) { + setIsLoadingPage(true); + } } - } - }); - + }); + observer.observe(iframe, { attributes: true }); return () => observer.disconnect(); // Clean up on unmount } @@ -278,7 +276,7 @@ export function Browser() { <> {isLoadingPage ? (
- + Loading {url}...