Skip to content

Commit

Permalink
fix: include Decky version in request for index.js
Browse files Browse the repository at this point in the history
This avoids the If-Modified-Since logic in aiohttp and makes
sure the script is always reloaded.
  • Loading branch information
K900 committed Aug 22, 2023
1 parent e3a8de2 commit 89f37f4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
# local modules
from browser import PluginBrowser
from helpers import (REMOTE_DEBUGGER_UNIT, csrf_middleware, get_csrf_token,
mkdir_as_user, get_system_pythonpaths, get_effective_user_id)

mkdir_as_user, get_system_pythonpaths, get_effective_user_id,
get_loader_version)

from injector import get_gamepadui_tab, Tab, get_tabs, close_old_tabs
from loader import Loader
from settings import SettingsManager
Expand Down Expand Up @@ -162,7 +163,7 @@ async def inject_javascript(self, tab: Tab, first=False, request=None):
if first:
if await tab.has_global_var("deckyHasLoaded", False):
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)
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?v=%s')}catch(e){console.error(e)};})();}}catch(e){console.error(e)}" % (get_loader_version(), ), False, False, False)
except:
logger.info("Failed to inject JavaScript into tab\n" + format_exc())
pass
Expand Down

0 comments on commit 89f37f4

Please sign in to comment.