diff options
Diffstat (limited to 'web/react/utils')
-rw-r--r-- | web/react/utils/async_client.jsx | 24 | ||||
-rw-r--r-- | web/react/utils/client.jsx | 15 | ||||
-rw-r--r-- | web/react/utils/constants.jsx | 1 |
3 files changed, 40 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; diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx index 6a1f7c820..7b014cdad 100644 --- a/web/react/utils/client.jsx +++ b/web/react/utils/client.jsx @@ -554,6 +554,21 @@ module.exports.getChannels = function(success, error) { }); }; +module.exports.getChannel = function(id, success, error) { + $.ajax({ + url: "/api/v1/channels/" + id + "/", + dataType: 'json', + type: 'GET', + success: success, + error: function(xhr, status, err) { + e = handleError("getChannel", xhr, status, err); + error(e); + } + }); + + module.exports.track('api', 'api_channel_get'); +}; + module.exports.getMoreChannels = function(success, error) { $.ajax({ url: "/api/v1/channels/more", diff --git a/web/react/utils/constants.jsx b/web/react/utils/constants.jsx index bed0ec556..19c92df33 100644 --- a/web/react/utils/constants.jsx +++ b/web/react/utils/constants.jsx @@ -10,6 +10,7 @@ module.exports = { CLICK_CHANNEL: null, CREATE_CHANNEL: null, RECIEVED_CHANNELS: null, + RECIEVED_CHANNEL: null, RECIEVED_MORE_CHANNELS: null, RECIEVED_CHANNEL_EXTRA_INFO: null, |