Skip to content

Commit

Permalink
more updater fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AAGaming00 committed Jul 15, 2022
1 parent e07827c commit f015e00
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions backend/injector.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def _send_devtools_cmd(self, dc, receive=True):
return (await self.websocket.receive_json()) if receive else None
raise RuntimeError("Websocket not opened")

async def evaluate_js(self, js, run_async=False, manage_socket=True):
async def evaluate_js(self, js, run_async=False, manage_socket=True, get_result=True):
if manage_socket:
await self.open_websocket()

Expand All @@ -45,7 +45,7 @@ async def evaluate_js(self, js, run_async=False, manage_socket=True):
"userGesture": True,
"awaitPromise": run_async
}
})
}, get_result)

if manage_socket:
await self.client.close()
Expand Down
6 changes: 2 additions & 4 deletions backend/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async def get_version(self):
return {
"current": self.localVer,
"remote": self.remoteVer,
"updatable": self.remoteVer != None
"updatable": self.localVer != None
}
else:
return {"current": "unknown", "updatable": False}
Expand Down Expand Up @@ -103,8 +103,7 @@ async def do_update(self):
raw += len(c)
new_progress = round((raw / total) * 100)
if progress != new_progress:
if new_progress - progress>= 2:
self.context.loop.create_task(tab.evaluate_js(f"window.DeckyUpdater.updateProgress({progress})", False, False))
self.context.loop.create_task(tab.evaluate_js(f"window.DeckyUpdater.updateProgress({new_progress})", False, False, False))
progress = new_progress

with open(path.join(getcwd(), ".loader.version"), "w") as out:
Expand All @@ -119,4 +118,3 @@ async def do_update(self):
async def do_restart(self):
call(["systemctl", "daemon-reload"])
call(["systemctl", "restart", "plugin_loader"])
exit(0)
7 changes: 3 additions & 4 deletions frontend/src/components/settings/pages/general/Updater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ export default function UpdaterSettings() {
>
{updateProgress == -1 ? (
<DialogButton
disabled={!versionInfo?.updatable || !versionInfo?.remote || checkingForUpdates}
disabled={!versionInfo?.updatable || checkingForUpdates}
onClick={
versionInfo?.remote?.tag_name == versionInfo?.current
!versionInfo?.remote || versionInfo?.remote?.tag_name == versionInfo?.current
? async () => {
setCheckingForUpdates(true);
const res = (await callUpdaterMethod('check_for_updates')) as { result: VerInfo };
Expand All @@ -79,7 +79,7 @@ export default function UpdaterSettings() {
>
{checkingForUpdates
? 'Checking'
: versionInfo?.remote?.tag_name == versionInfo?.current
: !versionInfo?.remote || versionInfo?.remote?.tag_name == versionInfo?.current
? 'Check For Updates'
: 'Install Update'}
</DialogButton>
Expand All @@ -88,7 +88,6 @@ export default function UpdaterSettings() {
layout="inline"
bottomSeparator={false}
nProgress={updateProgress}
nTransitionSec={0.01}
indeterminate={reloading}
sOperationText={reloading ? 'Reloading' : 'Updating'}
/>
Expand Down

0 comments on commit f015e00

Please sign in to comment.