Add api.chatviews.get
method
This commit is contained in:
parent
044907e4fa
commit
2045741fbe
|
@ -864,6 +864,31 @@ To return an array of chatboxes, provide an array of JIDs:
|
|||
| url | The URL of the chatbox heading. |
|
||||
+-------------+-----------------------------------------------------+
|
||||
|
||||
The **chatviews** grouping
|
||||
----------------------
|
||||
|
||||
.. note:: This is only for private chats.
|
||||
|
||||
get
|
||||
~~~
|
||||
|
||||
Returns a `Backbone.View <http://backbonejs.org/#View>`_ of type _converse.ChatBoxView.
|
||||
|
||||
The chat should already be open, otherwise `undefined` will be returned.
|
||||
|
||||
To return a single view, provide the JID of the contact:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
_converse.api.chatviews.get('buddy@example.com')
|
||||
|
||||
To return an array of views, provide an array of JIDs:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
_converse.api.chatviews.get(['buddy1@example.com', 'buddy2@example.com'])
|
||||
|
||||
|
||||
.. _`listen-grouping`:
|
||||
|
||||
The **listen** grouping
|
||||
|
|
|
@ -1186,6 +1186,27 @@
|
|||
// Advertise that we support XEP-0382 Message Spoilers
|
||||
_converse.connection.disco.addFeature(Strophe.NS.SPOILER);
|
||||
});
|
||||
|
||||
|
||||
/************************ BEGIN API ************************/
|
||||
_.extend(_converse.api, {
|
||||
'chatviews': {
|
||||
'get' (jids) {
|
||||
if (_.isUndefined(jids)) {
|
||||
_converse.log(
|
||||
"chats.create: You need to provide at least one JID",
|
||||
Strophe.LogLevel.ERROR
|
||||
);
|
||||
return null;
|
||||
}
|
||||
if (_.isString(jids)) {
|
||||
return _converse.chatboxviews.get(jids);
|
||||
}
|
||||
return _.map(jids, (jid) => _converse.chatboxviews.get(jids));
|
||||
}
|
||||
}
|
||||
});
|
||||
/************************ END API ************************/
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user