cleanup: Use logical assignments

gjs updated mozjs to a version that support assignment operators
for logical operators, so use those where appropriate.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2115>
This commit is contained in:
Florian Müllner 2022-01-18 21:02:04 +01:00 committed by Marge Bot
parent 1fe79a331f
commit b54111ef88
8 changed files with 11 additions and 11 deletions

View File

@ -104,7 +104,7 @@ function initTranslations(domain) {
if (!extension) if (!extension)
throw new Error('initTranslations() can only be called from extensions'); 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 // Expect USER extensions to have a locale/ subfolder, otherwise assume a
// SYSTEM extension that has been installed in the same prefix as the shell // SYSTEM extension that has been installed in the same prefix as the shell
@ -188,7 +188,7 @@ function getSettings(schema) {
if (!extension) if (!extension)
throw new Error('getSettings() can only be called from extensions'); 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; const GioSSS = Gio.SettingsSchemaSource;

View File

@ -329,7 +329,7 @@ function createTimeLabel(date, params) {
function lowerBound(array, val, cmp) { function lowerBound(array, val, cmp) {
let min, max, mid, v; let min, max, mid, v;
cmp = cmp || ((a, b) => a - b); cmp ||= (a, b) => a - b;
if (array.length == 0) if (array.length == 0)
return 0; return 0;

View File

@ -305,7 +305,7 @@ class DBusEventSource extends EventSourceBase {
let changed = false; let changed = false;
for (const id of ids) for (const id of ids)
changed = changed || this._events.delete(id); changed ||= this._events.delete(id);
if (changed) if (changed)
this.emit('changed'); this.emit('changed');
@ -318,7 +318,7 @@ class DBusEventSource extends EventSourceBase {
let changed = false; let changed = false;
for (const id of this._events.keys()) { for (const id of this._events.keys()) {
if (id.startsWith(sourceUid)) if (id.startsWith(sourceUid))
changed = changed || this._events.delete(id); changed ||= this._events.delete(id);
} }
if (changed) if (changed)

View File

@ -119,7 +119,7 @@ class NetworkSecretDialog extends ModalDialog.ModalDialog {
let valid = true; let valid = true;
for (let i = 0; i < this._content.secrets.length; i++) { for (let i = 0; i < this._content.secrets.length; i++) {
let secret = this._content.secrets[i]; let secret = this._content.secrets[i];
valid = valid && secret.valid; valid &&= secret.valid;
} }
this._okButton.button.reactive = valid; this._okButton.button.reactive = valid;
@ -130,7 +130,7 @@ class NetworkSecretDialog extends ModalDialog.ModalDialog {
let valid = true; let valid = true;
for (let i = 0; i < this._content.secrets.length; i++) { for (let i = 0; i < this._content.secrets.length; i++) {
let secret = this._content.secrets[i]; let secret = this._content.secrets[i];
valid = valid && secret.valid; valid &&= secret.valid;
if (secret.key !== null) { if (secret.key !== null) {
if (this._settingName === 'vpn') if (this._settingName === 'vpn')
this._agent.add_vpn_secret(this._requestId, secret.key, secret.value); this._agent.add_vpn_secret(this._requestId, secret.key, secret.value);

View File

@ -1187,7 +1187,7 @@ var MessageTray = GObject.registerClass({
// Filter out acknowledged notifications. // Filter out acknowledged notifications.
let changed = false; let changed = false;
this._notificationQueue = this._notificationQueue.filter(n => { this._notificationQueue = this._notificationQueue.filter(n => {
changed = changed || n.acknowledged; changed ||= n.acknowledged;
return !n.acknowledged; return !n.acknowledged;
}); });

View File

@ -959,7 +959,7 @@ class Panel extends St.Widget {
if (!(indicator instanceof PanelMenu.Button)) if (!(indicator instanceof PanelMenu.Button))
throw new TypeError('Status indicator must be an instance of PanelMenu.Button'); throw new TypeError('Status indicator must be an instance of PanelMenu.Button');
position = position || 0; position ??= 0;
let boxes = { let boxes = {
left: this._leftBox, left: this._leftBox,
center: this._centerBox, center: this._centerBox,

View File

@ -28,7 +28,7 @@ function _setButtonsForChoices(dialog, oldChoices, choices) {
for (let idx = 0; idx < choices.length; idx++) { for (let idx = 0; idx < choices.length; idx++) {
let button = idx; let button = idx;
buttonsChanged = buttonsChanged || oldChoices[idx] !== choices[idx]; buttonsChanged ||= oldChoices[idx] !== choices[idx];
buttons.unshift({ buttons.unshift({
label: choices[idx], label: choices[idx],

View File

@ -2114,7 +2114,7 @@ class Indicator extends PanelMenu.SystemIndicator {
// NONE is also possible, with a connection configured to force no default route // 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) // (but in general we should only prompt a portal if we know there is a portal)
if (GLib.getenv('GNOME_SHELL_CONNECTIVITY_TEST') != null) 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) if (!isPortal || Main.sessionMode.isGreeter)
return; return;