From 3940e95227aabea7261abf2ffa7a107a4390d04b Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Wed, 8 Nov 2017 11:20:39 -0500 Subject: [PATCH] better way to show dismiss link based on notifications widget state --- .../discourse/widgets/user-menu.js.es6 | 15 +-------------- .../discourse/widgets/user-notifications.js.es6 | 3 --- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/app/assets/javascripts/discourse/widgets/user-menu.js.es6 b/app/assets/javascripts/discourse/widgets/user-menu.js.es6 index 123bbddf92d..194ba4eb56f 100644 --- a/app/assets/javascripts/discourse/widgets/user-menu.js.es6 +++ b/app/assets/javascripts/discourse/widgets/user-menu.js.es6 @@ -92,12 +92,8 @@ createWidget('user-menu-dismiss-link', { tagName: 'div.dismiss-link', buildKey: () => 'user-menu-dismiss-link', - defaultState() { - return { showDismiss: false }; - }, - html() { - if (this.state.showDismiss) { + if (userNotifications.state.notifications.get('length') > 0) { return h('ul.menu-links', h('li', this.attach('link', { @@ -114,11 +110,6 @@ createWidget('user-menu-dismiss-link', { } }, - showDismissLink() { - this.state.showDismiss = true; - this.scheduleRerender(); - }, - dismissNotifications() { ajax('/notifications/mark-read', { method: 'PUT' }).then(() => { userNotifications.notificationsChanged(); @@ -169,9 +160,5 @@ export default createWidget('user-menu', { clickOutside() { this.sendWidgetAction('toggleUserMenu'); - }, - - notificationsLoaded() { - dismissLink.showDismissLink(); } }); diff --git a/app/assets/javascripts/discourse/widgets/user-notifications.js.es6 b/app/assets/javascripts/discourse/widgets/user-notifications.js.es6 index a334fce9486..a6353a995f4 100644 --- a/app/assets/javascripts/discourse/widgets/user-notifications.js.es6 +++ b/app/assets/javascripts/discourse/widgets/user-notifications.js.es6 @@ -51,9 +51,6 @@ export default createWidget('user-notifications', { }).finally(() => { state.loading = false; state.loaded = true; - if (state.notifications.get('length') > 0) { - this.sendWidgetAction('notificationsLoaded'); - } this.scheduleRerender(); }); },