From 570b60f927a744f101634e1bb9839081468dea30 Mon Sep 17 00:00:00 2001 From: blankie Date: Fri, 13 Oct 2023 14:49:09 +1100 Subject: [PATCH] Update Compass QoL Enhancer to 1.19.1 - Fix sorting resources when it's initially opened --- Compass QoL Enhancer.user.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Compass QoL Enhancer.user.js b/Compass QoL Enhancer.user.js index fad8bba..5c2e2e4 100644 --- a/Compass QoL Enhancer.user.js +++ b/Compass QoL Enhancer.user.js @@ -2,7 +2,7 @@ // @name Compass QoL Enhancer // @namespace blankie-scripts // @match http*://*.compass.education/* -// @version 1.19.0 +// @version 1.19.1 // @author blankie // @description A userscript that adds small but useful features for Compass, such as the ability to close windows by clicking on the background // @inject-into page @@ -242,13 +242,23 @@ function wikiNodeSort(lhs, rhs) { } let WikiBrowserPanel = getExtClass("Compass.widgets.WikiBrowserPanel"); if (WikiBrowserPanel) { - let original = WikiBrowserPanel.prototype.initComponent; + let originalInitComponent = WikiBrowserPanel.prototype.initComponent; WikiBrowserPanel.prototype.initComponent = function() { - original.apply(this, arguments); this.on("treeDataLoaded", function() { this.treePanel.store.sort({sorterFn: wikiNodeSort}); }); + originalInitComponent.apply(this, arguments); } + + let originalRenderLayout = WikiBrowserPanel.prototype.renderLayout; + WikiBrowserPanel.prototype.renderLayout = function() { + originalRenderLayout.apply(this, arguments); + try { + this.treePanel.store.sort({sorterFn: wikiNodeSort}); + } catch (e) { + // /Communicate/SchoolDocumentation.aspx dies for some reason + } + }; }