Skip to content

Commit

Permalink
Add loader
Browse files Browse the repository at this point in the history
  • Loading branch information
OKendigelyan committed Dec 20, 2024
1 parent cc03870 commit 76b2886
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 24 deletions.
4 changes: 1 addition & 3 deletions apps/desktop/public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,7 @@ function createWindow() {
mainWindow.once("ready-to-show", () => {
mainWindow.show();

if (backupData) {
mainWindow.webContents.send("backupData", backupData);
}
mainWindow.webContents.send("backupData", backupData);

if (deeplinkURL) {
mainWindow.webContents.send("deeplinkURL", deeplinkURL);
Expand Down
26 changes: 6 additions & 20 deletions apps/desktop/src/Router.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* istanbul ignore file */
import { Flex, Spinner } from "@chakra-ui/react";
import { DynamicModalContext, useDynamicModal } from "@umami/components";
import { useDataPolling } from "@umami/data-polling";
import {
Expand All @@ -13,6 +12,7 @@ import { useEffect, useState } from "react";
import { HashRouter, Navigate, Route, Routes } from "react-router-dom";

import { AnnouncementBanner } from "./components/AnnouncementBanner";
import { Loader } from "./components/Loader/Loader";
import { SocialLoginWarningModal } from "./components/SocialLoginWarningModal/SocialLoginWarningModal";
import { BeaconProvider } from "./utils/beacon/BeaconProvider";
import { persistor } from "./utils/persistor";
Expand Down Expand Up @@ -85,7 +85,7 @@ const LoggedOutRouter = () => {
WalletClient.destroy().then(resetBeaconConnections).catch(noop);
}, [resetBeaconConnections]);

const [isDataLoading] = useState(
const [isDataLoading, setIsDataLoading] = useState(
() => !localStorage.getItem("migration_2_3_3_to_2_3_4_completed")
);

Expand All @@ -98,8 +98,6 @@ const LoggedOutRouter = () => {

if (window.electronAPI) {
window.electronAPI.onBackupData((_, data) => {
console.log("1. Received backup data:", data);

if (data) {
setTimeout(() => {
localStorage.clear();
Expand All @@ -110,29 +108,17 @@ const LoggedOutRouter = () => {

window.location.reload();
}, 3000);
} else {
setIsDataLoading(false);
localStorage.setItem("migration_2_3_3_to_2_3_4_completed", "true");
}
});
}
}, []);

return (
<>
{isDataLoading && (
<Flex
position="absolute"
zIndex="9999"
top="0"
left="0"
alignItems="center"
justifyContent="center"
width="full"
height="100vh"
backdropFilter="blur(10px)"
backgroundColor="rgba(0, 0, 0, 0.2)"
>
<Spinner />
</Flex>
)}
{isDataLoading && <Loader />}
<HashRouter>
<Routes>
<Route element={<Navigate to="/welcome" />} path="/*" />
Expand Down
18 changes: 18 additions & 0 deletions apps/desktop/src/components/Loader/Loader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Flex, Spinner } from "@chakra-ui/react";

export const Loader = () => (
<Flex
position="absolute"
zIndex="9999"
top="0"
left="0"
alignItems="center"
justifyContent="center"
width="full"
height="100vh"
backdropFilter="blur(10px)"
backgroundColor="rgba(0, 0, 0, 0.2)"
>
<Spinner />
</Flex>
);
3 changes: 2 additions & 1 deletion apps/desktop/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Provider } from "react-redux";
import { PersistGate } from "redux-persist/integration/react";

import { ErrorPage } from "./components/ErrorPage";
import { Loader } from "./components/Loader/Loader";
import { ReactQueryProvider } from "./providers/ReactQueryProvider";
import { UmamiTheme } from "./providers/UmamiTheme";
import { Router } from "./Router";
Expand All @@ -29,7 +30,7 @@ root.render(
<StrictMode>
<UmamiTheme>
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<PersistGate loading={<Loader />} persistor={persistor}>
<ErrorBoundary fallback={<ErrorPage />} onError={logError}>
<ReactQueryProvider>
<Router />
Expand Down

0 comments on commit 76b2886

Please sign in to comment.