summaryrefslogtreecommitdiff
path: root/frontend/src/updater.ts
diff options
context:
space:
mode:
authorAAGaming <aa@mail.catvibers.me>2022-07-14 22:51:55 -0400
committerGitHub <noreply@github.com>2022-07-14 22:51:55 -0400
commit8c8cf180fad2ad6951ad7ce6b74e6c163fa01d18 (patch)
treedd051aaa7928867657c955cf2cad5143ca72f658 /frontend/src/updater.ts
parent05d11cfff037734f7aa6b6ac8e701eacd9f38d60 (diff)
downloaddecky-loader-8c8cf180fad2ad6951ad7ce6b74e6c163fa01d18.tar.gz
decky-loader-8c8cf180fad2ad6951ad7ce6b74e6c163fa01d18.zip
Updater for decky-loader (#117)
* Add an updater in settings for decky-loader * add chmod * remove junk comments
Diffstat (limited to 'frontend/src/updater.ts')
-rw-r--r--frontend/src/updater.ts30
1 files changed, 30 insertions, 0 deletions
diff --git a/frontend/src/updater.ts b/frontend/src/updater.ts
new file mode 100644
index 00000000..692a7a70
--- /dev/null
+++ b/frontend/src/updater.ts
@@ -0,0 +1,30 @@
+import { sleep } from 'decky-frontend-lib';
+
+export enum Branches {
+ Release,
+ Prerelease,
+ Nightly,
+}
+
+export interface DeckyUpdater {
+ updateProgress: (val: number) => void;
+ finish: () => void;
+}
+
+export async function callUpdaterMethod(methodName: string, args = {}) {
+ const response = await fetch(`http://127.0.0.1:1337/updater/${methodName}`, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify(args),
+ });
+
+ return response.json();
+}
+
+export async function finishUpdate() {
+ callUpdaterMethod('do_restart');
+ await sleep(3000);
+ location.reload();
+}