diff --git a/dist/converse.js b/dist/converse.js index 7711fb1c8..de3a5c3f2 100644 --- a/dist/converse.js +++ b/dist/converse.js @@ -48776,21 +48776,6 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_3__["default"].plugins }); /************************ BEGIN Event Handlers ************************/ - _converse.api.waitUntil('rosterContactsFetched').then(() => { - _converse.roster.on('add', contact => { - /* When a new contact is added, check if we already have a - * chatbox open for it, and if so attach it to the chatbox. - */ - const chatbox = _converse.chatboxes.findWhere({ - 'jid': contact.get('jid') - }); - - if (chatbox) { - chatbox.addRelatedContact(contact); - } - }); - }); - _converse.api.listen.on('chatBoxesInitialized', () => { _converse.chatboxviews = new _converse.ChatBoxViews({ 'model': _converse.chatboxes @@ -69628,6 +69613,21 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins } } + _converse.api.waitUntil('rosterContactsFetched').then(() => { + _converse.roster.on('add', contact => { + /* When a new contact is added, check if we already have a + * chatbox open for it, and if so attach it to the chatbox. + */ + const chatbox = _converse.chatboxes.findWhere({ + 'jid': contact.get('jid') + }); + + if (chatbox) { + addRelatedContactToChatbox(chatbox, contact); + } + }); + }); + function updateUnreadCounter(chatbox) { const contact = _converse.roster.findWhere({ 'jid': chatbox.get('jid') diff --git a/src/converse-chatboxviews.js b/src/converse-chatboxviews.js index 3c0fcc1d4..7824f66f7 100644 --- a/src/converse-chatboxviews.js +++ b/src/converse-chatboxviews.js @@ -154,18 +154,6 @@ converse.plugins.add('converse-chatboxviews', { /************************ BEGIN Event Handlers ************************/ - _converse.api.waitUntil('rosterContactsFetched').then(() => { - _converse.roster.on('add', (contact) => { - /* When a new contact is added, check if we already have a - * chatbox open for it, and if so attach it to the chatbox. - */ - const chatbox = _converse.chatboxes.findWhere({'jid': contact.get('jid')}); - if (chatbox) { - chatbox.addRelatedContact(contact); - } - }); - }); - _converse.api.listen.on('chatBoxesInitialized', () => { _converse.chatboxviews = new _converse.ChatBoxViews({ 'model': _converse.chatboxes diff --git a/src/headless/converse-roster.js b/src/headless/converse-roster.js index af85a3b8e..e672a122f 100644 --- a/src/headless/converse-roster.js +++ b/src/headless/converse-roster.js @@ -887,6 +887,19 @@ converse.plugins.add('converse-roster', { } } + _converse.api.waitUntil('rosterContactsFetched').then(() => { + _converse.roster.on('add', (contact) => { + /* When a new contact is added, check if we already have a + * chatbox open for it, and if so attach it to the chatbox. + */ + const chatbox = _converse.chatboxes.findWhere({'jid': contact.get('jid')}); + if (chatbox) { + addRelatedContactToChatbox(chatbox, contact); + } + }); + }); + + function updateUnreadCounter (chatbox) { const contact = _converse.roster.findWhere({'jid': chatbox.get('jid')}); if (!_.isUndefined(contact)) { diff --git a/src/headless/dist/converse-headless.js b/src/headless/dist/converse-headless.js index ea55d46a9..3736f3a7b 100644 --- a/src/headless/dist/converse-headless.js +++ b/src/headless/dist/converse-headless.js @@ -48127,6 +48127,21 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins } } + _converse.api.waitUntil('rosterContactsFetched').then(() => { + _converse.roster.on('add', contact => { + /* When a new contact is added, check if we already have a + * chatbox open for it, and if so attach it to the chatbox. + */ + const chatbox = _converse.chatboxes.findWhere({ + 'jid': contact.get('jid') + }); + + if (chatbox) { + addRelatedContactToChatbox(chatbox, contact); + } + }); + }); + function updateUnreadCounter(chatbox) { const contact = _converse.roster.findWhere({ 'jid': chatbox.get('jid')