Skip to content

Commit a7ec632

Browse files
committed
fix: window not opening sometimes when clicking on tray
1 parent 2b6d8eb commit a7ec632

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/main/main.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Downloader } from "@shared";
44
import { levelKeys, db } from "./level";
55
import type { UserPreferences } from "@types";
66
import {
7-
WSClient,
87
SystemPath,
98
CommonRedistManager,
109
TorBoxClient,
@@ -47,7 +46,7 @@ export const loadState = async () => {
4746

4847
await HydraApi.setupApi().then(() => {
4948
uploadGamesBatch();
50-
WSClient.connect();
49+
// WSClient.connect();
5150
});
5251

5352
const downloads = await downloadsSublevel

src/main/services/hydra-api.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { getUserData } from "./user/get-user-data";
1111
import { db } from "@main/level";
1212
import { levelKeys } from "@main/level/sublevels";
1313
import type { Auth, User } from "@types";
14-
import { WSClient } from "./ws/ws-client";
1514

1615
interface HydraApiOptions {
1716
needsAuth?: boolean;
@@ -103,8 +102,8 @@ export class HydraApi {
103102
WindowManager.mainWindow.webContents.send("on-signin");
104103
await clearGamesRemoteIds();
105104
uploadGamesBatch();
106-
WSClient.close();
107-
WSClient.connect();
105+
// WSClient.close();
106+
// WSClient.connect();
108107
}
109108
}
110109

src/main/services/window-manager.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,21 @@ export class WindowManager {
181181
});
182182

183183
this.mainWindow.on("close", async () => {
184+
const mainWindow = this.mainWindow;
185+
this.mainWindow = null;
186+
184187
const userPreferences = await db.get<string, UserPreferences>(
185188
levelKeys.userPreferences,
186189
{
187190
valueEncoding: "json",
188191
}
189192
);
190193

191-
if (this.mainWindow) {
192-
const lastBounds = this.mainWindow.getBounds();
193-
const isMaximized = this.mainWindow.isMaximized() ?? false;
194+
if (mainWindow) {
195+
mainWindow.setProgressBar(-1);
196+
197+
const lastBounds = mainWindow.getBounds();
198+
const isMaximized = mainWindow.isMaximized() ?? false;
194199
const screenConfig = isMaximized
195200
? {
196201
x: undefined,
@@ -207,9 +212,6 @@ export class WindowManager {
207212
if (userPreferences?.preferQuitInsteadOfHiding) {
208213
app.quit();
209214
}
210-
211-
WindowManager.mainWindow?.setProgressBar(-1);
212-
WindowManager.mainWindow = null;
213215
});
214216

215217
this.mainWindow.webContents.setWindowOpenHandler((handler) => {

0 commit comments

Comments
 (0)