diff --git a/js/misc/loginManager.js b/js/misc/loginManager.js index 6317b1dc4..fb61d64cb 100644 --- a/js/misc/loginManager.js +++ b/js/misc/loginManager.js @@ -146,25 +146,31 @@ var LoginManagerSystemd = class extends Signals.EventEmitter { } async canSuspend() { + let canSuspend, needsAuth; + try { const [result] = await this._proxy.CanSuspendAsync(); - const needsAuth = result === 'challenge'; - const canSuspend = needsAuth || result === 'yes'; - return [canSuspend, needsAuth]; + needsAuth = result === 'challenge'; + canSuspend = needsAuth || result === 'yes'; } catch (error) { - return [false, false]; + canSuspend = false; + needsAuth = false; } + return {canSuspend, needsAuth}; } async canRebootToBootLoaderMenu() { + let canRebootToBootLoaderMenu, needsAuth; + try { const [result] = await this._proxy.CanRebootToBootLoaderMenuAsync(); - const needsAuth = result[0] === 'challenge'; - const canRebootToBootLoaderMenu = needsAuth || result[0] === 'yes'; - return [canRebootToBootLoaderMenu, needsAuth]; + needsAuth = result[0] === 'challenge'; + canRebootToBootLoaderMenu = needsAuth || result[0] === 'yes'; } catch (error) { - return [false, false]; + canRebootToBootLoaderMenu = false; + needsAuth = false; } + return {canRebootToBootLoaderMenu, needsAuth}; } setRebootToBootLoaderMenu() { @@ -209,11 +215,17 @@ var LoginManagerDummy = class extends Signals.EventEmitter { } canSuspend() { - return new Promise(resolve => resolve([false, false])); + return new Promise(resolve => resolve({ + canSuspend: false, + needsAuth: false, + })); } canRebootToBootLoaderMenu() { - return new Promise(resolve => resolve([false, false])); + return new Promise(resolve => resolve({ + canRebootToBootLoaderMenu: false, + needsAuth: false, + })); } setRebootToBootLoaderMenu() { diff --git a/js/misc/systemActions.js b/js/misc/systemActions.js index 444ab4bad..c57afe5b5 100644 --- a/js/misc/systemActions.js +++ b/js/misc/systemActions.js @@ -351,7 +351,7 @@ const SystemActions = GObject.registerClass({ } async _updateHaveSuspend() { - const [canSuspend, needsAuth] = await this._loginManager.canSuspend(); + const {canSuspend, needsAuth} = await this._loginManager.canSuspend(); this._canHaveSuspend = canSuspend; this._suspendNeedsAuth = needsAuth; this._updateSuspend(); diff --git a/js/ui/endSessionDialog.js b/js/ui/endSessionDialog.js index 5723a221c..ca24d0698 100644 --- a/js/ui/endSessionDialog.js +++ b/js/ui/endSessionDialog.js @@ -305,7 +305,7 @@ class EndSessionDialog extends ModalDialog.ModalDialog { } async _getCanRebootToBootLoaderMenu() { - const [canRebootToBootLoaderMenu] = await this._loginManager.canRebootToBootLoaderMenu(); + const {canRebootToBootLoaderMenu} = await this._loginManager.canRebootToBootLoaderMenu(); this._canRebootToBootLoaderMenu = canRebootToBootLoaderMenu; }