mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-17 07:37:24 -05:00
added discord rpc
This commit is contained in:
10
main.js
10
main.js
@@ -6,6 +6,7 @@ const ServiceManager = require('./service-manager');
|
||||
const Patcher = require('./patcher');
|
||||
const UpdateClient = require('./update-client');
|
||||
const FileUpdater = require('./file-updater');
|
||||
const VylaPresence = require('./discord-rpc');
|
||||
|
||||
function getDefaultAppData() {
|
||||
if (process.platform === 'darwin') {
|
||||
@@ -43,6 +44,12 @@ function sendToTauri(event, data) {
|
||||
}
|
||||
|
||||
process.stdin.resume();
|
||||
require('readline').createInterface({ input: process.stdin }).on('line', (line) => {
|
||||
try {
|
||||
const msg = JSON.parse(line);
|
||||
if (msg && msg.type === 'presence') presence.report(msg.payload);
|
||||
} catch (e) { }
|
||||
});
|
||||
process.stdin.on('end', () => {
|
||||
debugLog('stdin closed - parent died. Self-terminating...');
|
||||
process.exit(0);
|
||||
@@ -88,6 +95,7 @@ function liveReposEnabled() {
|
||||
}
|
||||
|
||||
const updateClient = new UpdateClient(APPDATA_DIR);
|
||||
const presence = new VylaPresence({ getConfig: getEnvConfig, log: debugLog });
|
||||
const fileUpdater = new FileUpdater(APPDATA_DIR, updateClient);
|
||||
fileUpdater.onNotice = (message) => sendToTauri('notice', { message });
|
||||
let lastFilePercent = -1;
|
||||
@@ -436,6 +444,7 @@ async function start() {
|
||||
throw new Error(`${e.message}. Check logs in ${LOGS_DIR}`);
|
||||
}
|
||||
debugLog("Ports 3000 and 4890 are ready.");
|
||||
try { presence.start(); } catch (e) { debugLog(`Presence start failed: ${e.message}`); }
|
||||
|
||||
sendToTauri('status', { message: 'All backend services running and healthy.' });
|
||||
debugLog("Sending READY to Tauri.");
|
||||
@@ -448,6 +457,7 @@ async function start() {
|
||||
}
|
||||
|
||||
process.on('exit', () => {
|
||||
try { presence.stop(); } catch (e) { }
|
||||
if (serviceManager) {
|
||||
serviceManager.stopAll();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user