cleanup: Don't use comparison operator when checking falsy values

We mostly use the regular == and != comparison operators over their
type-safe === and !== counterparts. This is about to change, but there
are some places where we don't care whether a value is null, undefined
or 0; just check for falsiness there instead of using operators, so
we can start to consistently use the type-safe operators everywhere
else in a follow-up commit.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/91
This commit is contained in:
Florian Müllner
2019-08-07 03:58:03 +02:00
committed by Florian Müllner
parent eb79f5b512
commit ed7a292805
5 changed files with 11 additions and 11 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ class WindowMover {
});
let addedApps = ids.map(id => this._appSystem.lookup_app(id)).filter(
app => app != null && !this._appData.has(app)
app => app && !this._appData.has(app)
);
addedApps.forEach(app => {
let data = {
+1 -1
View File
@@ -53,7 +53,7 @@ class MountMenuItem extends PopupMenu.PopupBaseMenuItem {
let volume = this.mount.get_volume();
if (volume == null) {
if (!volume) {
// probably a GDaemonMount, could be network or
// local, but we can't tell; assume it's local for now
return true;
+4 -4
View File
@@ -366,7 +366,7 @@ var PlacesManager = class {
for (let i = 0; i < dirs.length; i++) {
let specialPath = GLib.get_user_special_dir(dirs[i]);
if (specialPath == null || specialPath == homePath)
if (!specialPath || specialPath == homePath)
continue;
let file = Gio.File.new_for_path(specialPath), info;
@@ -415,7 +415,7 @@ var PlacesManager = class {
networkVolumes.push(volumes[j]);
} else {
let mount = volumes[j].get_mount();
if (mount != null)
if (mount)
this._addMount('devices', mount);
}
}
@@ -424,7 +424,7 @@ var PlacesManager = class {
/* add all volumes that is not associated with a drive */
let volumes = this._volumeMonitor.get_volumes();
for (let i = 0; i < volumes.length; i++) {
if (volumes[i].get_drive() != null)
if (volumes[i].get_drive())
continue;
let identifier = volumes[i].get_identifier('class');
@@ -432,7 +432,7 @@ var PlacesManager = class {
networkVolumes.push(volumes[i]);
} else {
let mount = volumes[i].get_mount();
if (mount != null)
if (mount)
this._addMount('devices', mount);
}
}
+1 -1
View File
@@ -24,7 +24,7 @@ let MyWorkspacesDisplay = class extends WorkspacesDisplay {
}
show(...args) {
if (this._scrollEventId == 0) {
if (!this._scrollEventId) {
this._scrollEventId = Main.windowPicker.connect('scroll-event',
this._onScrollEvent.bind(this));
}
+4 -4
View File
@@ -61,7 +61,7 @@ var MyWorkspace = class extends Workspace.Workspace {
}
showTooltip() {
if (this._tip == null || this._actualGeometry == null)
if (!this._tip || !this._actualGeometry)
return;
this._tip.text = (this.metaWorkspace.index() + 1).toString();
@@ -83,7 +83,7 @@ var MyWorkspace = class extends Workspace.Workspace {
}
hideTooltip() {
if (this._tip == null)
if (!this._tip)
return;
if (!this._tip.get_parent())
return;
@@ -100,14 +100,14 @@ var MyWorkspace = class extends Workspace.Workspace {
showWindowsTooltips() {
for (let i in this._windowOverlays) {
if (this._windowOverlays[i] != null)
if (this._windowOverlays[i])
this._windowOverlays[i].showTooltip();
}
}
hideWindowsTooltips() {
for (let i in this._windowOverlays) {
if (this._windowOverlays[i] != null)
if (this._windowOverlays[i])
this._windowOverlays[i].hideTooltip();
}
}