From b54111ef886fcedc03818294b574509653cb84ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 18 Jan 2022 21:02:04 +0100 Subject: [PATCH] cleanup: Use logical assignments gjs updated mozjs to a version that support assignment operators for logical operators, so use those where appropriate. Part-of: --- js/misc/extensionUtils.js | 4 ++-- js/misc/util.js | 2 +- js/ui/calendar.js | 4 ++-- js/ui/components/networkAgent.js | 4 ++-- js/ui/messageTray.js | 2 +- js/ui/panel.js | 2 +- js/ui/shellMountOperation.js | 2 +- js/ui/status/network.js | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/js/misc/extensionUtils.js b/js/misc/extensionUtils.js index c86468e4b..e49722409 100644 --- a/js/misc/extensionUtils.js +++ b/js/misc/extensionUtils.js @@ -104,7 +104,7 @@ function initTranslations(domain) { if (!extension) throw new Error('initTranslations() can only be called from extensions'); - domain = domain || extension.metadata['gettext-domain']; + domain ||= extension.metadata['gettext-domain']; // Expect USER extensions to have a locale/ subfolder, otherwise assume a // SYSTEM extension that has been installed in the same prefix as the shell @@ -188,7 +188,7 @@ function getSettings(schema) { if (!extension) throw new Error('getSettings() can only be called from extensions'); - schema = schema || extension.metadata['settings-schema']; + schema ||= extension.metadata['settings-schema']; const GioSSS = Gio.SettingsSchemaSource; diff --git a/js/misc/util.js b/js/misc/util.js index 6a0f6f641..da768566a 100644 --- a/js/misc/util.js +++ b/js/misc/util.js @@ -329,7 +329,7 @@ function createTimeLabel(date, params) { function lowerBound(array, val, cmp) { let min, max, mid, v; - cmp = cmp || ((a, b) => a - b); + cmp ||= (a, b) => a - b; if (array.length == 0) return 0; diff --git a/js/ui/calendar.js b/js/ui/calendar.js index 852f1d0fe..035c7ccc4 100644 --- a/js/ui/calendar.js +++ b/js/ui/calendar.js @@ -305,7 +305,7 @@ class DBusEventSource extends EventSourceBase { let changed = false; for (const id of ids) - changed = changed || this._events.delete(id); + changed ||= this._events.delete(id); if (changed) this.emit('changed'); @@ -318,7 +318,7 @@ class DBusEventSource extends EventSourceBase { let changed = false; for (const id of this._events.keys()) { if (id.startsWith(sourceUid)) - changed = changed || this._events.delete(id); + changed ||= this._events.delete(id); } if (changed) diff --git a/js/ui/components/networkAgent.js b/js/ui/components/networkAgent.js index 92e499302..4f880a4dd 100644 --- a/js/ui/components/networkAgent.js +++ b/js/ui/components/networkAgent.js @@ -119,7 +119,7 @@ class NetworkSecretDialog extends ModalDialog.ModalDialog { let valid = true; for (let i = 0; i < this._content.secrets.length; i++) { let secret = this._content.secrets[i]; - valid = valid && secret.valid; + valid &&= secret.valid; } this._okButton.button.reactive = valid; @@ -130,7 +130,7 @@ class NetworkSecretDialog extends ModalDialog.ModalDialog { let valid = true; for (let i = 0; i < this._content.secrets.length; i++) { let secret = this._content.secrets[i]; - valid = valid && secret.valid; + valid &&= secret.valid; if (secret.key !== null) { if (this._settingName === 'vpn') this._agent.add_vpn_secret(this._requestId, secret.key, secret.value); diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index 8e403f308..de30767e5 100644 --- a/js/ui/messageTray.js +++ b/js/ui/messageTray.js @@ -1187,7 +1187,7 @@ var MessageTray = GObject.registerClass({ // Filter out acknowledged notifications. let changed = false; this._notificationQueue = this._notificationQueue.filter(n => { - changed = changed || n.acknowledged; + changed ||= n.acknowledged; return !n.acknowledged; }); diff --git a/js/ui/panel.js b/js/ui/panel.js index ce1c49308..5e9e44660 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -959,7 +959,7 @@ class Panel extends St.Widget { if (!(indicator instanceof PanelMenu.Button)) throw new TypeError('Status indicator must be an instance of PanelMenu.Button'); - position = position || 0; + position ??= 0; let boxes = { left: this._leftBox, center: this._centerBox, diff --git a/js/ui/shellMountOperation.js b/js/ui/shellMountOperation.js index d0d03491f..dd8eb5f77 100644 --- a/js/ui/shellMountOperation.js +++ b/js/ui/shellMountOperation.js @@ -28,7 +28,7 @@ function _setButtonsForChoices(dialog, oldChoices, choices) { for (let idx = 0; idx < choices.length; idx++) { let button = idx; - buttonsChanged = buttonsChanged || oldChoices[idx] !== choices[idx]; + buttonsChanged ||= oldChoices[idx] !== choices[idx]; buttons.unshift({ label: choices[idx], diff --git a/js/ui/status/network.js b/js/ui/status/network.js index f20bcb538..dec7adc00 100644 --- a/js/ui/status/network.js +++ b/js/ui/status/network.js @@ -2114,7 +2114,7 @@ class Indicator extends PanelMenu.SystemIndicator { // NONE is also possible, with a connection configured to force no default route // (but in general we should only prompt a portal if we know there is a portal) if (GLib.getenv('GNOME_SHELL_CONNECTIVITY_TEST') != null) - isPortal = isPortal || this._client.connectivity < NM.ConnectivityState.FULL; + isPortal ||= this._client.connectivity < NM.ConnectivityState.FULL; if (!isPortal || Main.sessionMode.isGreeter) return;