diff --git a/module/tweaks/rearrangeSidebarTabs.mjs b/module/tweaks/rearrangeSidebarTabs.mjs index 9d7e5a7..512f6bc 100644 --- a/module/tweaks/rearrangeSidebarTabs.mjs +++ b/module/tweaks/rearrangeSidebarTabs.mjs @@ -32,8 +32,32 @@ export function rearrangeSidebarTabs() { // #endregion Registration // #region Implementation - // TODO: do this + updateTabOrder(); // #endregion Implementation status[key] = SettingStatusEnum.Registered; }; + +function updateTabOrder() { + const order = game.settings.get(__ID__, `${key}User`) + ?? game.settings.get(__ID__, `${key}World`) + ?? null; + if (!order) { return }; + + const tabs = CONFIG.ui.sidebar.TABS; + const replaced = {}; + + // Sort all of the tabs that are provided + for (const tabID of order) { + if (!tabs[tabID]) { continue }; + replaced[tabID] = tabs[tabID]; + }; + + // Add any tabs that are not in the ordering yet + for (const tabID in tabs) { + if (replaced[tabID] != null) { continue }; + replaced[tabID] = tabs[tabID]; + }; + + CONFIG.ui.sidebar.TABS = replaced; +};