From 065269db24678e92f1dcf4bd459b59dfcaf816aa Mon Sep 17 00:00:00 2001 From: Dekita Date: Sun, 26 Jan 2025 11:19:07 +0000 Subject: [PATCH] fix for discord rpc causing app to hang with white screen --- main/background.js | 5 +++-- main/dek/discord-rpc.js | 19 ++++++++++++++++++- package.json | 4 ++-- renderer/hooks/useThemeSystem.js | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/main/background.js b/main/background.js index 0d77879..fe0925b 100644 --- a/main/background.js +++ b/main/background.js @@ -52,7 +52,8 @@ DEAP.setup(config, ()=>{ // then run this callback // ensure the ModCache folder is created on app ready let appDataPath = DEAP.app.getAppPath(); if (DEAP.app.isPackaged) { - appDataPath = path.dirname(DEAP.app.getPath('exe')); + // appDataPath = path.dirname(DEAP.app.getPath('exe')); + appDataPath = DEAP.app.getPath("userData"); } const appFolder = path.join(appDataPath, 'ModCache'); if (!fs.existsSync(appFolder)) { @@ -83,6 +84,6 @@ DEAP.launch({ // RPC.pause(); // }); // }); - RPC.start(); + RPC.startWhenReady(); } }); diff --git a/main/dek/discord-rpc.js b/main/dek/discord-rpc.js index 64b19c0..746903c 100644 --- a/main/dek/discord-rpc.js +++ b/main/dek/discord-rpc.js @@ -3,6 +3,7 @@ import DEAP from './deap'; import DiscordRPC from 'discord-rpc'; import localization from '../../renderer/locales/en-dektionary.json'; +import fs from 'fs'; // const path = require('path'); // const { app } = require('electron'); @@ -35,8 +36,22 @@ export default { paused: false, handle: null, isset: false, + isDiscordAvailable() { + let ipcPath = `\\\\?\\pipe\\discord-ipc-0`; + if (!process.platform === 'win32') { + ipcPath = `${process.env.XDG_RUNTIME_DIR || '/tmp'}/discord-ipc-0`; + } + return fs.existsSync(ipcPath); + }, + startWhenReady() { + console.log('Starting Discord RPC when ready'); + rpc.on('ready', () => this.start()); + }, start() { console.log('Starting Discord RPC'); + const available = this.isDiscordAvailable(); + console.log('Starting Discord RPC:', available); + if (!available) return; rpc.login({ clientId }).then(() => { console.log('Discord RPC connected'); startTimestamp = new Date(); @@ -46,6 +61,8 @@ export default { this.update(); }, UPDATE_FREQ); this.update(); + }).catch(error => { + console.error('Discord RPC error:', error); }); }, stop() { @@ -81,7 +98,7 @@ export default { if (!allowRPC) return; // console.log('Updating Discord RPC'); - + // const playtime = new Date() - startTimestamp; // const minutes = Math.floor(playtime / 60000); const maxLen = 23; diff --git a/package.json b/package.json index 8a70249..04e3c1b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "private": true, - "version": "0.8.35", + "version": "0.8.44", "name": "dekita-ue-mod-hub", "productName": "UE Mod Hub", "description": "UE Mod Hub written by DekitaRPG", @@ -81,6 +81,6 @@ }, "release": { "date": "1/26/2025", - "time": "5:15:26 AM" + "time": "11:16:17 AM" } } \ No newline at end of file diff --git a/renderer/hooks/useThemeSystem.js b/renderer/hooks/useThemeSystem.js index d376c68..77c3793 100644 --- a/renderer/hooks/useThemeSystem.js +++ b/renderer/hooks/useThemeSystem.js @@ -75,7 +75,7 @@ export default function useThemeSystem(game_id) { let base_theme_opac = 0; if (typeof window !== 'undefined') { // localStorage.setItem(key, value) - base_theme_id = window.localStorage.getItem('utheme-id') || 0; + base_theme_id = window.localStorage.getItem('utheme-id') || 2; base_theme_bg = window.localStorage.getItem('utheme-bg') || 0; base_theme_opac = window.localStorage.getItem('utheme-bgopac') || 0; }