Refactor: Reorder enable code and comment it, to make it more clear

This commit is contained in:
Julian 2023-01-29 00:41:46 +01:00
parent d01fb434ee
commit 8586f095fc
Signed by: julian
GPG Key ID: 094C2AC34192FA11

View File

@ -18,29 +18,28 @@ class Extension {
this._boxOrderManager = new BoxOrderManager.BoxOrderManager(); this._boxOrderManager = new BoxOrderManager.BoxOrderManager();
// Stuff to do on startup(extension enable). /// Stuff to do on startup(extension enable).
// Initially handle new top bar items and order top bar boxes.
this.#handleNewItemsAndOrderTopBar(); this.#handleNewItemsAndOrderTopBar();
// Overwrite `Panel._addToPanelBox` method with one handling new items
// and also handle AppIndicators getting ready, to handle new items.
this.#overwritePanelAddToPanelBox(); this.#overwritePanelAddToPanelBox();
this._boxOrderManager.connect("appIndicatorReady", () => {
this.#handleNewItemsAndOrderTopBar();
});
// Handle changes of configured box orders. // Handle changes of configured box orders.
this._settingsHandlerIds = []; this._settingsHandlerIds = [];
const addConfiguredBoxOrderChangeHandler = (box) => { const addConfiguredBoxOrderChangeHandler = (box) => {
let handlerId = this.settings.connect(`changed::${box}-box-order`, () => { let handlerId = this.settings.connect(`changed::${box}-box-order`, () => {
this.#handleNewItemsAndOrderTopBar(); this.#handleNewItemsAndOrderTopBar();
}); });
this._settingsHandlerIds.push(handlerId); this._settingsHandlerIds.push(handlerId);
}; };
addConfiguredBoxOrderChangeHandler("left"); addConfiguredBoxOrderChangeHandler("left");
addConfiguredBoxOrderChangeHandler("center"); addConfiguredBoxOrderChangeHandler("center");
addConfiguredBoxOrderChangeHandler("right"); addConfiguredBoxOrderChangeHandler("right");
// Handle AppIndicators getting ready.
this._boxOrderManager.connect("appIndicatorReady", () => {
this.#handleNewItemsAndOrderTopBar();
});
} }
disable() { disable() {