feat: add auto updater toggle

This commit is contained in:
NoCrypt 2024-08-04 08:41:03 +07:00
parent 5883ebb887
commit 5620a99776
6 changed files with 19 additions and 3 deletions

View file

@ -24,6 +24,8 @@
import { SUPPORTS } from '@/modules/support.js';
import { click } from '@/modules/click.js';
import { client } from '@/modules/torrent.js';
import { settings } from '@/modules/settings.js';
import IPC from '@/modules/ipc.js';
export let page = 'home'
@ -31,6 +33,8 @@
$: maxwidth = $isMobile ? '200px' : '60rem'
onMount(() => {
if($settings.enableAutoUpdate && SUPPORTS.update) IPC.emit('update')
if (SUPPORTS.isAndroid) {
let backButtonPressTimeout;
window.Capacitor.Plugins.App.addListener("backButton", () => {

View file

@ -2,7 +2,7 @@
export const SUPPORTS = {
offscreenRender: true,
update: false,
update: true,
angle: true,
doh: true,
dht: true,

View file

@ -136,6 +136,7 @@ export const defaults = {
slowSeeding: true,
disableStartupVideo: true,
amoledTheme: true,
enableAutoUpdate: true,
torrentPersist: false,
torrentDHT: false,
torrentPeX: false,

View file

@ -4,6 +4,7 @@
import { resetSettings } from '@/modules/settings.js'
import IPC from '@/modules/ipc.js'
import { SUPPORTS } from '@/modules/support.js'
import SettingCard from './SettingCard.svelte';
async function importSettings () {
localStorage.setItem('settings', await navigator.clipboard.readText())
@ -25,6 +26,10 @@
}
setInterval(checkUpdate, 1200000)
</script>
<script>
export let settings
</script>
<div class='d-inline-flex flex-column'>
<button
use:click={importSettings}
@ -39,6 +44,12 @@
Export Settings To Clipboard
</button>
{#if SUPPORTS.update}
<SettingCard title='Enable auto update' description='Enables auto updater upon startup. Disable this if you have issues with it.'>
<div class='custom-switch'>
<input type='checkbox' id='enable-auto-updater' bind:checked={settings.enableAutoUpdate} />
<label for='enable-auto-updater'>{settings.enableAutoUpdate ? 'On' : 'Off'}</label>
</div>
</SettingCard>
<button
use:click={checkUpdate}
class='btn btn-primary mx-20 mt-10'

View file

@ -149,7 +149,7 @@
</Tab>
<Tab>
<div class='root h-full w-full overflow-y-md-auto p-20' use:smoothScroll>
<AppSettings />
<AppSettings bind:settings={$settings} />
<div class='h-250' />
</div>
</Tab>

View file

@ -9,7 +9,7 @@ ipcMain.on('update', () => {
autoUpdater.checkForUpdatesAndNotify()
})
autoUpdater.checkForUpdatesAndNotify()
// autoUpdater.checkForUpdatesAndNotify()
export default class Updater {
hasUpdate = false
/**