const _knownMessages = new WeakSet<HTMLElement>();
let _mobileSidebarEnabled = false;
let _pageMenuMain: UiPageMenuMain;
-let _pageMenuUser: UiPageMenuUser;
+let _pageMenuUser: UiPageMenuUser | undefined = undefined;
let _messageGroups: HTMLCollection | null = null;
const _sidebars: HTMLElement[] = [];
function initMobileMenu(): void {
if (_enableMobileMenu) {
_pageMenuMain = new UiPageMenuMain();
- _pageMenuUser = new UiPageMenuUser();
+
+ if (UiPageMenuUser.hasValidMenu()) {
+ _pageMenuUser = new UiPageMenuUser();
+ }
}
}
_enabled = true;
if (_enableMobileMenu) {
_pageMenuMain.enable();
- _pageMenuUser.enable();
+ _pageMenuUser?.enable();
}
}
_enabled = false;
if (_enableMobileMenu) {
_pageMenuMain.disable();
- _pageMenuUser.disable();
+ _pageMenuUser?.disable();
}
}
* Initializes the touch-friendly fullscreen user menu.
*/
constructor() {
- // check if user menu is actually empty
- const menu = document.querySelector("#pageUserMenuMobile > .menuOverlayItemList")!;
- if (menu.childElementCount === 1 && menu.children[0].classList.contains("menuOverlayTitle")) {
- const userPanel = document.querySelector("#pageHeader .userPanel")!;
- userPanel.classList.add("hideUserPanel");
- return;
- }
-
super("com.woltlab.wcf.UserMenuMobile", "pageUserMenuMobile", "#pageHeader .userPanel");
EventHandler.add("com.woltlab.wcf.userMenu", "updateBadge", (data) => this.updateBadge(data));
}
});
}
+
+ static hasValidMenu(): boolean {
+ const menu = document.querySelector("#pageUserMenuMobile > .menuOverlayItemList")!;
+ if (menu.childElementCount === 1 && menu.children[0].classList.contains("menuOverlayTitle")) {
+ const userPanel = document.querySelector("#pageHeader .userPanel")!;
+ userPanel.classList.add("hideUserPanel");
+ return false;
+ }
+
+ return true;
+ }
}
Core.enableLegacyInheritance(UiPageMenuUser);
const _knownMessages = new WeakSet();
let _mobileSidebarEnabled = false;
let _pageMenuMain;
- let _pageMenuUser;
+ let _pageMenuUser = undefined;
let _messageGroups = null;
const _sidebars = [];
function init() {
function initMobileMenu() {
if (_enableMobileMenu) {
_pageMenuMain = new Main_1.default();
- _pageMenuUser = new User_1.default();
+ if (User_1.default.hasValidMenu()) {
+ _pageMenuUser = new User_1.default();
+ }
}
}
function closeAllMenus() {
_enabled = true;
if (_enableMobileMenu) {
_pageMenuMain.enable();
- _pageMenuUser.enable();
+ _pageMenuUser === null || _pageMenuUser === void 0 ? void 0 : _pageMenuUser.enable();
}
}
exports.enable = enable;
_enabled = false;
if (_enableMobileMenu) {
_pageMenuMain.disable();
- _pageMenuUser.disable();
+ _pageMenuUser === null || _pageMenuUser === void 0 ? void 0 : _pageMenuUser.disable();
}
}
exports.disable = disable;
* Initializes the touch-friendly fullscreen user menu.
*/
constructor() {
- // check if user menu is actually empty
- const menu = document.querySelector("#pageUserMenuMobile > .menuOverlayItemList");
- if (menu.childElementCount === 1 && menu.children[0].classList.contains("menuOverlayTitle")) {
- const userPanel = document.querySelector("#pageHeader .userPanel");
- userPanel.classList.add("hideUserPanel");
- return;
- }
super("com.woltlab.wcf.UserMenuMobile", "pageUserMenuMobile", "#pageHeader .userPanel");
EventHandler.add("com.woltlab.wcf.userMenu", "updateBadge", (data) => this.updateBadge(data));
this.button.setAttribute("aria-label", Language.get("wcf.menu.user"));
}
});
}
+ static hasValidMenu() {
+ const menu = document.querySelector("#pageUserMenuMobile > .menuOverlayItemList");
+ if (menu.childElementCount === 1 && menu.children[0].classList.contains("menuOverlayTitle")) {
+ const userPanel = document.querySelector("#pageHeader .userPanel");
+ userPanel.classList.add("hideUserPanel");
+ return false;
+ }
+ return true;
+ }
}
Core.enableLegacyInheritance(UiPageMenuUser);
return UiPageMenuUser;