Skip to content

Commit 5664b45

Browse files
authored
Merge pull request #3 from MystenLabs/APPS-add-loading
add loading before redirect
2 parents 23c3eca + 53c3b0a commit 5664b45

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

apps/explorer/src/components/Layout/PageLayout.tsx

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -107,23 +107,7 @@ function ImageLink({ type }: { type: RedirectExplorer }) {
107107
}
108108

109109
function RedirectContent() {
110-
const { suiscanUrl, suivisionUrl } = useRedirectExplorerUrl();
111110
const redirectExplorers = useRedirectExplorerOrder();
112-
const {
113-
checked,
114-
preference,
115-
} = usePreference();
116-
117-
useEffect(() => {
118-
if (checked && preference) {
119-
const redirectUrl = preference === RedirectExplorer.SUISCAN ? suiscanUrl : suivisionUrl;
120-
ampli.redirectToExternalExplorer({
121-
name: preference,
122-
url: redirectUrl,
123-
});
124-
window.location.href = redirectUrl;
125-
}
126-
}, [checked, preference, suiscanUrl, suivisionUrl]);
127111

128112
return (
129113
<section className="flex flex-col gap-10">
@@ -208,6 +192,11 @@ export function PageLayout({ gradient, content, loading, isError }: PageLayoutPr
208192
const [network] = useNetworkContext();
209193
const { request } = useAppsBackend();
210194
const outageOverride = useFeatureIsOn('network-outage-override');
195+
const { suiscanUrl, suivisionUrl } = useRedirectExplorerUrl();
196+
const {
197+
checked,
198+
preference,
199+
} = usePreference();
211200

212201
const { data } = useQuery({
213202
queryKey: ['apps-backend', 'monitor-network'],
@@ -226,11 +215,33 @@ export function PageLayout({ gradient, content, loading, isError }: PageLayoutPr
226215
const headerRef = useRef<HTMLElement | null>(null);
227216
const [headerHeight] = useElementDimensions(headerRef, DEFAULT_HEADER_HEIGHT);
228217

218+
useEffect(() => {
219+
if (checked && preference) {
220+
const redirectUrl = preference === RedirectExplorer.SUISCAN ? suiscanUrl : suivisionUrl;
221+
ampli.redirectToExternalExplorer({
222+
name: preference,
223+
url: redirectUrl,
224+
});
225+
window.location.href = redirectUrl;
226+
}
227+
}, [checked, preference, suiscanUrl, suivisionUrl]);
228+
229+
229230
const networkDegradeBannerCopy =
230231
network === Network.TESTNET
231232
? 'Sui Explorer (Testnet) is currently under-going maintenance. Some data may be incorrect or missing.'
232233
: "The explorer is running slower than usual. We're working to fix the issue and appreciate your patience.";
233234

235+
if (checked && preference) {
236+
return (
237+
<div className="h-full w-full relative">
238+
<div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2">
239+
<LoadingIndicator />
240+
</div>
241+
</div>
242+
)
243+
}
244+
234245
return (
235246
<div className="relative min-h-screen w-full">
236247
<section ref={headerRef} className="fixed top-0 z-20 flex w-full flex-col">

0 commit comments

Comments
 (0)