better way to show dismiss link based on notifications widget state
This commit is contained in:
parent
7134b11673
commit
3940e95227
|
@ -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();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue