Commit ceb9d129 authored by JC Brand's avatar JC Brand

Don't store ChatRoomOccupants on ChatRoomView

Helps with enforcing discipline of keeping them separate
parent 7cd69726
...@@ -1432,8 +1432,8 @@ ...@@ -1432,8 +1432,8 @@
await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy'); await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy');
var name; var name;
var view = _converse.chatboxviews.get('lounge@localhost'), const view = _converse.chatboxviews.get('lounge@localhost');
occupants = view.el.querySelector('.occupant-list'); const occupants = view.el.querySelector('.occupant-list');
var presence, role, jid, model; var presence, role, jid, model;
for (var i=0; i<mock.chatroom_names.length; i++) { for (var i=0; i<mock.chatroom_names.length; i++) {
name = mock.chatroom_names[i]; name = mock.chatroom_names[i];
...@@ -1452,8 +1452,8 @@ ...@@ -1452,8 +1452,8 @@
.c('status').attrs({code:'110'}).nodeTree; .c('status').attrs({code:'110'}).nodeTree;
_converse.connection._dataRecv(test_utils.createRequest(presence)); _converse.connection._dataRecv(test_utils.createRequest(presence));
expect(occupants.querySelectorAll('li').length).toBe(2+i); expect(occupants.querySelectorAll('li').length).toBe(2+i);
model = view.occupantsview.model.where({'nick': name})[0]; model = view.model.occupants.where({'nick': name})[0];
var index = view.occupantsview.model.indexOf(model); const index = view.model.occupants.indexOf(model);
expect(occupants.querySelectorAll('li .occupant-nick')[index].textContent.trim()).toBe(mock.chatroom_names[i]); expect(occupants.querySelectorAll('li .occupant-nick')[index].textContent.trim()).toBe(mock.chatroom_names[i]);
} }
...@@ -1506,8 +1506,8 @@ ...@@ -1506,8 +1506,8 @@
.c('status').attrs({code:'110'}).nodeTree; .c('status').attrs({code:'110'}).nodeTree;
_converse.connection._dataRecv(test_utils.createRequest(presence)); _converse.connection._dataRecv(test_utils.createRequest(presence));
expect(occupants.querySelectorAll('li').length).toBe(2+i); expect(occupants.querySelectorAll('li').length).toBe(2+i);
model = view.occupantsview.model.where({'nick': name})[0]; model = view.model.occupants.where({'nick': name})[0];
var index = view.occupantsview.model.indexOf(model); const index = view.model.occupants.indexOf(model);
expect(occupants.querySelectorAll('li .occupant-nick')[index].textContent.trim()).toBe(mock.chatroom_names[i]); expect(occupants.querySelectorAll('li .occupant-nick')[index].textContent.trim()).toBe(mock.chatroom_names[i]);
} }
...@@ -1801,8 +1801,7 @@ ...@@ -1801,8 +1801,7 @@
spyOn(_converse.connection, 'send').and.callFake(function (stanza) { spyOn(_converse.connection, 'send').and.callFake(function (stanza) {
sent_stanza = stanza; sent_stanza = stanza;
}); });
const results_el = view.occupantsview.el.querySelector('.suggestion-box__results'); const hint = await test_utils.waitUntil(() => view.el.querySelector('.suggestion-box__results li'));
const hint = results_el.firstElementChild;
expect(input.value).toBe('Felix'); expect(input.value).toBe('Felix');
expect(hint.textContent).toBe('Felix Amsel'); expect(hint.textContent).toBe('Felix Amsel');
......
...@@ -637,9 +637,9 @@ converse.plugins.add('converse-muc-views', { ...@@ -637,9 +637,9 @@ converse.plugins.add('converse-muc-views', {
createOccupantsView () { createOccupantsView () {
this.model.occupants.chatroomview = this; this.model.occupants.chatroomview = this;
this.occupantsview = new _converse.ChatRoomOccupantsView({'model': this.model.occupants}); const view = new _converse.ChatRoomOccupantsView({'model': this.model.occupants});
const container_el = this.el.querySelector('.chatroom-body'); const container_el = this.el.querySelector('.chatroom-body');
container_el.insertAdjacentElement('beforeend', this.occupantsview.el); container_el.insertAdjacentElement('beforeend', view.el);
}, },
initMentionAutoComplete () { initMentionAutoComplete () {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment