Commit 2045741f authored by JC Brand's avatar JC Brand

Add `api.chatviews.get` method

parent 044907e4
......@@ -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 ************************/
}
});
......
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