diff --git a/js/extensionPrefs/main.js b/js/extensionPrefs/main.js index 43efa95e9..24ecdc165 100644 --- a/js/extensionPrefs/main.js +++ b/js/extensionPrefs/main.js @@ -582,12 +582,12 @@ class ExtensionRow extends Gtk.ListBoxRow { _isEnabled() { let extensions = this._settings.get_strv('enabled-extensions'); - return extensions.indexOf(this.uuid) != -1; + return extensions.includes(this.uuid); } _enable() { let extensions = this._settings.get_strv('enabled-extensions'); - if (extensions.indexOf(this.uuid) != -1) + if (extensions.includes(this.uuid)) return; extensions.push(this.uuid); diff --git a/js/misc/extensionUtils.js b/js/misc/extensionUtils.js index cf308b31f..89a085d68 100644 --- a/js/misc/extensionUtils.js +++ b/js/misc/extensionUtils.js @@ -31,7 +31,7 @@ function getCurrentExtension() { // Search for an occurrence of an extension stack frame // Start at 1 because 0 is the stack frame of this function for (let i = 1; i < stack.length; i++) { - if (stack[i].indexOf('/gnome-shell/extensions/') > -1) { + if (stack[i].includes('/gnome-shell/extensions/')) { extensionStackLine = stack[i]; break; } diff --git a/js/misc/keyboardManager.js b/js/misc/keyboardManager.js index 99e100231..ae71b646e 100644 --- a/js/misc/keyboardManager.js +++ b/js/misc/keyboardManager.js @@ -125,7 +125,7 @@ var KeyboardManager = class { _getLocaleLayout() { let locale = GLib.get_language_names()[0]; - if (locale.indexOf('_') == -1) + if (!locale.includes('_')) locale = DEFAULT_LOCALE; let [found, , id] = GnomeDesktop.get_input_source_from_locale(locale); diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index ea86c81b9..00019772a 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -69,7 +69,7 @@ function _getCategories(info) { function _listsIntersect(a, b) { for (let itemA of a) - if (b.indexOf(itemA) >= 0) + if (b.includes(itemA)) return true; return false; } @@ -1165,7 +1165,7 @@ var FolderIcon = class FolderIcon { let excludedApps = this._folder.get_strv('excluded-apps'); let appSys = Shell.AppSystem.get_default(); let addAppId = appId => { - if (excludedApps.indexOf(appId) >= 0) + if (excludedApps.includes(appId)) return; let app = appSys.lookup_app(appId); @@ -1728,7 +1728,7 @@ var AppIconMenu = class AppIconMenu extends PopupMenu.PopupMenu { let appInfo = this._source.app.get_app_info(); let actions = appInfo.list_actions(); if (this._source.app.can_open_new_window() && - actions.indexOf('new-window') == -1) { + actions.includes('new-window')) { this._newWindowMenuItem = this._appendMenuItem(_("New Window")); this._newWindowMenuItem.connect('activate', () => { if (this._source.app.state == Shell.AppState.STOPPED) @@ -1742,7 +1742,7 @@ var AppIconMenu = class AppIconMenu extends PopupMenu.PopupMenu { if (discreteGpuAvailable && this._source.app.state == Shell.AppState.STOPPED && - actions.indexOf('activate-discrete-gpu') == -1) { + actions.includes('activate-discrete-gpu')) { this._onDiscreteGpuMenuItem = this._appendMenuItem(_("Launch using Dedicated Graphics Card")); this._onDiscreteGpuMenuItem.connect('activate', () => { if (this._source.app.state == Shell.AppState.STOPPED) diff --git a/js/ui/calendar.js b/js/ui/calendar.js index cd3e879c4..d7c5bc805 100644 --- a/js/ui/calendar.js +++ b/js/ui/calendar.js @@ -38,7 +38,7 @@ function isToday(date) { function _isWorkDay(date) { /* Translators: Enter 0-6 (Sunday-Saturday) for non-work days. Examples: "0" (Sunday) "6" (Saturday) "06" (Sunday and Saturday). */ let days = C_('calendar-no-work', "06"); - return days.indexOf(date.getDay().toString()) == -1; + return !days.includes(date.getDay().toString()); } function _getBeginningOfDay(date) { diff --git a/js/ui/components/__init__.js b/js/ui/components/__init__.js index 6d6cc9d69..652f6951c 100644 --- a/js/ui/components/__init__.js +++ b/js/ui/components/__init__.js @@ -13,13 +13,13 @@ var ComponentManager = class { let newEnabledComponents = Main.sessionMode.components; newEnabledComponents.filter( - name => this._enabledComponents.indexOf(name) == -1 + name => !this._enabledComponents.includes(name) ).forEach(name => { this._enableComponent(name); }); this._enabledComponents.filter( - name => newEnabledComponents.indexOf(name) == -1 + name => !newEnabledComponents.includes(name) ).forEach(name => { this._disableComponent(name); }); diff --git a/js/ui/components/autorunManager.js b/js/ui/components/autorunManager.js index 34c7d6250..4891e5d95 100644 --- a/js/ui/components/autorunManager.js +++ b/js/ui/components/autorunManager.js @@ -40,7 +40,7 @@ function isMountRootHidden(root) { let path = root.get_path(); // skip any mounts in hidden directory hierarchies - return (path.indexOf('/.') != -1); + return (path.includes('/.')); } function isMountNonLocal(mount) { @@ -192,15 +192,15 @@ var AutorunDispatcher = class { _getAutorunSettingForType(contentType) { let runApp = this._settings.get_strv(SETTING_START_APP); - if (runApp.indexOf(contentType) != -1) + if (runApp.includes(contentType)) return AutorunSetting.RUN; let ignore = this._settings.get_strv(SETTING_IGNORE); - if (ignore.indexOf(contentType) != -1) + if (ignore.includes(contentType)) return AutorunSetting.IGNORE; let openFiles = this._settings.get_strv(SETTING_OPEN_FOLDER); - if (openFiles.indexOf(contentType) != -1) + if (openFiles.includes(contentType)) return AutorunSetting.FILES; return AutorunSetting.ASK; diff --git a/js/ui/components/networkAgent.js b/js/ui/components/networkAgent.js index 48bbd308f..dca8318ed 100644 --- a/js/ui/components/networkAgent.js +++ b/js/ui/components/networkAgent.js @@ -327,7 +327,7 @@ class NetworkSecretDialog extends ModalDialog.ModalDialog { this._getPPPoESecrets(content.secrets); break; case 'gsm': - if (this._hints.indexOf('pin') != -1) { + if (this._hints.includes('pin')) { let gsmSetting = this._connection.get_setting_gsm(); content.title = _("PIN code required"); content.message = _("PIN code is needed for the mobile broadband device"); @@ -695,7 +695,7 @@ var NetworkAgent = class { body = _("A password is required to connect to ā€œ%sā€.".format(connection.get_id())); break; case 'gsm': - if (hints.indexOf('pin') != -1) { + if (hints.includes('pin')) { let gsmSetting = connection.get_setting_gsm(); title = _("PIN code required"); body = _("PIN code is needed for the mobile broadband device"); diff --git a/js/ui/components/polkitAgent.js b/js/ui/components/polkitAgent.js index 27566531f..a44165df9 100644 --- a/js/ui/components/polkitAgent.js +++ b/js/ui/components/polkitAgent.js @@ -45,9 +45,9 @@ var AuthenticationDialog = GObject.registerClass({ } let userName = GLib.get_user_name(); - if (userNames.indexOf(userName) < 0) + if (!userNames.includes(userName)) userName = 'root'; - if (userNames.indexOf(userName) < 0) + if (!userNames.includes(userName)) userName = userNames[0]; this._user = AccountsService.UserManager.get_default().get_user(userName); diff --git a/js/ui/dash.js b/js/ui/dash.js index 0032c912e..878045410 100644 --- a/js/ui/dash.js +++ b/js/ui/dash.js @@ -700,14 +700,14 @@ var Dash = class Dash { } // App removed at oldIndex - if (oldApp && newApps.indexOf(oldApp) == -1) { + if (oldApp && !newApps.includes(oldApp)) { removedActors.push(children[oldIndex]); oldIndex++; continue; } // App added at newIndex - if (newApp && oldApps.indexOf(newApp) == -1) { + if (newApp && !oldApps.includes(newApp)) { addedItems.push({ app: newApp, item: this._createAppItem(newApp), pos: newIndex }); diff --git a/js/ui/endSessionDialog.js b/js/ui/endSessionDialog.js index d83578fb9..3c7729eb3 100644 --- a/js/ui/endSessionDialog.js +++ b/js/ui/endSessionDialog.js @@ -585,7 +585,7 @@ class EndSessionDialog extends ModalDialog.ModalDialog { } _onInhibitorLoaded(inhibitor) { - if (this._applications.indexOf(inhibitor) < 0) { + if (!this._applications.includes(inhibitor)) { // Stale inhibitor return; } diff --git a/js/ui/extensionDownloader.js b/js/ui/extensionDownloader.js index 184db2464..fb36ac478 100644 --- a/js/ui/extensionDownloader.js +++ b/js/ui/extensionDownloader.js @@ -228,7 +228,7 @@ class InstallExtensionDialog extends ModalDialog.ModalDialog { function callback() { // Add extension to 'enabled-extensions' for the user, always... let enabledExtensions = global.settings.get_strv(ExtensionSystem.ENABLED_EXTENSIONS_KEY); - if (enabledExtensions.indexOf(uuid) == -1) { + if (!enabledExtensions.includes(uuid)) { enabledExtensions.push(uuid); global.settings.set_strv(ExtensionSystem.ENABLED_EXTENSIONS_KEY, enabledExtensions); } diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js index 6244c39b4..744f5e7ac 100644 --- a/js/ui/extensionSystem.js +++ b/js/ui/extensionSystem.js @@ -169,7 +169,7 @@ function loadExtension(extension) { if (checkVersion && ExtensionUtils.isOutOfDate(extension)) { extension.state = ExtensionState.OUT_OF_DATE; } else { - let enabled = enabledExtensions.indexOf(extension.uuid) != -1; + let enabled = enabledExtensions.includes(extension.uuid); if (enabled) { if (!initExtension(extension.uuid)) return; diff --git a/js/ui/grabHelper.js b/js/ui/grabHelper.js index 509915019..39873e16f 100644 --- a/js/ui/grabHelper.js +++ b/js/ui/grabHelper.js @@ -87,7 +87,7 @@ var GrabHelper = class GrabHelper { _isWithinGrabbedActor(actor) { let currentActor = this.currentGrab.actor; while (actor) { - if (this._actors.indexOf(actor) != -1) + if (this._actors.includes(actor)) return true; if (actor == currentActor) return true; diff --git a/js/ui/inhibitShortcutsDialog.js b/js/ui/inhibitShortcutsDialog.js index 170cd1a33..6c988577c 100644 --- a/js/ui/inhibitShortcutsDialog.js +++ b/js/ui/inhibitShortcutsDialog.js @@ -111,7 +111,7 @@ var InhibitShortcutsDialog = GObject.registerClass({ } vfunc_show() { - if (this._app && APP_WHITELIST.indexOf(this._app.get_id()) != -1) { + if (this._app && APP_WHITELIST.includes(this._app.get_id())) { this._emitResponse(DialogResponse.ALLOW); return; } diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js index b6a26663a..c30f90a76 100644 --- a/js/ui/keyboard.js +++ b/js/ui/keyboard.js @@ -1074,7 +1074,7 @@ var Keyboard = class Keyboard { let manager = Clutter.DeviceManager.get_default(); let device = manager.get_device(deviceId); - if (device.get_device_name().indexOf('XTEST') < 0) { + if (!device.get_device_name().includes('XTEST')) { this._lastDeviceId = deviceId; this._syncEnabled(); } diff --git a/js/ui/main.js b/js/ui/main.js index 04f333ea1..9b6986001 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -663,7 +663,7 @@ function initializeDeferredWork(actor, callback, props) { _deferredWorkData[workId] = { 'actor': actor, 'callback': callback }; actor.connect('notify::mapped', () => { - if (!(actor.mapped && _deferredWorkQueue.indexOf(workId) >= 0)) + if (!(actor.mapped && _deferredWorkQueue.includes(workId))) return; _queueBeforeRedraw(workId); }); @@ -693,7 +693,7 @@ function queueDeferredWork(workId) { logError(new Error(message), message); return; } - if (_deferredWorkQueue.indexOf(workId) < 0) + if (!_deferredWorkQueue.includes(workId)) _deferredWorkQueue.push(workId); if (data.actor.mapped) { _queueBeforeRedraw(workId); diff --git a/js/ui/messageList.js b/js/ui/messageList.js index bd97ffcb0..93c3fc3ac 100644 --- a/js/ui/messageList.js +++ b/js/ui/messageList.js @@ -72,7 +72,7 @@ var URLHighlighter = class URLHighlighter { let urlId = this._findUrlAtPos(event); if (urlId != -1) { let url = this._urls[urlId].url; - if (url.indexOf(':') == -1) + if (!url.includes(':')) url = 'http://' + url; Gio.app_info_launch_default_for_uri(url, global.create_app_launch_context(0, -1)); diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index f1f79d8c2..4007f1b00 100644 --- a/js/ui/messageTray.js +++ b/js/ui/messageTray.js @@ -228,7 +228,7 @@ class NotificationApplicationPolicy extends NotificationPolicy { this._settings.set_string('application-id', this.id + '.desktop'); let apps = this._masterSettings.get_strv('application-children'); - if (apps.indexOf(this._canonicalId) < 0) { + if (!apps.includes(this._canonicalId)) { apps.push(this._canonicalId); this._masterSettings.set_strv('application-children', apps); } @@ -772,7 +772,7 @@ var Source = class Source { } pushNotification(notification) { - if (this.notifications.indexOf(notification) >= 0) + if (this.notifications.includes(notification)) return; while (this.notifications.length >= MAX_NOTIFICATIONS_PER_SOURCE) @@ -1069,7 +1069,7 @@ var MessageTray = class MessageTray { // If a new notification is updated while it is being hidden, // we stop hiding it and show it again. this._updateShowingNotification(); - } else if (this._notificationQueue.indexOf(notification) < 0) { + } else if (!this._notificationQueue.includes(notification)) { // If the queue is "full", we skip banner mode and just show a small // indicator in the panel; however do make an exception for CRITICAL // notifications, as only banner mode allows expansion. diff --git a/js/ui/padOsd.js b/js/ui/padOsd.js index a4af47297..903b967c4 100644 --- a/js/ui/padOsd.js +++ b/js/ui/padOsd.js @@ -630,7 +630,7 @@ var PadOsd = class { // If the device is being removed, destroy the padOsd. if (device == this.padDevice) { this.destroy(); - } else if (this._groupPads.indexOf(device) != -1) { + } else if (this._groupPads.includes(device)) { // Or update the pad chooser if the device belongs to // the same group. this._groupPads.splice(this._groupPads.indexOf(device), 1); @@ -749,8 +749,7 @@ var PadOsd = class { } _requestForOtherPad(pad) { - if (pad == this.padDevice || - this._groupPads.indexOf(pad) == -1) + if (pad == this.padDevice || !this._groupPads.includes(pad)) return; let editionMode = this._editionMode; @@ -801,7 +800,7 @@ var PadOsd = class { // If the event comes from another pad in the same group, // show the OSD for it. - if (this._groupPads.indexOf(event.get_source_device()) != -1) { + if (this._groupPads.includes(event.get_source_device())) { this._requestForOtherPad(event.get_source_device()); return Clutter.EVENT_STOP; } diff --git a/js/ui/panel.js b/js/ui/panel.js index be02785a8..fbd65a263 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -1056,9 +1056,9 @@ class Panel extends St.Widget { this._updateBox(panel.center, this._centerBox); this._updateBox(panel.right, this._rightBox); - if (panel.left.indexOf('dateMenu') != -1) + if (panel.left.includes('dateMenu')) Main.messageTray.bannerAlignment = Clutter.ActorAlign.START; - else if (panel.right.indexOf('dateMenu') != -1) + else if (panel.right.includes('dateMenu')) Main.messageTray.bannerAlignment = Clutter.ActorAlign.END; // Default to center if there is no dateMenu else diff --git a/js/ui/remoteSearch.js b/js/ui/remoteSearch.js index ce8c4d09b..ae6c6dab7 100644 --- a/js/ui/remoteSearch.js +++ b/js/ui/remoteSearch.js @@ -146,10 +146,10 @@ function loadRemoteSearchProviders(searchSettings, callback) { if (provider.defaultEnabled) { let disabled = searchSettings.get_strv('disabled'); - return disabled.indexOf(appId) == -1; + return !disabled.includes(appId); } else { let enabled = searchSettings.get_strv('enabled'); - return enabled.indexOf(appId) != -1; + return enabled.includes(appId); } }); diff --git a/js/ui/runDialog.js b/js/ui/runDialog.js index 9186ff7bb..21bd04c3e 100644 --- a/js/ui/runDialog.js +++ b/js/ui/runDialog.js @@ -182,7 +182,7 @@ class RunDialog extends ModalDialog.ModalDialog { } _getCompletion(text) { - if (text.indexOf('/') != -1) { + if (text.includes('/')) { return this._pathCompleter.get_completion_suffix(text); } else { return this._getCommandCompletion(text); diff --git a/js/ui/sessionMode.js b/js/ui/sessionMode.js index ae6c64dd3..70a6e8a15 100644 --- a/js/ui/sessionMode.js +++ b/js/ui/sessionMode.js @@ -128,7 +128,7 @@ function _loadMode(file, info) { let propBlacklist = ['unlockDialog']; for (let prop in _modes[DEFAULT_MODE]) { if (newMode[prop] !== undefined && - propBlacklist.indexOf(prop) == -1) + !propBlacklist.includes(prop)) _modes[modeName][prop] = newMode[prop]; } _modes[modeName]['isPrimary'] = true; diff --git a/js/ui/status/network.js b/js/ui/status/network.js index 7c2499d0e..8ad451347 100644 --- a/js/ui/status/network.js +++ b/js/ui/status/network.js @@ -1040,7 +1040,7 @@ class NMWirelessDialog extends ModalDialog.ModalDialog { _checkConnections(network, accessPoint) { this._connections.forEach(connection => { if (accessPoint.connection_valid(connection) && - network.connections.indexOf(connection) == -1) { + !network.connections.includes(connection)) { network.connections.push(connection); } }); @@ -1059,7 +1059,7 @@ class NMWirelessDialog extends ModalDialog.ModalDialog { if (pos != -1) { network = this._networks[pos]; - if (network.accessPoints.indexOf(accessPoint) != -1) { + if (network.accessPoints.includes(accessPoint)) { log('Access point was already seen, not adding again'); return; } diff --git a/js/ui/status/volume.js b/js/ui/status/volume.js index ae2497a93..cc270500b 100644 --- a/js/ui/status/volume.js +++ b/js/ui/status/volume.js @@ -215,7 +215,7 @@ var OutputStreamSlider = class extends StreamSlider { // of different identifiers for headphones, and I could // not find the complete list if (sink.get_ports().length > 0) - return sink.get_port().port.indexOf('headphone') >= 0; + return sink.get_port().port.includes('headphone'); return false; } diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js index 19dc263cd..d016f3371 100644 --- a/js/ui/windowManager.js +++ b/js/ui/windowManager.js @@ -1288,7 +1288,7 @@ var WindowManager = class { return false; let type = actor.meta_window.get_window_type(); - return types.indexOf(type) >= 0; + return types.includes(type); } _removeEffect(list, actor) { @@ -1501,7 +1501,7 @@ var WindowManager = class { _sizeChangedWindow(shellwm, actor) { if (!actor.__animationInfo) return; - if (this._resizing.indexOf(actor) != -1) + if (this._resizing.includes(actor)) return; let actorClone = actor.__animationInfo.clone; diff --git a/js/ui/workspace.js b/js/ui/workspace.js index 50ac141d9..1b6c63eb3 100644 --- a/js/ui/workspace.js +++ b/js/ui/workspace.js @@ -536,7 +536,7 @@ var WindowOverlay = class { let [cloneX, cloneY, cloneWidth, cloneHeight] = this._windowClone.slot; let layout = Meta.prefs_get_button_layout(); - let side = layout.left_buttons.indexOf(Meta.ButtonFunction.CLOSE) > -1 ? St.Side.LEFT : St.Side.RIGHT; + let side = layout.left_buttons.includes(Meta.ButtonFunction.CLOSE) ? St.Side.LEFT : St.Side.RIGHT; let buttonX; let buttonY = cloneY - (button.height - button._overlap); diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js index 969167178..be196c04b 100644 --- a/js/ui/workspaceThumbnail.js +++ b/js/ui/workspaceThumbnail.js @@ -378,7 +378,7 @@ var WorkspaceThumbnail = class { return; } - if (this._allWindows.indexOf(metaWin) == -1) { + if (!this._allWindows.includes(metaWin)) { let minimizedChangedId = metaWin.connect('notify::minimized', this._updateMinimized.bind(this)); this._allWindows.push(metaWin);