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',
|
tagName: 'div.dismiss-link',
|
||||||
buildKey: () => 'user-menu-dismiss-link',
|
buildKey: () => 'user-menu-dismiss-link',
|
||||||
|
|
||||||
defaultState() {
|
|
||||||
return { showDismiss: false };
|
|
||||||
},
|
|
||||||
|
|
||||||
html() {
|
html() {
|
||||||
if (this.state.showDismiss) {
|
if (userNotifications.state.notifications.get('length') > 0) {
|
||||||
return h('ul.menu-links',
|
return h('ul.menu-links',
|
||||||
h('li',
|
h('li',
|
||||||
this.attach('link', {
|
this.attach('link', {
|
||||||
|
@ -114,11 +110,6 @@ createWidget('user-menu-dismiss-link', {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
showDismissLink() {
|
|
||||||
this.state.showDismiss = true;
|
|
||||||
this.scheduleRerender();
|
|
||||||
},
|
|
||||||
|
|
||||||
dismissNotifications() {
|
dismissNotifications() {
|
||||||
ajax('/notifications/mark-read', { method: 'PUT' }).then(() => {
|
ajax('/notifications/mark-read', { method: 'PUT' }).then(() => {
|
||||||
userNotifications.notificationsChanged();
|
userNotifications.notificationsChanged();
|
||||||
|
@ -169,9 +160,5 @@ export default createWidget('user-menu', {
|
||||||
|
|
||||||
clickOutside() {
|
clickOutside() {
|
||||||
this.sendWidgetAction('toggleUserMenu');
|
this.sendWidgetAction('toggleUserMenu');
|
||||||
},
|
|
||||||
|
|
||||||
notificationsLoaded() {
|
|
||||||
dismissLink.showDismissLink();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -51,9 +51,6 @@ export default createWidget('user-notifications', {
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
state.loading = false;
|
state.loading = false;
|
||||||
state.loaded = true;
|
state.loaded = true;
|
||||||
if (state.notifications.get('length') > 0) {
|
|
||||||
this.sendWidgetAction('notificationsLoaded');
|
|
||||||
}
|
|
||||||
this.scheduleRerender();
|
this.scheduleRerender();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue