Replace notify method by binded version in constructor of chat and notification menu
We need to keep a reference to the binded method registered to be able to unregister it. Closes #14425
This commit is contained in:
+2
-1
@@ -5,8 +5,9 @@
|
||||
|
||||
class _Chat {
|
||||
constructor(record) {
|
||||
this.notify = this.notify.bind(this);
|
||||
this.record = record;
|
||||
Sao.Bus.register(`chat:${this.record}`, this.notify.bind(this));
|
||||
Sao.Bus.register(`chat:${this.record}`, this.notify);
|
||||
this.el = this.__build();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
class _NotificationMenu {
|
||||
constructor() {
|
||||
this.notify = this.notify.bind(this);
|
||||
this.el = jQuery('<ul/>', {
|
||||
'class': 'notification-menu dropdown-menu',
|
||||
'role': 'menu',
|
||||
|
||||
+2
-3
@@ -614,8 +614,7 @@ var Sao = {
|
||||
let user_id = Sao.Session.current_session.user_id;
|
||||
Sao.Bus.register(
|
||||
`notification:${user_id}`,
|
||||
Sao.NotificationMenu.notify
|
||||
.bind(Sao.NotificationMenu));
|
||||
Sao.NotificationMenu.notify);
|
||||
Sao.NotificationMenu.count();
|
||||
Sao.Bus.listen();
|
||||
|
||||
@@ -642,7 +641,7 @@ var Sao = {
|
||||
jQuery('#menu').empty();
|
||||
let user_id = Sao.Session.current_session.user_id;
|
||||
Sao.Bus.unregister(
|
||||
`notification:${user_id}`, Sao.NotificationMenu.update);
|
||||
`notification:${user_id}`, Sao.NotificationMenu.notify);
|
||||
session.do_logout().always(Sao.login);
|
||||
Sao.set_title();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user