Skip to content

Commit

Permalink
added getActiveMenu function
Browse files Browse the repository at this point in the history
  • Loading branch information
Voiture-0 committed Nov 7, 2024
1 parent 2617dd7 commit 3cae812
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions assets/chat/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,10 @@ class Chat {
document.addEventListener('keydown', (e) => {
if (isKeyCode(e, KEYCODES.ESC)) {
// If any menus are open, close them first
if ([...this.menus].some(([, menu]) => menu.visible)) ChatMenu.closeMenus(this);
if (this.getActiveMenu() !== undefined) ChatMenu.closeMenus(this);
// If the active window is scrolled up (not pinned), scroll to bottom
else if (!this.getActiveWindow().scrollplugin.pinned) this.getActiveWindow().scrollplugin.scrollBottom();
else if (!this.getActiveWindow().scrollplugin.pinned)
this.getActiveWindow().scrollplugin.scrollBottom();
}
});

Expand Down Expand Up @@ -927,6 +928,10 @@ class Chat {
if (this.mainwindow !== null) this.mainwindow.update();
}

getActiveMenu() {
return [...this.menus.values()].find((menu) => menu.visible);
}

censor(nick) {
for (const message of this.mainwindow.messages) {
if (message.user?.username === nick.toLowerCase()) {
Expand Down

0 comments on commit 3cae812

Please sign in to comment.