Skip to content

Commit c019dcc

Browse files
committed
update BASE_REST_API in environment files and refactor useClosePreloadWindow hook usage
1 parent aa04d78 commit c019dcc

File tree

9 files changed

+21
-15
lines changed

9 files changed

+21
-15
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
LOCALHOST_ELECTRON_SERVER_PORT="8844"
2-
BASE_REST_API="https://localhost:10000"
2+
BASE_REST_API="https://gp-api-w36p.onrender.com"

.env.production

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
BASE_REST_API="https://gp-api-w36p.onrender.com"
2-
GH_TOKEN="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"
1+
BASE_REST_API="https://gp-api-w36p.onrender.com"

src/main/app/window.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,10 @@ export class AppWindow implements TWindowManager {
7171

7272
private async checkAuthenticated(window: BrowserWindow) {
7373
const result = this.authService.checkAuthenticated(window);
74-
if (result !== undefined && result.isAuthenticated !== undefined) {
75-
ipcWebContentsSend("authSocialNetwork", window.webContents, {
76-
isAuthenticated: result.isAuthenticated,
77-
});
78-
}
74+
ipcWebContentsSend("authSocialNetwork", window.webContents, {
75+
isAuthenticated:
76+
result !== undefined && result.isAuthenticated !== undefined,
77+
});
7978
}
8079

8180
private buildTray(window: BrowserWindow): void {

src/main/resources/windows/add.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { TWindowManager } from "../../@core/types/window-manager.js";
55
hash: "window/resource/add",
66
isCache: true,
77
options: {
8-
alwaysOnTop: true,
98
width: 400,
109
height: 500,
1110
},

src/main/resources/windows/delete.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { TWindowManager } from "../../@core/types/window-manager.js";
66
hash: "window/resource/delete",
77
isCache: true,
88
options: {
9-
alwaysOnTop: true,
109
width: 350,
1110
height: 190,
1211
},

src/main/resources/windows/update.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { TWindowManager } from "../../@core/types/window-manager.js";
66
hash: "window/resource/update",
77
isCache: true,
88
options: {
9-
alwaysOnTop: true,
109
width: 400,
1110
height: 500,
1211
},
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
import { useEffect } from "react";
2+
import { useLocation } from "react-router-dom";
3+
4+
export const useClosePreloadWindow = (currentPathname: string) => {
5+
const { pathname } = useLocation();
26

3-
export const useClosePreloadWindow = () => {
47
useEffect(() => {
5-
window.electron.send.closePreloadWindow();
6-
}, []);
8+
const normalizedParam = currentPathname.startsWith("/")
9+
? currentPathname
10+
: `/${currentPathname}`;
11+
12+
if (normalizedParam === pathname) {
13+
window.electron.send.closePreloadWindow();
14+
}
15+
}, [currentPathname, pathname]);
716
};

src/renderer/layouts/Main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const theme = createTheme({
2828
});
2929

3030
export const MainLayout = () => {
31-
useClosePreloadWindow();
31+
useClosePreloadWindow("sign-in");
3232

3333
return (
3434
<ThemeProvider theme={theme}>

src/renderer/windows/home/components/Home.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ import {
77
} from "@ui-business/MasterKey";
88
import { Provider as ProviderSync } from "@ui-business/Sync";
99
import { LoadingSpinner } from "@components/LoadingSpinner";
10+
import { useClosePreloadWindow } from "@hooks/closePreloadWindow";
1011

1112
const LazyTopPanel = lazy(() => import("./TopPanel"));
1213
const LazyResources = lazy(() => import("./Resources"));
1314

1415
const Home = () => {
16+
useClosePreloadWindow("window:main");
1517
useIpcMasterKey();
1618
const { isMasterKey } = useControlContextMasterKey();
1719

0 commit comments

Comments
 (0)