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), getOwner(this),
tab.panelComponent tab.panelComponent
); );
this.appEvents.trigger("user-menu:tab-click", tab.id);
this.currentNotificationTypes = tab.notificationTypes; 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"; import UserMenuReviewableItem from "discourse/lib/user-menu/reviewable-item";
export default class UserMenuNotificationsList extends UserMenuItemsList { export default class UserMenuNotificationsList extends UserMenuItemsList {
@service appEvents;
@service currentUser; @service currentUser;
@service siteSettings; @service siteSettings;
@service site; @service site;
@ -108,6 +109,7 @@ export default class UserMenuNotificationsList extends UserMenuItemsList {
} }
).forEach((item) => { ).forEach((item) => {
const props = { const props = {
appEvents: this.appEvents,
currentUser: this.currentUser, currentUser: this.currentUser,
siteSettings: this.siteSettings, siteSettings: this.siteSettings,
site: this.site, site: this.site,
@ -126,6 +128,7 @@ export default class UserMenuNotificationsList extends UserMenuItemsList {
content.push( content.push(
new UserMenuNotificationItem({ new UserMenuNotificationItem({
notification, notification,
appEvents: this.appEvents,
currentUser: this.currentUser, currentUser: this.currentUser,
siteSettings: this.siteSettings, siteSettings: this.siteSettings,
site: this.site, site: this.site,

View File

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