A platform for community discussion. Free, open, simple.
UX: Add class to body on first unread notification (#12362)
Jordan Vidrinef1c1f9e0e785
diff --git a/app/assets/javascripts/discourse/app/components/site-header.js b/app/assets/javascripts/discourse/app/components/site-header.jsindex faca98fbfbd..9be47f75680 100644--- a/app/assets/javascripts/discourse/app/components/site-header.js+++ b/app/assets/javascripts/discourse/app/components/site-header.js@@ -215,6 +215,13 @@ const SiteHeaderComponent = MountWidget.extend(this.appEvents.on("dom:clean", this, "_cleanDom");+ if (+ this.currentUser &&+ !this.get("currentUser.read_first_notification")+ ) {+ document.body.classList.add("unread-first-notification");+ }+// Allow first notification to be dismissed on a click anywhereif (this.currentUser &&@@ -222,6 +229,9 @@ const SiteHeaderComponent = MountWidget.extend(!this.get("currentUser.enforcedSecondFactor")) {this._dismissFirstNotification = (e) => {+ if (document.body.classList.contains("unread-first-notification")) {+ document.body.classList.remove("unread-first-notification");+ }if (!e.target.closest("#current-user") &&!e.target.closest(".ring-backdrop") &&diff --git a/app/assets/javascripts/discourse/app/widgets/header.js b/app/assets/javascripts/discourse/app/widgets/header.jsindex 6dd0b8d3ac5..0a5eba5f0f1 100644--- a/app/assets/javascripts/discourse/app/widgets/header.js+++ b/app/assets/javascripts/discourse/app/widgets/header.js@@ -586,6 +586,9 @@ export default createWidget("header", {headerDismissFirstNotificationMask() {// Dismiss notifications+ if (document.body.classList.contains("unread-first-notification")) {+ document.body.classList.remove("unread-first-notification");+ }this.store.findStale("notification",