Skip to content

Commit

Permalink
fix for discord rpc causing app to hang with white screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Dekita committed Jan 26, 2025
1 parent c6686f4 commit 065269d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
5 changes: 3 additions & 2 deletions main/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -83,6 +84,6 @@ DEAP.launch({
// RPC.pause();
// });
// });
RPC.start();
RPC.startWhenReady();
}
});
19 changes: 18 additions & 1 deletion main/dek/discord-rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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();
Expand All @@ -46,6 +61,8 @@ export default {
this.update();
}, UPDATE_FREQ);
this.update();
}).catch(error => {
console.error('Discord RPC error:', error);
});
},
stop() {
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -81,6 +81,6 @@
},
"release": {
"date": "1/26/2025",
"time": "5:15:26 AM"
"time": "11:16:17 AM"
}
}
2 changes: 1 addition & 1 deletion renderer/hooks/useThemeSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 065269d

Please # to comment.