summaryrefslogtreecommitdiffstats
path: root/web/react/utils/async_client.jsx
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-07-27 11:30:03 -0400
committerJoramWilander <jwawilander@gmail.com>2015-08-11 12:09:54 -0400
commit1c0ee4d2f65d1d4434a3a16070abe7d61a268ce6 (patch)
treea10ebb3fb82ad16c015276b0618c1beda18755ff /web/react/utils/async_client.jsx
parent4c7cdb20f074e2c06a08cd64a57060b8e8b64d2e (diff)
downloadchat-1c0ee4d2f65d1d4434a3a16070abe7d61a268ce6.tar.gz
chat-1c0ee4d2f65d1d4434a3a16070abe7d61a268ce6.tar.bz2
chat-1c0ee4d2f65d1d4434a3a16070abe7d61a268ce6.zip
added getChannel api service and use that over getChannels where appropriate on client
Diffstat (limited to 'web/react/utils/async_client.jsx')
-rw-r--r--web/react/utils/async_client.jsx24
1 files changed, 24 insertions, 0 deletions
diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx
index f35b0f6cc..b938216ac 100644
--- a/web/react/utils/async_client.jsx
+++ b/web/react/utils/async_client.jsx
@@ -81,6 +81,30 @@ module.exports.getChannels = function(force, updateLastViewed, checkVersion) {
}
}
+module.exports.getChannel = function(id) {
+ if (isCallInProgress("getChannel"+id)) return;
+
+ callTracker["getChannel"+id] = utils.getTimestamp();
+ client.getChannel(id,
+ function(data, textStatus, xhr) {
+ callTracker["getChannel"+id] = 0;
+
+ if (xhr.status === 304 || !data) return;
+
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECIEVED_CHANNEL,
+ channel: data.channel,
+ member: data.member
+ });
+
+ },
+ function(err) {
+ callTracker["getChannel"+id] = 0;
+ dispatchError(err, "getChannel");
+ }
+ );
+}
+
module.exports.updateLastViewedAt = function() {
if (isCallInProgress("updateLastViewed")) return;