import UserMenuView from "../View";
export type UserMenuButton = {
+ clickCallback?: () => void;
icon: string;
link: string;
name: string;
if (button.link === "#") {
link = document.createElement("button");
link.type = "button";
+
+ if (button.name === "markAllAsRead") {
+ link.addEventListener("click", (event) => {
+ event.preventDefault();
+
+ void this.markAllAsRead();
+ });
+ } else if (typeof button.clickCallback === "function") {
+ link.addEventListener("click", (event) => {
+ event.preventDefault();
+
+ button.clickCallback!();
+ });
+ }
} else {
link = document.createElement("a");
link.href = button.link;
link.title = button.title;
link.innerHTML = button.icon;
- if (button.name === "markAllAsRead") {
- link.addEventListener("click", (event) => {
- event.preventDefault();
-
- void this.markAllAsRead();
- });
- }
-
return link;
}
if (button.link === "#") {
link = document.createElement("button");
link.type = "button";
+ if (button.name === "markAllAsRead") {
+ link.addEventListener("click", (event) => {
+ event.preventDefault();
+ void this.markAllAsRead();
+ });
+ }
+ else if (typeof button.clickCallback === "function") {
+ link.addEventListener("click", (event) => {
+ event.preventDefault();
+ button.clickCallback();
+ });
+ }
}
else {
link = document.createElement("a");
link.classList.add("userMenuButton", "jsTooltip");
link.title = button.title;
link.innerHTML = button.icon;
- if (button.name === "markAllAsRead") {
- link.addEventListener("click", (event) => {
- event.preventDefault();
- void this.markAllAsRead();
- });
- }
return link;
}
async markAllAsRead() {