mirror of
https://gitlab.gnome.org/julianschacher/top-bar-organizer.git
synced 2025-10-27 15:19:09 +00:00
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.
This commit is contained in:
parent
5a09b1a2c8
commit
1e87992081
@ -259,20 +259,15 @@ export default class BoxOrderManager extends GObject.Object {
|
|||||||
// Get a resolved box order.
|
// Get a resolved box order.
|
||||||
let resolvedBoxOrder = this.#getResolvedBoxOrder(box);
|
let resolvedBoxOrder = this.#getResolvedBoxOrder(box);
|
||||||
|
|
||||||
// ToDo: simplify.
|
|
||||||
// Get the indicator containers (of the items) currently present in the
|
// Get the indicator containers (of the items) currently present in the
|
||||||
// GNOME Shell top bar.
|
// GNOME Shell top bar.
|
||||||
// They should be St.Bins (see link), so ensure that using a filter.
|
// 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
|
// 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)._leftBox.get_children(),
|
||||||
(Main.panel as CustomPanel)._centerBox.get_children(),
|
(Main.panel as CustomPanel)._centerBox.get_children(),
|
||||||
(Main.panel as CustomPanel)._rightBox.get_children(),
|
(Main.panel as CustomPanel)._rightBox.get_children(),
|
||||||
].flat().filter(ic => ic instanceof St.Bin);
|
].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);
|
|
||||||
|
|
||||||
// Go through the resolved box order and only add items to the valid box
|
// 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
|
// order, where their indicator is currently present in the GNOME Shell
|
||||||
@ -285,7 +280,7 @@ export default class BoxOrderManager extends GObject.Object {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indicatorContainerSet.has(associatedIndicatorContainer)) {
|
if (indicatorContainers.has(associatedIndicatorContainer)) {
|
||||||
validBoxOrder.push(item);
|
validBoxOrder.push(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user