Bugfix. Don't create multiple RosterContactView objects
This commit is contained in:
parent
77f38bb40b
commit
bad815b429
@ -212,6 +212,7 @@ describe("Message Archive Management", function () {
|
||||
await mock.waitForRoster(_converse, 'current', 1);
|
||||
const contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@montague.lit';
|
||||
await mock.openChatBoxFor(_converse, contact_jid);
|
||||
const view = _converse.chatboxviews.get(contact_jid);
|
||||
await mock.waitUntilDiscoConfirmed(_converse, _converse.bare_jid, null, [Strophe.NS.MAM]);
|
||||
const sent_IQs = _converse.connection.IQ_stanzas;
|
||||
const stanza = await u.waitUntil(() => sent_IQs.filter(iq => iq.querySelector(`iq[type="set"] query[xmlns="${Strophe.NS.MAM}"]`)).pop());
|
||||
@ -252,7 +253,6 @@ describe("Message Archive Management", function () {
|
||||
.c('count').t('16');
|
||||
_converse.connection._dataRecv(mock.createRequest(iq_result));
|
||||
|
||||
const view = _converse.chatboxviews.get(contact_jid);
|
||||
await new Promise(resolve => view.once('messageInserted', resolve));
|
||||
expect(view.model.messages.length).toBe(1);
|
||||
expect(view.model.messages.at(0).get('message')).toBe("Thrice the brinded cat hath mew'd.");
|
||||
|
@ -300,7 +300,6 @@ converse.plugins.add('converse-rosterview', {
|
||||
this.listenTo(this.model, "change", this.debouncedRender);
|
||||
this.listenTo(this.model, "destroy", this.remove);
|
||||
this.listenTo(this.model, "highlight", this.highlight);
|
||||
this.listenTo(this.model, "open", this.openChat);
|
||||
this.listenTo(this.model, "remove", this.remove);
|
||||
this.listenTo(this.model, 'vcard:change', this.debouncedRender);
|
||||
this.listenTo(this.model.presence, "change:show", this.debouncedRender);
|
||||
@ -453,8 +452,7 @@ converse.plugins.add('converse-rosterview', {
|
||||
|
||||
openChat (ev) {
|
||||
if (ev && ev.preventDefault) { ev.preventDefault(); }
|
||||
const attrs = this.model.attributes;
|
||||
api.chats.open(attrs.jid, attrs, true);
|
||||
this.model.openChat();
|
||||
},
|
||||
|
||||
async removeContact (ev) {
|
||||
|
@ -248,6 +248,11 @@ converse.plugins.add('converse-roster', {
|
||||
this.presence = _converse.presences.findWhere({'jid': jid}) || _converse.presences.create({'jid': jid});
|
||||
},
|
||||
|
||||
openChat () {
|
||||
const attrs = this.attributes;
|
||||
api.chats.open(attrs.jid, attrs, true);
|
||||
},
|
||||
|
||||
getDisplayName () {
|
||||
// Gets overridden in converse-vcard where the fullname is may be returned
|
||||
if (this.get('nickname')) {
|
||||
|
@ -132,17 +132,15 @@ window.addEventListener('converse-loaded', () => {
|
||||
};
|
||||
|
||||
mock.openChatBoxes = function (converse, amount) {
|
||||
const views = [];
|
||||
for (let i=0; i<amount; i++) {
|
||||
const jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@montague.lit';
|
||||
views.push(converse.roster.get(jid).trigger("open"));
|
||||
converse.roster.get(jid).openChat();
|
||||
}
|
||||
return views;
|
||||
};
|
||||
|
||||
mock.openChatBoxFor = async function (_converse, jid) {
|
||||
await _converse.api.waitUntil('rosterContactsFetched');
|
||||
_converse.roster.get(jid).trigger("open");
|
||||
_converse.roster.get(jid).openChat();
|
||||
return u.waitUntil(() => _converse.chatboxviews.get(jid), 1000);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user