Wrap requestUpdate in an arrow function

Otherwise parameters from the event handler might be passed in to it,
causing potential weirdness.
This commit is contained in:
JC Brand 2022-09-16 10:26:21 +02:00
parent 8378ce739b
commit 927add0707
12 changed files with 53 additions and 53 deletions

View File

@ -19,7 +19,7 @@ export default class ChatView extends BaseChatView {
this.model = _converse.chatboxes.get(this.jid); this.model = _converse.chatboxes.get(this.jid);
this.listenTo(_converse, 'windowStateChanged', this.onWindowStateChanged); this.listenTo(_converse, 'windowStateChanged', this.onWindowStateChanged);
this.listenTo(this.model, 'change:hidden', () => !this.model.get('hidden') && this.afterShown()); this.listenTo(this.model, 'change:hidden', () => !this.model.get('hidden') && this.afterShown());
this.listenTo(this.model, 'change:show_help_messages', this.requestUpdate); this.listenTo(this.model, 'change:show_help_messages', () => this.requestUpdate());
await this.model.messages.fetched; await this.model.messages.fetched;
!this.model.get('hidden') && this.afterShown() !this.model.get('hidden') && this.afterShown()

View File

@ -17,14 +17,14 @@ export default class ChatHeading extends CustomElement {
initialize () { initialize () {
this.model = _converse.chatboxes.get(this.jid); this.model = _converse.chatboxes.get(this.jid);
this.listenTo(this.model, 'change:status', this.requestUpdate); this.listenTo(this.model, 'change:status', () => this.requestUpdate());
this.listenTo(this.model, 'vcard:add', this.requestUpdate); this.listenTo(this.model, 'vcard:add', () => this.requestUpdate());
this.listenTo(this.model, 'vcard:change', this.requestUpdate); this.listenTo(this.model, 'vcard:change', () => this.requestUpdate());
if (this.model.contact) { if (this.model.contact) {
this.listenTo(this.model.contact, 'destroy', this.requestUpdate); this.listenTo(this.model.contact, 'destroy', () => this.requestUpdate());
} }
this.model.rosterContactAdded?.then(() => { this.model.rosterContactAdded?.then(() => {
this.listenTo(this.model.contact, 'change:nickname', this.requestUpdate); this.listenTo(this.model.contact, 'change:nickname', () => this.requestUpdate());
this.requestUpdate(); this.requestUpdate();
}); });
} }

View File

@ -13,9 +13,9 @@ class HeadlinesFeedView extends BaseChatView {
this.listenTo(_converse, 'windowStateChanged', this.onWindowStateChanged); this.listenTo(_converse, 'windowStateChanged', this.onWindowStateChanged);
this.listenTo(this.model, 'change:hidden', () => this.afterShown()); this.listenTo(this.model, 'change:hidden', () => this.afterShown());
this.listenTo(this.model, 'destroy', this.remove); this.listenTo(this.model, 'destroy', this.remove);
this.listenTo(this.model.messages, 'add', this.requestUpdate); this.listenTo(this.model.messages, 'add', () => this.requestUpdate());
this.listenTo(this.model.messages, 'remove', this.requestUpdate); this.listenTo(this.model.messages, 'remove', () => this.requestUpdate());
this.listenTo(this.model.messages, 'reset', this.requestUpdate); this.listenTo(this.model.messages, 'reset', () => this.requestUpdate());
await this.model.messages.fetched; await this.model.messages.fetched;
this.model.maybeShow(); this.model.maybeShow();

View File

@ -10,18 +10,18 @@ export default class MinimizedChats extends CustomElement {
async initialize () { async initialize () {
this.model = _converse.chatboxes; this.model = _converse.chatboxes;
await this.initToggle(); await this.initToggle();
this.listenTo(this.minchats, 'change:collapsed', this.requestUpdate) this.listenTo(this.minchats, 'change:collapsed', () => this.requestUpdate())
this.listenTo(this.model, 'add', this.requestUpdate) this.listenTo(this.model, 'add', () => this.requestUpdate())
this.listenTo(this.model, 'change:fullname', this.requestUpdate) this.listenTo(this.model, 'change:fullname', () => this.requestUpdate())
this.listenTo(this.model, 'change:jid', this.requestUpdate) this.listenTo(this.model, 'change:jid', () => this.requestUpdate())
this.listenTo(this.model, 'change:minimized', this.requestUpdate) this.listenTo(this.model, 'change:minimized', () => this.requestUpdate())
this.listenTo(this.model, 'change:name', this.requestUpdate) this.listenTo(this.model, 'change:name', () => this.requestUpdate())
this.listenTo(this.model, 'change:num_unread', this.requestUpdate) this.listenTo(this.model, 'change:num_unread', () => this.requestUpdate())
this.listenTo(this.model, 'remove', this.requestUpdate) this.listenTo(this.model, 'remove', () => this.requestUpdate())
this.listenTo(_converse, 'connected', this.requestUpdate); this.listenTo(_converse, 'connected', () => this.requestUpdate());
this.listenTo(_converse, 'reconnected', this.requestUpdate); this.listenTo(_converse, 'reconnected', () => this.requestUpdate());
this.listenTo(_converse, 'disconnected', this.requestUpdate); this.listenTo(_converse, 'disconnected', () => this.requestUpdate());
} }
render () { render () {

View File

@ -19,8 +19,8 @@ class MUCConfigForm extends CustomElement {
connectedCallback () { connectedCallback () {
super.connectedCallback(); super.connectedCallback();
this.model = _converse.chatboxes.get(this.jid); this.model = _converse.chatboxes.get(this.jid);
this.listenTo(this.model.features, 'change:passwordprotected', this.requestUpdate); this.listenTo(this.model.features, 'change:passwordprotected', () => this.requestUpdate());
this.listenTo(this.model.session, 'change:config_stanza', this.requestUpdate); this.listenTo(this.model.session, 'change:config_stanza', () => this.requestUpdate());
this.getConfig(); this.getConfig();
} }

View File

@ -15,7 +15,7 @@ export default class MUCView extends BaseChatView {
this.listenTo(_converse, 'windowStateChanged', this.onWindowStateChanged); this.listenTo(_converse, 'windowStateChanged', this.onWindowStateChanged);
this.listenTo(this.model, 'change:composing_spoiler', this.requestUpdateMessageForm); this.listenTo(this.model, 'change:composing_spoiler', this.requestUpdateMessageForm);
this.listenTo(this.model.session, 'change:connection_status', this.onConnectionStatusChanged); this.listenTo(this.model.session, 'change:connection_status', this.onConnectionStatusChanged);
this.listenTo(this.model.session, 'change:view', this.requestUpdate); this.listenTo(this.model.session, 'change:view', () => this.requestUpdate());
this.onConnectionStatusChanged(); this.onConnectionStatusChanged();
this.model.maybeShow(); this.model.maybeShow();

View File

@ -19,11 +19,11 @@ export default class MUCSidebar extends CustomElement {
connectedCallback () { connectedCallback () {
super.connectedCallback(); super.connectedCallback();
this.model = _converse.chatboxes.get(this.jid); this.model = _converse.chatboxes.get(this.jid);
this.listenTo(this.model.occupants, 'add', this.requestUpdate); this.listenTo(this.model.occupants, 'add', () => this.requestUpdate());
this.listenTo(this.model.occupants, 'remove', this.requestUpdate); this.listenTo(this.model.occupants, 'remove', () => this.requestUpdate());
this.listenTo(this.model.occupants, 'change', this.requestUpdate); this.listenTo(this.model.occupants, 'change', () => this.requestUpdate());
this.listenTo(this.model.occupants, 'vcard:change', this.requestUpdate); this.listenTo(this.model.occupants, 'vcard:change', () => this.requestUpdate());
this.listenTo(this.model.occupants, 'vcard:add', this.requestUpdate); this.listenTo(this.model.occupants, 'vcard:add', () => this.requestUpdate());
this.model.initialized.then(() => this.requestUpdate()); this.model.initialized.then(() => this.requestUpdate());
} }

View File

@ -12,11 +12,11 @@ export class Fingerprints extends CustomElement {
async initialize () { async initialize () {
this.devicelist = await api.omemo.devicelists.get(this.jid, true); this.devicelist = await api.omemo.devicelists.get(this.jid, true);
this.listenTo(this.devicelist.devices, 'change:bundle', this.requestUpdate); this.listenTo(this.devicelist.devices, 'change:bundle', () => this.requestUpdate());
this.listenTo(this.devicelist.devices, 'change:trusted', this.requestUpdate); this.listenTo(this.devicelist.devices, 'change:trusted', () => this.requestUpdate());
this.listenTo(this.devicelist.devices, 'remove', this.requestUpdate); this.listenTo(this.devicelist.devices, 'remove', () => this.requestUpdate());
this.listenTo(this.devicelist.devices, 'add', this.requestUpdate); this.listenTo(this.devicelist.devices, 'add', () => this.requestUpdate());
this.listenTo(this.devicelist.devices, 'reset', this.requestUpdate); this.listenTo(this.devicelist.devices, 'reset', () => this.requestUpdate());
this.requestUpdate(); this.requestUpdate();
} }

View File

@ -7,9 +7,9 @@ class Profile extends CustomElement {
initialize () { initialize () {
this.model = _converse.xmppstatus; this.model = _converse.xmppstatus;
this.listenTo(this.model, "change", this.requestUpdate); this.listenTo(this.model, "change", () => this.requestUpdate());
this.listenTo(this.model, "vcard:add", this.requestUpdate); this.listenTo(this.model, "vcard:add", () => this.requestUpdate());
this.listenTo(this.model, "vcard:change", this.requestUpdate); this.listenTo(this.model, "vcard:change", () => this.requestUpdate());
} }
render () { render () {

View File

@ -13,13 +13,13 @@ export default class RosterView extends CustomElement {
async initialize () { async initialize () {
await api.waitUntil('rosterInitialized') await api.waitUntil('rosterInitialized')
this.listenTo(_converse, 'rosterContactsFetched', this.requestUpdate); this.listenTo(_converse, 'rosterContactsFetched', () => this.requestUpdate());
this.listenTo(_converse.presences, 'change:show', this.requestUpdate); this.listenTo(_converse.presences, 'change:show', () => this.requestUpdate());
this.listenTo(_converse.roster, 'add', this.requestUpdate); this.listenTo(_converse.roster, 'add', () => this.requestUpdate());
this.listenTo(_converse.roster, 'destroy', this.requestUpdate); this.listenTo(_converse.roster, 'destroy', () => this.requestUpdate());
this.listenTo(_converse.roster, 'remove', this.requestUpdate); this.listenTo(_converse.roster, 'remove', () => this.requestUpdate());
this.listenTo(_converse.roster, 'change', this.requestUpdate); this.listenTo(_converse.roster, 'change', () => this.requestUpdate());
this.listenTo(_converse.roster.state, 'change', this.requestUpdate); this.listenTo(_converse.roster.state, 'change', () => this.requestUpdate());
/** /**
* Triggered once the _converse.RosterView instance has been created and initialized. * Triggered once the _converse.RosterView instance has been created and initialized.
* @event _converse#rosterViewInitialized * @event _converse#rosterViewInitialized

View File

@ -23,18 +23,18 @@ export default class ChatContent extends CustomElement {
async initialize () { async initialize () {
await this.setModels(); await this.setModels();
this.listenTo(this.model, 'change:hidden_occupants', this.requestUpdate); this.listenTo(this.model, 'change:hidden_occupants', () => this.requestUpdate());
this.listenTo(this.model.messages, 'add', this.requestUpdate); this.listenTo(this.model.messages, 'add', () => this.requestUpdate());
this.listenTo(this.model.messages, 'change', this.requestUpdate); this.listenTo(this.model.messages, 'change', () => this.requestUpdate());
this.listenTo(this.model.messages, 'remove', this.requestUpdate); this.listenTo(this.model.messages, 'remove', () => this.requestUpdate());
this.listenTo(this.model.messages, 'rendered', this.requestUpdate); this.listenTo(this.model.messages, 'rendered', () => this.requestUpdate());
this.listenTo(this.model.messages, 'reset', this.requestUpdate); this.listenTo(this.model.messages, 'reset', () => this.requestUpdate());
this.listenTo(this.model.notifications, 'change', this.requestUpdate); this.listenTo(this.model.notifications, 'change', () => this.requestUpdate());
this.listenTo(this.model.ui, 'change', this.requestUpdate); this.listenTo(this.model.ui, 'change', () => this.requestUpdate());
this.listenTo(this.model.ui, 'change:scrolled', this.scrollDown); this.listenTo(this.model.ui, 'change:scrolled', this.scrollDown);
if (this.model.occupants) { if (this.model.occupants) {
this.listenTo(this.model.occupants, 'change', this.requestUpdate); this.listenTo(this.model.occupants, 'change', () => this.requestUpdate());
} }
this.addEventListener('scroll', markScrolled); this.addEventListener('scroll', markScrolled);
} }

View File

@ -12,7 +12,7 @@ export default class MessageLimitIndicator extends CustomElement {
connectedCallback () { connectedCallback () {
super.connectedCallback(); super.connectedCallback();
this.listenTo(this.model, 'change:draft', this.requestUpdate); this.listenTo(this.model, 'change:draft', () => this.requestUpdate());
} }
render () { render () {