DEV: Fire appEvents for user menu events (opening/clicking) (#21322)

This commit is contained in:
Mark VanLandingham 2023-05-01 11:31:57 -05:00 committed by GitHub
parent 4cca7de22d
commit 685e1de3ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View File

@ -277,6 +277,8 @@ export default class UserMenu extends Component {
getOwner(this),
tab.panelComponent
);
this.appEvents.trigger("user-menu:tab-click", tab.id);
this.currentNotificationTypes = tab.notificationTypes;
}

View File

@ -14,6 +14,7 @@ import UserMenuReviewable from "discourse/models/user-menu-reviewable";
import UserMenuReviewableItem from "discourse/lib/user-menu/reviewable-item";
export default class UserMenuNotificationsList extends UserMenuItemsList {
@service appEvents;
@service currentUser;
@service siteSettings;
@service site;
@ -108,6 +109,7 @@ export default class UserMenuNotificationsList extends UserMenuItemsList {
}
).forEach((item) => {
const props = {
appEvents: this.appEvents,
currentUser: this.currentUser,
siteSettings: this.siteSettings,
site: this.site,
@ -126,6 +128,7 @@ export default class UserMenuNotificationsList extends UserMenuItemsList {
content.push(
new UserMenuNotificationItem({
notification,
appEvents: this.appEvents,
currentUser: this.currentUser,
siteSettings: this.siteSettings,
site: this.site,

View File

@ -5,8 +5,9 @@ import { setTransientHeader } from "discourse/lib/ajax";
import { getRenderDirector } from "discourse/lib/notification-types-manager";
export default class UserMenuNotificationItem extends UserMenuBaseItem {
constructor({ notification, currentUser, siteSettings, site }) {
constructor({ notification, appEvents, currentUser, siteSettings, site }) {
super(...arguments);
this.appEvents = appEvents;
this.notification = notification;
this.currentUser = currentUser;
this.siteSettings = siteSettings;
@ -62,6 +63,8 @@ export default class UserMenuNotificationItem extends UserMenuBaseItem {
}
onClick() {
this.appEvents.trigger("user-menu:notification-click", this.notification);
if (!this.notification.read) {
this.notification.set("read", true);