Avoid unnecessarily sending out a presence stanza
- Set roster_fetched flag when we get an empty IQ[type="result"] stanza - Set `restored` flag when resuming in converse-smacks - Don't trigger change event when fetching xmppstatus values - Removed two events, since we can just listen to `change` on `_converse.xmppstatus`.
This commit is contained in:
parent
ba9d28b5c2
commit
f3c4dbc344
|
@ -51,6 +51,9 @@
|
||||||
- Remove the `expose_rid_and_sid` configuration setting.
|
- Remove the `expose_rid_and_sid` configuration setting.
|
||||||
- A `prebind_url` is now mandatory when setting `authentication` to `prebind`.
|
- A `prebind_url` is now mandatory when setting `authentication` to `prebind`.
|
||||||
It's no longer possible to pass in `rid` and `sid` values to `converse.initialize.
|
It's no longer possible to pass in `rid` and `sid` values to `converse.initialize.
|
||||||
|
- Removed events `statusChanged` and `statusMessageChanged`. Instead, you can
|
||||||
|
listen on the `change:status` or `change:status\_message` events on
|
||||||
|
`_converse.xmppstatus`.
|
||||||
|
|
||||||
### API changes
|
### API changes
|
||||||
|
|
||||||
|
|
|
@ -1003,7 +1003,8 @@ _converse.initialize = async function (settings, callback) {
|
||||||
_converse.xmppstatus.browserStorage = new BrowserStorage.session(id);
|
_converse.xmppstatus.browserStorage = new BrowserStorage.session(id);
|
||||||
_converse.xmppstatus.fetch({
|
_converse.xmppstatus.fetch({
|
||||||
'success': _.partial(_converse.onStatusInitialized, reconnecting),
|
'success': _.partial(_converse.onStatusInitialized, reconnecting),
|
||||||
'error': _.partial(_converse.onStatusInitialized, reconnecting)
|
'error': _.partial(_converse.onStatusInitialized, reconnecting),
|
||||||
|
'silent': true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1152,28 +1153,13 @@ _converse.initialize = async function (settings, callback) {
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize () {
|
initialize () {
|
||||||
this.on('change:status', (item) => {
|
this.on('change', item => {
|
||||||
const status = this.get('status');
|
if (!_.isObject(item.changed)) {
|
||||||
this.sendPresence(status);
|
return;
|
||||||
/**
|
}
|
||||||
* Triggered when the current user's status has changed
|
if ('status' in item.changed || 'status_message' in item.changed) {
|
||||||
* @event _converse#statusChanged
|
this.sendPresence(this.get('status'), this.get('status_message'));
|
||||||
* @type { string }
|
}
|
||||||
* @example _converse.api.listen.on('statusChanged', status => { ... });
|
|
||||||
*/
|
|
||||||
_converse.api.trigger('statusChanged', status);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.on('change:status_message', () => {
|
|
||||||
const status_message = this.get('status_message');
|
|
||||||
this.sendPresence(this.get('status'), status_message);
|
|
||||||
/**
|
|
||||||
* Triggered when the current user's custom status message has changed.
|
|
||||||
* @event _converse#statusMessageChanged
|
|
||||||
* @type { string }
|
|
||||||
* @example _converse.api.listen.on('statusMessageChanged', message => { ... });
|
|
||||||
*/
|
|
||||||
_converse.api.trigger('statusMessageChanged', status_message);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -672,8 +672,8 @@ converse.plugins.add('converse-roster', {
|
||||||
const items = sizzle(`item`, query);
|
const items = sizzle(`item`, query);
|
||||||
_.each(items, (item) => this.updateContact(item));
|
_.each(items, (item) => this.updateContact(item));
|
||||||
this.data.save('version', query.getAttribute('ver'));
|
this.data.save('version', query.getAttribute('ver'));
|
||||||
_converse.session.save('roster_fetched', true);
|
|
||||||
}
|
}
|
||||||
|
_converse.session.save('roster_fetched', true);
|
||||||
/**
|
/**
|
||||||
* When the roster has been received from the XMPP server.
|
* When the roster has been received from the XMPP server.
|
||||||
* See also the `cachedRoster` event further up, which gets called instead of
|
* See also the `cachedRoster` event further up, which gets called instead of
|
||||||
|
|
|
@ -149,6 +149,7 @@ converse.plugins.add('converse-smacks', {
|
||||||
resendUnackedStanzas();
|
resendUnackedStanzas();
|
||||||
_converse.connection.do_bind = false; // No need to bind our resource anymore
|
_converse.connection.do_bind = false; // No need to bind our resource anymore
|
||||||
_converse.connection.authenticated = true;
|
_converse.connection.authenticated = true;
|
||||||
|
_converse.connection.restored = true;
|
||||||
_converse.connection._changeConnectStatus(Strophe.Status.CONNECTED, null);
|
_converse.connection._changeConnectStatus(Strophe.Status.CONNECTED, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user