浏览代码

Wait for roster to be initialized

JC Brand 4 年之前
父节点
当前提交
d1abf3a04e
共有 2 个文件被更改,包括 2 次插入2 次删除
  1. 2 0
      src/headless/plugins/headlines.js
  2. 0 2
      src/plugins/notifications/tests/notification.js

+ 2 - 0
src/headless/plugins/headlines.js

@@ -83,6 +83,8 @@ converse.plugins.add('converse-headlines', {
             // Handler method for all incoming messages of type "headline".
             // Handler method for all incoming messages of type "headline".
             if (isHeadline(stanza) || isServerMessage(stanza)) {
             if (isHeadline(stanza) || isServerMessage(stanza)) {
                 const from_jid = stanza.getAttribute('from');
                 const from_jid = stanza.getAttribute('from');
+
+                await api.waitUntil('rosterInitialized')
                 if (from_jid.includes('@') &&
                 if (from_jid.includes('@') &&
                         !_converse.roster.get(from_jid) &&
                         !_converse.roster.get(from_jid) &&
                         !api.settings.get("allow_non_roster_messaging")) {
                         !api.settings.get("allow_non_roster_messaging")) {

+ 0 - 2
src/plugins/notifications/tests/notification.js

@@ -94,8 +94,6 @@ describe("Notifications", function () {
                     _converse.connection._dataRecv(mock.createRequest(stanza));
                     _converse.connection._dataRecv(mock.createRequest(stanza));
 
 
                     await u.waitUntil(() => _converse.chatboxviews.keys().length === 2);
                     await u.waitUntil(() => _converse.chatboxviews.keys().length === 2);
-                    const view = _converse.chatboxviews.get('notify.example.com');
-                    await new Promise(resolve => view.model.messages.once('rendered', resolve));
                     expect(_converse.chatboxviews.keys().includes('notify.example.com')).toBeTruthy();
                     expect(_converse.chatboxviews.keys().includes('notify.example.com')).toBeTruthy();
                     expect(window.Notification).toHaveBeenCalled();
                     expect(window.Notification).toHaveBeenCalled();
                 }));
                 }));