11import log from 'electron-log/main.js'
22import AutoLaunch from 'auto-launch'
33import FlatpakPortalManager from './flatpakPortalManager.js'
4- import { insideFlatpak } from './utils.js'
4+ import { insideFlatpak , insideWindowsStore } from './utils.js'
55
66class AutostartManager {
77 constructor ( {
8- platform,
9- windowsStore,
108 app,
119 settings
1210 } ) {
13- this . platform = platform
14- this . windowsStore = windowsStore
1511 this . app = app
1612
1713 this . isFlatpak = insideFlatpak ( )
14+ this . isWindowsStore = insideWindowsStore ( )
1815
1916 if ( this . isFlatpak ) {
2017 this . flatpakPortalManager = new FlatpakPortalManager ( settings )
21- } else if ( this . platform === 'linux' ) {
18+ } else if ( process . platform === 'linux' ) {
2219 this . nativeAutoLauncher = new AutoLaunch ( { name : 'stretchly' } )
23- } else if ( this . platform === 'win32' && this . windowsStore ) {
20+ } else if ( this . isWindowsStore ) {
2421 this . windowsStoreAutoLauncher = new AutoLaunch ( {
2522 name : 'Stretchly' ,
2623 path : '33881JanHovancik.stretchly_24fg4m0zq65je!Stretchly' ,
@@ -30,13 +27,13 @@ class AutostartManager {
3027 }
3128
3229 async setAutostartEnabled ( value ) {
33- log . info ( `Stretchly: setting autostart to ${ value } on ${ this . platform } ${ this . platform === 'win32' && this . windowsStore ? ' (Windows Store)' : '' } ${ this . isFlatpak ? ' (Flatpak)' : '' } ` )
30+ log . info ( `Stretchly: setting autostart to ${ value } on ${ process . platform } ${ this . isWindowsStore ? ' (Windows Store)' : '' } ${ this . isFlatpak ? ' (Flatpak)' : '' } ` )
3431
3532 if ( this . isFlatpak ) {
3633 await ( value ? this . flatpakPortalManager . enableAutostart ( ) : this . flatpakPortalManager . disableAutostart ( ) )
37- } else if ( this . platform === 'linux' ) {
34+ } else if ( process . platform === 'linux' ) {
3835 await ( value ? this . nativeAutoLauncher . enable ( ) : this . nativeAutoLauncher . disable ( ) )
39- } else if ( this . platform === 'win32' && this . windowsStore ) {
36+ } else if ( this . isWindowsStore ) {
4037 await ( value ? this . windowsStoreAutoLauncher . enable ( ) : this . windowsStoreAutoLauncher . disable ( ) )
4138 } else {
4239 this . app . setLoginItemSettings ( { openAtLogin : value } )
@@ -46,9 +43,9 @@ class AutostartManager {
4643 async autoLaunchStatus ( ) {
4744 if ( this . isFlatpak ) {
4845 return await this . flatpakPortalManager . isAutostartEnabled ( )
49- } else if ( this . platform === 'linux' ) {
46+ } else if ( process . platform === 'linux' ) {
5047 return await this . nativeAutoLauncher . isEnabled ( )
51- } else if ( this . platform === 'win32' && this . windowsStore ) {
48+ } else if ( this . isWindowsStore ) {
5249 return await this . windowsStoreAutoLauncher . isEnabled ( )
5350 } else {
5451 return this . app . getLoginItemSettings ( ) . openAtLogin
0 commit comments