Skip to content

Commit

Permalink
feat: add auto updater toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
NoCrypt committed Aug 4, 2024
1 parent 5883ebb commit 5620a99
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions common/Router.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@
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'
$: minwidth = $isMobile ? '200px' : '35rem'
$: maxwidth = $isMobile ? '200px' : '60rem'
onMount(() => {
if($settings.enableAutoUpdate && SUPPORTS.update) IPC.emit('update')
if (SUPPORTS.isAndroid) {
let backButtonPressTimeout;
window.Capacitor.Plugins.App.addListener("backButton", () => {
Expand Down
2 changes: 1 addition & 1 deletion common/modules/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

export const SUPPORTS = {
offscreenRender: true,
update: false,
update: true,
angle: true,
doh: true,
dht: true,
Expand Down
1 change: 1 addition & 0 deletions common/modules/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export const defaults = {
slowSeeding: true,
disableStartupVideo: true,
amoledTheme: true,
enableAutoUpdate: true,
torrentPersist: false,
torrentDHT: false,
torrentPeX: false,
Expand Down
11 changes: 11 additions & 0 deletions common/views/Settings/AppSettings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -25,6 +26,10 @@
}
setInterval(checkUpdate, 1200000)
</script>
<script>
export let settings
</script>

<div class='d-inline-flex flex-column'>
<button
use:click={importSettings}
Expand All @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion common/views/Settings/Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion electron/src/main/updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ipcMain.on('update', () => {
autoUpdater.checkForUpdatesAndNotify()
})

autoUpdater.checkForUpdatesAndNotify()
// autoUpdater.checkForUpdatesAndNotify()
export default class Updater {
hasUpdate = false
/**
Expand Down

0 comments on commit 5620a99

Please sign in to comment.