Add and document bring_to_foreground option to rooms API

This commit is contained in:
JC Brand 2017-12-15 20:51:07 +00:00
parent 3c7454c4c1
commit fbc81d30ec
3 changed files with 14 additions and 8 deletions

View File

@ -987,6 +987,9 @@ Room attributes that may be passed in:
The values should be named without the ``muc#roomconfig_`` prefix. The values should be named without the ``muc#roomconfig_`` prefix.
* *maximize*: A boolean, indicating whether minimized rooms should also be * *maximize*: A boolean, indicating whether minimized rooms should also be
maximized, when opened. Set to ``false`` by default. maximized, when opened. Set to ``false`` by default.
* *bring_to_foreground*: A boolean indicating whether the room should be
brought to the foreground and therefore replace the currently shown chat.
If there is no chat currently open, then this option is ineffective.
For example, opening a room with a specific default configuration: For example, opening a room with a specific default configuration:

View File

@ -231,7 +231,7 @@
*/ */
ev.preventDefault(); ev.preventDefault();
const jid = ev.target.getAttribute('data-room-jid'); const jid = ev.target.getAttribute('data-room-jid');
const chatroom = _converse.openChatRoom({'jid': jid}, true); const chatroom = _converse.api.rooms.open(jid, {'bring_to_foreground': true});
_converse.chatboxviews.get(jid).renderBookmarkForm(); _converse.chatboxviews.get(jid).renderBookmarkForm();
}, },
}); });

View File

@ -2895,13 +2895,16 @@
_converse.getChatRoom = function (jid, attrs, fetcher) { _converse.getChatRoom = function (jid, attrs, fetcher) {
jid = jid.toLowerCase(); jid = jid.toLowerCase();
return _converse.getViewForChatBox(fetcher(_.extend({ return _converse.getViewForChatBox(
'id': jid, fetcher(_.extend({
'jid': jid, 'id': jid,
'name': Strophe.unescapeNode(Strophe.getNodeFromJid(jid)), 'jid': jid,
'type': CHATROOMS_TYPE, 'name': Strophe.unescapeNode(Strophe.getNodeFromJid(jid)),
'box_id': b64_sha1(jid) 'type': CHATROOMS_TYPE,
}, attrs))); 'box_id': b64_sha1(jid)
}, attrs),
attrs.bring_to_foreground
));
}; };
/* We extend the default converse.js API to add methods specific to MUC /* We extend the default converse.js API to add methods specific to MUC