Add a "create" parameter to rooms.get
to indicate whether the room should be created if not found.
This commit is contained in:
parent
95c5f9d420
commit
10ca2900d4
@ -651,8 +651,19 @@ get
|
||||
~~~
|
||||
|
||||
Returns an object representing a multi user chat box (room).
|
||||
It takes 3 parameters:
|
||||
|
||||
Similar to chats.get API
|
||||
* the room JID
|
||||
* the user's nickname (if not specified, the node part of the user's JID will be used).
|
||||
* boolean, indicating whether the room should be created if not found (default: `false`)
|
||||
|
||||
The last two parameters are optional.
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
var nick = 'dread-pirate-roberts';
|
||||
var create_if_not_found = true;
|
||||
converse.rooms.open('group@muc.example.com', nick, create_if_not_found)
|
||||
|
||||
open
|
||||
~~~~
|
||||
|
@ -1437,9 +1437,9 @@
|
||||
return this.model.chatBoxMayBeShown(chatbox);
|
||||
},
|
||||
|
||||
getChatBox: function (attrs) {
|
||||
getChatBox: function (attrs, create) {
|
||||
var chatbox = this.model.get(attrs.jid);
|
||||
if (!chatbox) {
|
||||
if (!chatbox && create) {
|
||||
chatbox = this.model.create(attrs, {
|
||||
'error': function (model, response) {
|
||||
converse.log(response.responseText);
|
||||
@ -1453,7 +1453,7 @@
|
||||
/* Find the chat box and show it (if it may be shown).
|
||||
* If it doesn't exist, create it.
|
||||
*/
|
||||
var chatbox = this.getChatBox(attrs);
|
||||
var chatbox = this.getChatBox(attrs, true);
|
||||
if (this.chatBoxMayBeShown(chatbox)) {
|
||||
chatbox.trigger('show', true);
|
||||
}
|
||||
|
@ -1431,8 +1431,8 @@
|
||||
}
|
||||
return _.map(jids, _.partial(_transform, _, nick, fetcher));
|
||||
},
|
||||
'get': function (jids, nick) {
|
||||
var fetcher = converse.chatboxviews.getChatBox.bind(converse.chatboxviews);
|
||||
'get': function (jids, nick, create) {
|
||||
var fetcher = _.partial(converse.chatboxviews.getChatBox.bind(converse.chatboxviews), _, create);
|
||||
if (!nick) {
|
||||
nick = Strophe.getNodeFromJid(converse.bare_jid);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user