diff options
| author | AAGaming <aagaming@riseup.net> | 2024-07-28 20:25:21 -0400 |
|---|---|---|
| committer | AAGaming <aagaming@riseup.net> | 2024-08-03 14:04:22 -0400 |
| commit | 52b40b7d0c175da3e1033b1a621d18a04ac6b1fa (patch) | |
| tree | d4404ed0323e65287b0ce90251b46b87e06d9424 | |
| parent | 3cb150b9fbe37d8df001c456d7bef957f5cd92f7 (diff) | |
| download | decky-loader-52b40b7d0c175da3e1033b1a621d18a04ac6b1fa.tar.gz decky-loader-52b40b7d0c175da3e1033b1a621d18a04ac6b1fa.zip | |
wait for SP to exist before loading plugins when booted in gamepadui mode
| -rw-r--r-- | frontend/src/plugin-loader.tsx | 16 | ||||
| -rw-r--r-- | frontend/src/router-hook.tsx | 2 |
2 files changed, 14 insertions, 4 deletions
diff --git a/frontend/src/plugin-loader.tsx b/frontend/src/plugin-loader.tsx index 74732ac7..28927f1e 100644 --- a/frontend/src/plugin-loader.tsx +++ b/frontend/src/plugin-loader.tsx @@ -5,6 +5,7 @@ import { PanelSection, PanelSectionRow, QuickAccessTab, + findSP, quickAccessMenuClasses, showModal, sleep, @@ -29,7 +30,7 @@ import { HiddenPluginsService } from './hidden-plugins-service'; import Logger from './logger'; import { NotificationService } from './notification-service'; import { InstallType, Plugin, PluginLoadType } from './plugin'; -import RouterHook from './router-hook'; +import RouterHook, { UIMode } from './router-hook'; import { deinitSteamFixes, initSteamFixes } from './steamfixes'; import { checkForPluginUpdates } from './store'; import TabsHook from './tabs-hook'; @@ -166,7 +167,6 @@ class PluginLoader extends Logger { this.initPluginBackendAPI(); Promise.all([this.getUserInfo(), this.updateVersion()]) - .then(() => sleep(800)) .then(() => this.loadPlugins()) .then(() => this.checkPluginUpdates()) .then(() => this.log('Initialized')); @@ -178,6 +178,17 @@ class PluginLoader extends Logger { >('loader/get_plugins'); private async loadPlugins() { + let registration: any; + const uiMode = await new Promise(r => registration = SteamClient.UI.RegisterForUIModeChanged((mode: UIMode) => { + r(mode); + registration.unregister() + })); + if (uiMode == UIMode.BigPicture) { + // wait for SP window to exist before loading plugins + while (!findSP()) { + await sleep(100); + } + } const plugins = await this.getPluginsFromBackend(); const pluginLoadPromises = []; const loadStart = performance.now(); @@ -565,7 +576,6 @@ class PluginLoader extends Logger { method = request.method; delete req.method; } - // this is terrible but a. we're going to redo this entire method anyway and b. it was already terrible try { const ret = await DeckyBackend.call< [method: string, url: string, extra_opts?: any], diff --git a/frontend/src/router-hook.tsx b/frontend/src/router-hook.tsx index 98aa6863..cc00643a 100644 --- a/frontend/src/router-hook.tsx +++ b/frontend/src/router-hook.tsx @@ -31,7 +31,7 @@ declare global { } } -enum UIMode { +export enum UIMode { BigPicture = 4, Desktop = 7, } |
