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:
Cédric Krier
2025-12-16 01:10:47 +01:00
parent f9a6bd7379
commit 78b475740b
3 changed files with 5 additions and 4 deletions
+2 -1
View File
@@ -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();
}
+1
View File
@@ -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
View File
@@ -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();
});