mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
fix(update): ensure update check is only performed in Tauri environment
This commit is contained in:
1 parent
01bbf396a9
commit
8222d82b01
1 file changed
+34
-32
+34
-32
@@ -121,41 +121,43 @@ export class AppComponent {
|
||||
}
|
||||
|
||||
async checkForUpdates() {
|
||||
const update = await check();
|
||||
if (update?.available) {
|
||||
console.log(
|
||||
`found update ${update.version} from ${update.date} with notes ${update.body}`
|
||||
);
|
||||
let downloaded = 0;
|
||||
let contentLength = 0;
|
||||
if (isTauri()) {
|
||||
const update = await check();
|
||||
if (update?.available) {
|
||||
console.log(
|
||||
`found update ${update.version} from ${update.date} with notes ${update.body}`
|
||||
);
|
||||
let downloaded = 0;
|
||||
let contentLength = 0;
|
||||
|
||||
const wantsUpdate = await ask(
|
||||
`New version ${update.version} is available. Do you want to update now?`
|
||||
);
|
||||
const wantsUpdate = await ask(
|
||||
`New version ${update.version} is available. Do you want to update now?`
|
||||
);
|
||||
|
||||
if (wantsUpdate) {
|
||||
await update.downloadAndInstall((event) => {
|
||||
switch (event.event) {
|
||||
case 'Started':
|
||||
contentLength = event.data.contentLength;
|
||||
console.log(
|
||||
`started downloading ${event.data.contentLength} bytes`
|
||||
);
|
||||
break;
|
||||
case 'Progress':
|
||||
downloaded += event.data.chunkLength;
|
||||
console.log(
|
||||
`downloaded ${downloaded} from ${contentLength}`
|
||||
);
|
||||
break;
|
||||
case 'Finished':
|
||||
console.log('download finished');
|
||||
break;
|
||||
}
|
||||
});
|
||||
if (wantsUpdate) {
|
||||
await update.downloadAndInstall((event) => {
|
||||
switch (event.event) {
|
||||
case 'Started':
|
||||
contentLength = event.data.contentLength;
|
||||
console.log(
|
||||
`started downloading ${event.data.contentLength} bytes`
|
||||
);
|
||||
break;
|
||||
case 'Progress':
|
||||
downloaded += event.data.chunkLength;
|
||||
console.log(
|
||||
`downloaded ${downloaded} from ${contentLength}`
|
||||
);
|
||||
break;
|
||||
case 'Finished':
|
||||
console.log('download finished');
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
console.log('update installed');
|
||||
await relaunch();
|
||||
console.log('update installed');
|
||||
await relaunch();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user