fix: fixing main thread lock

This commit is contained in:
Hydra 2024-05-03 23:00:53 +01:00
parent 1eb963679e
commit e1955e11f5
No known key found for this signature in database
8 changed files with 1132 additions and 1107 deletions

View File

@ -4,7 +4,6 @@ import {
loadEnv,
swcPlugin,
externalizeDepsPlugin,
bytecodePlugin,
} from "electron-vite";
import react from "@vitejs/plugin-react";
import { vanillaExtractPlugin } from "@vanilla-extract/vite-plugin";
@ -34,12 +33,7 @@ export default defineConfig(({ mode }) => {
"@resources": resolve("resources"),
},
},
plugins: [
externalizeDepsPlugin(),
swcPlugin(),
bytecodePlugin(),
sentryPlugin,
],
plugins: [externalizeDepsPlugin(), swcPlugin(), sentryPlugin],
},
preload: {
plugins: [externalizeDepsPlugin()],
@ -54,13 +48,7 @@ export default defineConfig(({ mode }) => {
"@locales": resolve("src/locales"),
},
},
plugins: [
svgr(),
react(),
vanillaExtractPlugin(),
bytecodePlugin(),
sentryPlugin,
],
plugins: [svgr(), react(), vanillaExtractPlugin(), sentryPlugin],
},
};
});

View File

@ -1,7 +1,7 @@
{
"home": {
"featured": "Destaque",
"recently_added": "Novidades",
"recently_added": "Recém adicionados",
"trending": "Populares",
"surprise_me": "Surpreenda-me",
"no_results": "Nenhum resultado encontrado"

View File

@ -1,5 +1,4 @@
export * from "./game.entity";
export * from "./image-cache.entity";
export * from "./repack.entity";
export * from "./repacker-friendly-name.entity";
export * from "./user-preferences.entity";

View File

@ -8,7 +8,7 @@ import { stateManager } from "@main/state-manager";
const { Index } = flexSearch;
const repacksIndex = new Index();
const steamGamesIndex = new Index();
const steamGamesIndex = new Index({ tokenize: "forward" });
const repacks = stateManager.getValue("repacks");
const steamGames = stateManager.getValue("steamGames");

View File

@ -20,6 +20,7 @@ export const startProcessWatcher = async () => {
});
if (games.length === 0) {
await sleep(sleepTime);
continue;
}

View File

@ -52,8 +52,7 @@ const getXatabRepack = (url: string) => {
worker.removeListener("message", onMessage);
};
worker.on("message", onMessage);
worker.postMessage($downloadButton.href);
worker.once("message", onMessage);
})();
});
};

View File

@ -1,5 +1,6 @@
import path from "node:path";
import cp from "node:child_process";
import crypto from "node:crypto";
import fs from "node:fs";
import * as Sentry from "@sentry/electron/main";
import { Notification, app, dialog } from "electron";
@ -98,6 +99,25 @@ export class TorrentClient {
return game.progress;
}
private static createTempIcon(encodedIcon: string): Promise<string> {
return new Promise((resolve, reject) => {
const hash = crypto.randomBytes(16).toString("hex");
const iconPath = path.join(app.getPath("temp"), `${hash}.png`);
fs.writeFile(
iconPath,
Buffer.from(
encodedIcon.replace("data:image/jpeg;base64,", ""),
"base64"
),
(err) => {
if (err) reject(err);
resolve(iconPath);
}
);
});
}
public static async onSocketData(data: Buffer) {
const message = Buffer.from(data).toString("utf-8");
@ -139,7 +159,10 @@ export class TorrentClient {
});
if (userPreferences?.downloadNotificationsEnabled) {
const iconPath = await this.createTempIcon(game.iconUrl);
new Notification({
icon: iconPath,
title: t("download_complete", {
ns: "notifications",
lng: userPreferences.language,

2191
yarn.lock

File diff suppressed because it is too large Load Diff