@@ -18,7 +18,7 @@ class FlatpakPortalManager {
1818 if ( this . bus ) {
1919 try {
2020 this . bus . disconnect ( )
21- } catch ( err ) {
21+ } catch {
2222 // Ignore disconnect errors
2323 }
2424 this . bus = null
@@ -66,19 +66,22 @@ class FlatpakPortalManager {
6666 // When disabling autostart, the portal doesn't create a persistent request object.
6767 // No Response signal is emitted, so we can return immediately.
6868 if ( ! enabled ) {
69- await background . RequestBackground ( '' , options )
70- log . info ( 'Stretchly: Autostart disabled via XDG Portal' )
71- return true
69+ try {
70+ await background . RequestBackground ( '' , options )
71+ log . info ( 'Stretchly: Autostart disabled via XDG Portal' )
72+ return true
73+ } catch ( error ) {
74+ log . error ( 'Stretchly: Failed to disable autostart via XDG Portal:' , error )
75+ return false
76+ }
7277 }
7378
7479 // When enabling autostart, we must wait for the Response signal.
7580 // We start listening BEFORE calling the method to avoid race conditions.
7681 const responsePromise = this . _waitForBusResponse ( handleToken , enabled )
7782
78- await background . RequestBackground ( '' , options )
79- . then ( requestPath => {
80- log . info ( `Stretchly: RequestBackground called, request path: ${ requestPath } ` )
81- } )
83+ const requestPath = await background . RequestBackground ( '' , options )
84+ log . info ( `Stretchly: RequestBackground called, request path: ${ requestPath } ` )
8285
8386 return await responsePromise
8487 } catch ( error ) {
@@ -152,8 +155,10 @@ class FlatpakPortalManager {
152155 if ( success ) {
153156 this . settings . set ( 'flatpakAutostart' , true )
154157 }
158+ return success
155159 } catch ( error ) {
156160 log . error ( 'Stretchly: Failed to set autostart (enable) via XDG Portal' , error )
161+ return false
157162 }
158163 }
159164
@@ -163,8 +168,10 @@ class FlatpakPortalManager {
163168 if ( success ) {
164169 this . settings . set ( 'flatpakAutostart' , false )
165170 }
171+ return success
166172 } catch ( error ) {
167173 log . error ( 'Stretchly: Failed to set autostart (disable) via XDG Portal' , error )
174+ return false
168175 }
169176 }
170177
0 commit comments