Commit bbe2a622 authored by JC Brand's avatar JC Brand

converse-muc: Create `info` and `error` messages on the model

instead of on the view.
parent 970ba96c
......@@ -2344,7 +2344,8 @@
.c('status').attrs({code:'210'}).nodeTree;
_converse.connection._dataRecv(test_utils.createRequest(presence));
view.model.sendMessage('hello world');
await new Promise((resolve, reject) => view.once('messageInserted', resolve));
await test_utils.waitUntil(() => view.el.querySelectorAll('.chat-msg').length === 3);
expect(view.model.messages.last().get('affiliation')).toBe('owner');
expect(view.model.messages.last().get('role')).toBe('moderator');
expect(view.el.querySelectorAll('.chat-msg').length).toBe(3);
......
This diff is collapsed.
......@@ -112,6 +112,8 @@ converse.plugins.add('converse-message-view', {
this.renderFileUploadProgresBar();
} else if (this.model.get('type') === 'error') {
this.renderErrorMessage();
} else if (this.model.get('type') === 'info') {
this.renderInfoMessage();
} else {
await this.renderChatMessage();
}
......@@ -212,6 +214,16 @@ converse.plugins.add('converse-message-view', {
}
},
renderInfoMessage () {
const msg = u.stringToElement(
tpl_info(Object.assign(this.model.toJSON(), {
'extra_classes': 'chat-info',
'isodate': dayjs(this.model.get('time')).toISOString()
}))
);
return this.replaceElement(msg);
},
renderErrorMessage () {
const msg = u.stringToElement(
tpl_info(Object.assign(this.model.toJSON(), {
......
......@@ -197,6 +197,12 @@ converse.plugins.add('converse-minimize', {
const minimizableChatBoxView = {
/**
* Maximizes a minimized chat box.
* Will trigger {@link _converse#chatBoxMaximized}
* @returns {_converse.ChatBoxView|_converse.ChatRoomView}
*/
maximize () {
// Restores a minimized chat box
const { _converse } = this.__super__;
......@@ -216,6 +222,11 @@ converse.plugins.add('converse-minimize', {
return this;
},
/**
* Minimizes a chat box.
* Will trigger {@link _converse#chatBoxMinimized}
* @returns {_converse.ChatBoxView|_converse.ChatRoomView}
*/
minimize (ev) {
const { _converse } = this.__super__;
if (ev && ev.preventDefault) { ev.preventDefault(); }
......@@ -234,6 +245,7 @@ converse.plugins.add('converse-minimize', {
* @example _converse.api.listen.on('chatBoxMinimized', view => { ... });
*/
_converse.api.trigger('chatBoxMinimized', this);
return this;
},
onMinimizedChanged (item) {
......
This diff is collapsed.
This diff is collapsed.
......@@ -114,8 +114,10 @@
return _converse.chatboxviews.get(jid);
};
utils.openChatRoom = function (_converse, room, server) {
return _converse.api.rooms.open(`${room}@${server}`);
utils.openChatRoom = async function (_converse, room, server) {
const model = await _converse.api.rooms.open(`${room}@${server}`);
await model.messages.fetched;
return model;
};
utils.getRoomFeatures = async function (_converse, room, server, features=[]) {
......
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