Commit 59e216ad authored by JC Brand's avatar JC Brand

muc: no need for `message_queue`...

since we create the `fetched` promise earlier
parent c750748b
......@@ -262,17 +262,12 @@ describe("XEP-0198 Stream Management", function () {
await _converse.api.waitUntil('chatBoxesFetched');
const muc = _converse.chatboxes.get(muc_jid);
await u.waitUntil(() => muc.message_queue.length === 1);
const view = _converse.chatboxviews.get(muc_jid);
await mock.getRoomFeatures(_converse, muc_jid);
await mock.receiveOwnMUCPresence(_converse, muc_jid, nick);
await u.waitUntil(() => (view.model.session.get('connection_status') === converse.ROOMSTATUS.ENTERED));
await view.model.messages.fetched;
await u.waitUntil(() => (muc.session.get('connection_status') === converse.ROOMSTATUS.ENTERED));
await muc.messages.fetched;
await u.waitUntil(() => muc.messages.length);
expect(muc.messages.at(0).get('message')).toBe('First message')
delete _converse.no_connection_on_bind;
done();
}));
......
......@@ -475,13 +475,6 @@ converse.plugins.add('converse-muc', {
return this;
},
async fetchMessages () {
await _converse.ChatBox.prototype.fetchMessages.call(this);
const queued_messages = this.message_queue.map(m => this.queueMessage(m));
this.message_queue = [];
return Promise.all(queued_messages);
},
async clearCache () {
this.session.save('connection_status', converse.ROOMSTATUS.DISCONNECTED);
if (this.occupants.length) {
......@@ -533,11 +526,6 @@ converse.plugins.add('converse-muc', {
return this.join();
},
initMessages () {
this.message_queue = [];
_converse.ChatBox.prototype.initMessages.call(this);
},
async onConnectionStatusChanged () {
if (this.session.get('connection_status') === converse.ROOMSTATUS.ENTERED) {
await this.occupants.fetchMembers();
......@@ -1935,24 +1923,6 @@ converse.plugins.add('converse-muc', {
return false;
},
/**
* Queue an incoming message stanza meant for this {@link _converse.Chatroom} for processing.
* @async
* @private
* @method _converse.ChatRoom#queueMessage
* @param { Promise<MessageAttributes> } attrs - A promise which resolves to the message attributes
*/
queueMessage (attrs) {
if (this.messages?.fetched) {
this.msg_chain = (this.msg_chain || this.messages.fetched);
this.msg_chain = this.msg_chain.then(() => this.onMessage(attrs));
return this.msg_chain;
} else {
this.message_queue.push(attrs);
return Promise.resolve();
}
},
/**
* @param {String} actor - The nickname of the actor that caused the notification
* @param {String|Array<String>} states - The state or states representing the type of notificcation
......@@ -2752,7 +2722,6 @@ converse.plugins.add('converse-muc', {
const muc = _converse.chatboxes.get(muc_jid);
if (muc) {
await muc.initialized;
await muc.messages.fetched
muc.message_handler.run(stanza);
}
});
......
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