Skip to content

Commit e584dc4

Browse files
committed
Refactor
1 parent 0f8b3d3 commit e584dc4

File tree

14 files changed

+33
-99
lines changed

14 files changed

+33
-99
lines changed

apps/desktop-e2e/cucumber.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const config = {
1414
failFast: true,
1515
paths: ["src/features/*"],
1616
require: ["src/**/*.ts"],
17-
requireModule: ["ts-node/register/transpile-only", "tsconfig-paths/register"],
17+
requireModule: ["ts-node/register"],
1818
format: ["html:test-results/cucumber-report.html", "json:test-results/cucumber-report.json"],
1919
},
2020
};

apps/desktop-e2e/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
"eslint": "^8.57.0",
2323
"madge": "^8.0.0",
2424
"prettier": "^3.4.2",
25-
"rimraf": "^6.0.1",
26-
"tsconfig-paths": "^4.2.0"
25+
"rimraf": "^6.0.1"
2726
},
2827
"dependencies": {
2928
"@cucumber/cucumber": "^11.1.1",

apps/desktop-e2e/src/global.d.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

apps/desktop-e2e/tsconfig.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"extends": "@umami/typescript-config/tsconfig.json",
32
"compilerOptions": {
43
"target": "esnext",
54
"allowJs": true,
@@ -15,13 +14,10 @@
1514
"noEmit": true,
1615
"jsx": "react-jsx",
1716
"customConditions": ["@umami/source"],
18-
"preserveSymlinks": true,
19-
"types": ["node", "jest"]
17+
"preserveSymlinks": true
2018
},
2119
"ts-node": {
22-
"esm": true,
23-
"transpileOnly": true,
24-
"files": true
20+
"esm": true
2521
},
26-
"include": ["src", ".eslintrc.cjs", "cucumber.cjs", "src/global.d.ts"]
22+
"include": ["src", ".eslintrc.cjs", "cucumber.cjs"]
2723
}

apps/desktop/public/electron.js

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ const fs = require("fs");
1111
const APP_PROTOCOL = "app";
1212
const APP_HOST = "assets";
1313

14-
// backupData is used to store the backup data from the previous version of the app
15-
let backupData;
16-
1714
const appURL = app.isPackaged
1815
? url.format({
1916
pathname: `${APP_HOST}/index.html`,
@@ -64,20 +61,19 @@ async function createBackupFromPrevDB() {
6461
return;
6562
}
6663

67-
// Copy the database to not lose original data
68-
fs.cpSync(dbPath, dbBackupPath, { recursive: true });
69-
70-
7164
if (fs.existsSync(backupPath)) {
7265
log.info("Backup file already exists. Skipping migration.");
7366
return;
7467
}
7568

69+
// Copy the database to not lose original data
70+
fs.cpSync(dbPath, dbBackupPath, { recursive: true });
71+
7672
const db = new Level(dbBackupPath);
7773

7874
// Retry logic for opening the database
7975
const maxRetries = 3;
80-
const retryDelay = 1000; // 1 second
76+
const retryDelay = 1000;
8177

8278
const tryOpenDb = async retriesLeft => {
8379
try {
@@ -88,7 +84,6 @@ async function createBackupFromPrevDB() {
8884
} catch (error) {
8985
if (retriesLeft <= 0) {
9086
log.error("Failed to open DB after all retries", error);
91-
await db.close();
9287
throw error;
9388
}
9489

@@ -100,7 +95,6 @@ async function createBackupFromPrevDB() {
10095

10196
try {
10297
await tryOpenDb(maxRetries);
103-
log.info("DB is opened");
10498

10599
const storage = {};
106100

@@ -169,9 +163,7 @@ async function createBackupFromPrevDB() {
169163
"persist:root": extractKeys(storage["persist:root"]),
170164
};
171165

172-
backupData = preparedStorage;
173-
174-
// Write storage object to JSON file
166+
// Write preparedStorage to JSON file
175167
try {
176168
fs.writeFileSync(backupPath, JSON.stringify(preparedStorage, null, 2), "utf-8");
177169
log.info("Backup successfully created at:", backupPath);
@@ -294,8 +286,6 @@ function createWindow() {
294286
mainWindow.once("ready-to-show", () => {
295287
mainWindow.show();
296288

297-
mainWindow.webContents.send("backupData", backupData);
298-
299289
if (deeplinkURL) {
300290
mainWindow.webContents.send("deeplinkURL", deeplinkURL);
301291
deeplinkURL = null;

apps/desktop/public/preload.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ contextBridge.exposeInMainWorld("electronAPI", {
1515
// Notify UI if app update is available to be installed.
1616
onAppUpdateDownloaded: callback => ipcRenderer.on("app-update-downloaded", callback),
1717

18-
// handle the backupData send in electron.js
19-
onBackupData: callback => ipcRenderer.on("backupData", callback),
20-
getBackupData: () => ipcRenderer.invoke("getBackupData"),
21-
2218
// Notify Electron that app update should be installed.
2319
installAppUpdateAndQuit: () => ipcRenderer.send("install-app-update"),
2420

2521
clipboardWriteText: text => ipcRenderer.send("clipboard-write", text),
2622
clipboardClear: () => ipcRenderer.send("clipboard-clear"),
23+
24+
getBackupData: () => ipcRenderer.invoke("getBackupData"),
2725
});

apps/desktop/src/Router.tsx

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ import {
99
useResetBeaconConnections,
1010
} from "@umami/state";
1111
import { noop } from "lodash";
12-
import { useEffect, useState } from "react";
12+
import { useEffect } from "react";
1313
import { HashRouter, Navigate, Route, Routes } from "react-router-dom";
1414

1515
import { AnnouncementBanner } from "./components/AnnouncementBanner";
16-
import { Loader } from "./components/Loader/Loader";
1716
import { SocialLoginWarningModal } from "./components/SocialLoginWarningModal/SocialLoginWarningModal";
1817
import { BeaconProvider } from "./utils/beacon/BeaconProvider";
1918
import { persistor } from "./utils/persistor";
@@ -87,27 +86,21 @@ const LoggedOutRouter = () => {
8786
WalletClient.destroy().then(resetBeaconConnections).catch(noop);
8887
}, [resetBeaconConnections]);
8988

90-
const [isDataLoading, setIsDataLoading] = useState(
91-
() => !localStorage.getItem("migration_2_3_3_to_2_3_4_completed")
92-
);
93-
9489
useEffect(() => {
9590
if (localStorage.getItem("migration_2_3_3_to_2_3_4_completed")) {
9691
return;
9792
}
9893

9994
const getBackupData = async () => {
100-
persistor.pause();
101-
10295
const backupData = await window.electronAPI.getBackupData();
10396

10497
if (!backupData) {
105-
setIsDataLoading(false);
10698
localStorage.setItem("migration_2_3_3_to_2_3_4_completed", "true");
107-
persistor.persist();
10899
return;
109100
}
110101

102+
persistor.pause();
103+
111104
await persistor.flush();
112105
localStorage.clear();
113106

@@ -124,14 +117,11 @@ const LoggedOutRouter = () => {
124117
}, []);
125118

126119
return (
127-
<>
128-
{isDataLoading && <Loader />}
129-
<HashRouter>
130-
<Routes>
131-
<Route element={<Navigate to="/welcome" />} path="/*" />
132-
<Route element={<WelcomeScreen />} path="/welcome" />
133-
</Routes>
134-
</HashRouter>
135-
</>
120+
<HashRouter>
121+
<Routes>
122+
<Route element={<Navigate to="/welcome" />} path="/*" />
123+
<Route element={<WelcomeScreen />} path="/welcome" />
124+
</Routes>
125+
</HashRouter>
136126
);
137127
};

apps/desktop/src/global.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ declare global {
88
onDeeplink: (callback: (url: string) => void) => void;
99
onAppUpdateDownloaded: (callback: () => void) => void;
1010
installAppUpdateAndQuit: () => void;
11-
onBackupData: (fn: (event: any, data?: Record<string, string>) => void) => void;
1211
getBackupData: () => Promise<Record<string, string> | undefined>;
1312
};
1413
}

apps/web/src/global.d.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/components/src/global.d.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)