From 1e8799208145fc831c1b22b6f13fd2a95bd63154 Mon Sep 17 00:00:00 2001 From: June Date: Thu, 12 Jun 2025 01:26:44 +0200 Subject: [PATCH] refactor: directly create set of indicator cont. in getValidBoxOrder Skip the unecessary intermediate variable and directly create a set. Also remove the "ToDo: simplify" comment as I don't see how this logic can be simplified more really. --- src/extensionModules/BoxOrderManager.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/extensionModules/BoxOrderManager.ts b/src/extensionModules/BoxOrderManager.ts index 085bbfc..317da51 100644 --- a/src/extensionModules/BoxOrderManager.ts +++ b/src/extensionModules/BoxOrderManager.ts @@ -259,20 +259,15 @@ export default class BoxOrderManager extends GObject.Object { // Get a resolved box order. let resolvedBoxOrder = this.#getResolvedBoxOrder(box); - // ToDo: simplify. // Get the indicator containers (of the items) currently present in the // GNOME Shell top bar. // They should be St.Bins (see link), so ensure that using a filter. // https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/48.2/js/ui/panelMenu.js?ref_type=tags#L21 - const indicatorContainers = [ + const indicatorContainers = new Set([ (Main.panel as CustomPanel)._leftBox.get_children(), (Main.panel as CustomPanel)._centerBox.get_children(), (Main.panel as CustomPanel)._rightBox.get_children(), - ].flat().filter(ic => ic instanceof St.Bin); - - // Create an indicator containers set from the indicator containers for - // fast easy access. - const indicatorContainerSet = new Set(indicatorContainers); + ].flat().filter(ic => ic instanceof St.Bin)); // Go through the resolved box order and only add items to the valid box // order, where their indicator is currently present in the GNOME Shell @@ -285,7 +280,7 @@ export default class BoxOrderManager extends GObject.Object { continue; } - if (indicatorContainerSet.has(associatedIndicatorContainer)) { + if (indicatorContainers.has(associatedIndicatorContainer)) { validBoxOrder.push(item); } }