Refactor Steam callback cleanup on app exit

Simplified the cleanup logic for Steam callback pump by removing unnecessary try-catch and optional chaining. The cleanup is now directly registered after requiring Electron modules.
This commit is contained in:
2026-01-01 00:34:57 +13:00
parent 72438af1b6
commit 76f5ef188a
+3 -5
View File
@@ -127,9 +127,10 @@ function initializeSteamworks() {
// This is critical for Steam Input to recognize native controller support // This is critical for Steam Input to recognize native controller support
initializeSteamworks(); initializeSteamworks();
const { app, BrowserWindow, ipcMain, session, screen, shell, dialog, Menu, clipboard, webContents } = require('electron');
// Cleanup Steam callback pump on exit // Cleanup Steam callback pump on exit
try { app.once('before-quit', () => {
app?.once?.('before-quit', () => {
if (steamCallbacksInterval) { if (steamCallbacksInterval) {
clearInterval(steamCallbacksInterval); clearInterval(steamCallbacksInterval);
steamCallbacksInterval = null; steamCallbacksInterval = null;
@@ -138,9 +139,6 @@ try {
steamInput?.shutdown?.(); steamInput?.shutdown?.();
} catch {} } catch {}
}); });
} catch {}
const { app, BrowserWindow, ipcMain, session, screen, shell, dialog, Menu, clipboard, webContents } = require('electron');
const { autoUpdater } = require('electron-updater'); const { autoUpdater } = require('electron-updater');
const { pathToFileURL } = require('url'); const { pathToFileURL } = require('url');
const fs = require('fs'); const fs = require('fs');