diff options
| author | AAGaming <aa@mail.catvibers.me> | 2023-01-07 20:33:28 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-07 17:33:28 -0800 |
| commit | b72b32761058767d143e9ff08dc238c5ac9b777c (patch) | |
| tree | ab3cb1d855a20c37355f1b0c650647cd733a1d5d /backend/main.py | |
| parent | b8fdff80933b0164096c94358ab8123722906e0d (diff) | |
| download | decky-loader-b72b32761058767d143e9ff08dc238c5ac9b777c.tar.gz decky-loader-b72b32761058767d143e9ff08dc238c5ac9b777c.zip | |
Fix reloading UI on updates and restarting steam (#303)v2.4.9-pre1
Diffstat (limited to 'backend/main.py')
| -rw-r--r-- | backend/main.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/backend/main.py b/backend/main.py index b6cab774..b99e7df1 100644 --- a/backend/main.py +++ b/backend/main.py @@ -168,15 +168,15 @@ class PluginManager: async def inject_javascript(self, tab: Tab, first=False, request=None): logger.info("Loading Decky frontend!") try: - # if first: - # if await tab.has_global_var("deckyHasLoaded", False): - # tabs = await get_tabs() - # for t in tabs: - # if t.title != "Steam" and t.title != "SP": - # logger.debug("Closing tab: " + getattr(t, "title", "Untitled")) - # await t.close() - # await sleep(0.5) - await tab.evaluate_js("try{if (window.deckyHasLoaded){setTimeout(() => SteamClient.User.StartShutdown(false), 100)}else{window.deckyHasLoaded = true;(async()=>{try{while(!window.SP_REACT){await new Promise(r => setTimeout(r, 10))};await import('http://localhost:1337/frontend/index.js')}catch(e){console.error(e)};})();}}catch(e){console.error(e)}", False, False, False) + if first: + if await tab.has_global_var("deckyHasLoaded", False): + tabs = await get_tabs() + for t in tabs: + if not t.title or (t.title != "Steam" and t.title != "SP"): + logger.debug("Closing tab: " + getattr(t, "title", "Untitled")) + await t.close() + await sleep(0.5) + await tab.evaluate_js("try{if (window.deckyHasLoaded){setTimeout(() => location.reload(), 100)}else{window.deckyHasLoaded = true;(async()=>{try{while(!window.SP_REACT){await new Promise(r => setTimeout(r, 10))};await import('http://localhost:1337/frontend/index.js')}catch(e){console.error(e)};})();}}catch(e){console.error(e)}", False, False, False) except: logger.info("Failed to inject JavaScript into tab\n" + format_exc()) pass |
