diff options
Diffstat (limited to 'webapp/utils')
-rw-r--r-- | webapp/utils/async_client.jsx | 229 |
1 files changed, 0 insertions, 229 deletions
diff --git a/webapp/utils/async_client.jsx b/webapp/utils/async_client.jsx index 47327c5e5..712d447e8 100644 --- a/webapp/utils/async_client.jsx +++ b/webapp/utils/async_client.jsx @@ -2,10 +2,8 @@ // See License.txt for license information. import BrowserStore from 'stores/browser_store.jsx'; -import ChannelStore from 'stores/channel_store.jsx'; import UserStore from 'stores/user_store.jsx'; import TeamStore from 'stores/team_store.jsx'; -import ErrorStore from 'stores/error_store.jsx'; import * as GlobalActions from 'actions/global_actions.jsx'; @@ -62,233 +60,6 @@ export function checkVersion() { } } -export function getChannels() { - return new Promise((resolve, reject) => { - if (isCallInProgress('getChannels')) { - resolve(); - return; - } - - callTracker.getChannels = utils.getTimestamp(); - - Client.getChannels( - (data) => { - callTracker.getChannels = 0; - - AppDispatcher.handleServerAction({ - type: ActionTypes.RECEIVED_CHANNELS, - channels: data - }); - resolve(); - }, - (err) => { - callTracker.getChannels = 0; - dispatchError(err, 'getChannels'); - reject(new Error('Unable to getChannels')); - } - ); - }); -} - -export function getChannel(id) { - if (isCallInProgress('getChannel' + id)) { - return; - } - - callTracker['getChannel' + id] = utils.getTimestamp(); - - Client.getChannel(id, - (data) => { - callTracker['getChannel' + id] = 0; - - AppDispatcher.handleServerAction({ - type: ActionTypes.RECEIVED_CHANNEL, - channel: data.channel, - member: data.member - }); - }, - (err) => { - callTracker['getChannel' + id] = 0; - dispatchError(err, 'getChannel'); - } - ); -} - -export function getMyChannelMembers() { - return new Promise((resolve, reject) => { - if (isCallInProgress('getMyChannelMembers')) { - resolve(); - return; - } - - callTracker.getMyChannelMembers = utils.getTimestamp(); - - Client.getMyChannelMembers( - (data) => { - callTracker.getMyChannelMembers = 0; - - AppDispatcher.handleServerAction({ - type: ActionTypes.RECEIVED_MY_CHANNEL_MEMBERS, - members: data - }); - resolve(); - }, - (err) => { - callTracker.getMyChannelMembers = 0; - dispatchError(err, 'getMyChannelMembers'); - reject(new Error('Unable to getMyChannelMembers')); - } - ); - }); -} - -export function getMyChannelMembersForTeam(teamId) { - return new Promise((resolve, reject) => { - if (isCallInProgress(`getMyChannelMembers${teamId}`)) { - resolve(); - return; - } - - callTracker[`getMyChannelMembers${teamId}`] = utils.getTimestamp(); - - Client.getMyChannelMembersForTeam( - teamId, - (data) => { - callTracker[`getMyChannelMembers${teamId}`] = 0; - - AppDispatcher.handleServerAction({ - type: ActionTypes.RECEIVED_MY_CHANNEL_MEMBERS, - members: data - }); - resolve(); - }, - (err) => { - callTracker[`getMyChannelMembers${teamId}`] = 0; - dispatchError(err, 'getMyChannelMembersForTeam'); - reject(new Error('Unable to getMyChannelMembersForTeam')); - } - ); - }); -} - -export function viewChannel(channelId = ChannelStore.getCurrentId(), prevChannelId = '', time = 0) { - if (channelId == null || !Client.teamId) { - return; - } - - if (isCallInProgress(`viewChannel${channelId}`)) { - return; - } - - callTracker[`viewChannel${channelId}`] = utils.getTimestamp(); - Client.viewChannel( - channelId, - prevChannelId, - time, - () => { - AppDispatcher.handleServerAction({ - type: ActionTypes.RECEIVED_PREFERENCE, - preference: { - category: 'last', - name: TeamStore.getCurrentId(), - value: channelId - } - }); - - callTracker[`viewChannel${channelId}`] = 0; - ErrorStore.clearLastError(); - }, - (err) => { - callTracker[`viewChannel${channelId}`] = 0; - const count = ErrorStore.getConnectionErrorCount(); - ErrorStore.setConnectionErrorCount(count + 1); - dispatchError(err, 'viewChannel'); - } - ); -} - -export function getMoreChannelsPage(offset, limit) { - if (isCallInProgress('getMoreChannelsPage')) { - return; - } - - callTracker.getMoreChannelsPage = utils.getTimestamp(); - Client.getMoreChannelsPage( - offset, - limit, - (data) => { - callTracker.getMoreChannelsPage = 0; - - AppDispatcher.handleServerAction({ - type: ActionTypes.RECEIVED_MORE_CHANNELS, - channels: data - }); - }, - (err) => { - callTracker.getMoreChannelsPage = 0; - dispatchError(err, 'getMoreChannelsPage'); - } - ); -} - -export function getChannelStats(channelId = ChannelStore.getCurrentId(), doVersionCheck = false) { - if (isCallInProgress('getChannelStats' + channelId) || channelId == null) { - return; - } - - callTracker['getChannelStats' + channelId] = utils.getTimestamp(); - - Client.getChannelStats( - channelId, - (data) => { - callTracker['getChannelStats' + channelId] = 0; - - if (doVersionCheck) { - checkVersion(); - } - - AppDispatcher.handleServerAction({ - type: ActionTypes.RECEIVED_CHANNEL_STATS, - stats: data - }); - }, - (err) => { - callTracker['getChannelStats' + channelId] = 0; - dispatchError(err, 'getChannelStats'); - } - ); -} - -export function getChannelMember(channelId, userId) { - return new Promise((resolve, reject) => { - if (isCallInProgress(`getChannelMember${channelId}${userId}`)) { - resolve(); - return; - } - - callTracker[`getChannelMember${channelId}${userId}`] = utils.getTimestamp(); - - Client.getChannelMember( - channelId, - userId, - (data) => { - callTracker[`getChannelMember${channelId}${userId}`] = 0; - - AppDispatcher.handleServerAction({ - type: ActionTypes.RECEIVED_CHANNEL_MEMBER, - member: data - }); - resolve(); - }, - (err) => { - callTracker[`getChannelMember${channelId}${userId}`] = 0; - dispatchError(err, 'getChannelMember'); - reject(new Error('Unable to getChannelMeber')); - } - ); - }); -} - export function getUser(userId, success, error) { const callName = `getUser${userId}`; |