diff options
| author | TrainDoctor <traindoctor@protonmail.com> | 2023-01-15 17:40:47 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-15 17:40:47 -0800 |
| commit | 5fdcc56409a0bc75171df25ca50b6e09ffe7bf3a (patch) | |
| tree | 2e35f9fe6246dca82ac415298af5c2bfe9c879b5 /backend | |
| parent | 915997d1495cc47f60e148252df3e4878a1179a5 (diff) | |
| download | decky-loader-5fdcc56409a0bc75171df25ca50b6e09ffe7bf3a.tar.gz decky-loader-5fdcc56409a0bc75171df25ca50b6e09ffe7bf3a.zip | |
Aa/bump dfl navigation fix jan2023 (#341)v2.4.10-pre1
* fix React DevTools
* bump DFL to fix Navigation
* Bump DFL and add shims
* fix shims not applying due to timing issue
Co-authored-by: AAGaming <aa@mail.catvibers.me>
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/injector.py | 13 | ||||
| -rw-r--r-- | backend/main.py | 9 | ||||
| -rw-r--r-- | backend/utilities.py | 6 |
3 files changed, 18 insertions, 10 deletions
diff --git a/backend/injector.py b/backend/injector.py index f4dfd384..d77de13a 100644 --- a/backend/injector.py +++ b/backend/injector.py @@ -394,9 +394,12 @@ async def get_tab_lambda(test) -> Tab: raise ValueError(f"Tab not found by lambda") return tab +def tab_is_gamepadui(t: Tab) -> bool: + return "https://steamloopback.host/routes/" in t.url and (t.title == "Steam Shared Context presented by Valve™" or t.title == "Steam" or t.title == "SP") + async def get_gamepadui_tab() -> Tab: tabs = await get_tabs() - tab = next((i for i in tabs if ("https://steamloopback.host/routes/" in i.url and (i.title == "Steam Shared Context presented by Valve™" or i.title == "Steam" or i.title == "SP"))), None) + tab = next((i for i in tabs if tab_is_gamepadui(i)), None) if not tab: raise ValueError(f"GamepadUI Tab not found") return tab @@ -405,3 +408,11 @@ async def inject_to_tab(tab_name, js, run_async=False): tab = await get_tab(tab_name) return await tab.evaluate_js(js, run_async) + +async def close_old_tabs(): + tabs = await get_tabs() + for t in tabs: + if not t.title or (t.title != "Steam Shared Context presented by Valve™" and t.title != "Steam" and t.title != "SP"): + logger.debug("Closing tab: " + getattr(t, "title", "Untitled")) + await t.close() + await sleep(0.5)
\ No newline at end of file diff --git a/backend/main.py b/backend/main.py index b99e7df1..44311cf3 100644 --- a/backend/main.py +++ b/backend/main.py @@ -22,7 +22,7 @@ from helpers import (REMOTE_DEBUGGER_UNIT, csrf_middleware, get_csrf_token, get_home_path, get_homebrew_path, get_user, get_user_group, set_user, set_user_group, stop_systemd_unit, start_systemd_unit) -from injector import get_gamepadui_tab, Tab, get_tabs +from injector import get_gamepadui_tab, Tab, get_tabs, close_old_tabs from loader import Loader from settings import SettingsManager from updater import Updater @@ -170,12 +170,7 @@ class PluginManager: try: 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 close_old_tabs() 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()) diff --git a/backend/utilities.py b/backend/utilities.py index 0723402f..88e7d0bf 100644 --- a/backend/utilities.py +++ b/backend/utilities.py @@ -7,7 +7,7 @@ from asyncio import sleep, start_server, gather, open_connection from aiohttp import ClientSession, web from logging import getLogger -from injector import inject_to_tab, get_gamepadui_tab +from injector import inject_to_tab, get_gamepadui_tab, close_old_tabs import helpers import subprocess @@ -251,6 +251,7 @@ class Utilities: self.logger.info("Connected to React DevTools, loading script") tab = await get_gamepadui_tab() # RDT needs to load before React itself to work. + await close_old_tabs() result = await tab.reload_and_evaluate(script) self.logger.info(result) @@ -262,5 +263,6 @@ class Utilities: self.logger.info("Disabling React DevTools") tab = await get_gamepadui_tab() self.rdt_script_id = None - await tab.evaluate_js("SteamClient.User.StartRestart();", False, True, False) + await close_old_tabs() + await tab.evaluate_js("location.reload();", False, True, False) self.logger.info("React DevTools disabled") |
