better way to show dismiss link based on notifications widget state

This commit is contained in:
Neil Lalonde 2017-11-08 11:20:39 -05:00
parent 7134b11673
commit 3940e95227
2 changed files with 1 additions and 17 deletions

View File

@ -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();
}
});

View File

@ -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();
});
},