summaryrefslogtreecommitdiffstats
path: root/webapp/utils
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-11-14 07:09:41 -0500
committerChristopher Speller <crspeller@gmail.com>2016-11-14 07:09:41 -0500
commit323ce8b203c570ed6a1dd57b44d6637ad8207616 (patch)
treeefc3c61b905244bdb0e1ace0ce9f5ae4876644ad /webapp/utils
parentd1207d34c1d99eba9ebf85c98d267ee7e955ea7d (diff)
parentb55ec6148caa93d54b660afe55408c643d217108 (diff)
downloadchat-323ce8b203c570ed6a1dd57b44d6637ad8207616.tar.gz
chat-323ce8b203c570ed6a1dd57b44d6637ad8207616.tar.bz2
chat-323ce8b203c570ed6a1dd57b44d6637ad8207616.zip
Merge branch 'release-3.5'
Diffstat (limited to 'webapp/utils')
-rw-r--r--webapp/utils/async_client.jsx82
-rw-r--r--webapp/utils/constants.jsx1
-rw-r--r--webapp/utils/utils.jsx10
3 files changed, 56 insertions, 37 deletions
diff --git a/webapp/utils/async_client.jsx b/webapp/utils/async_client.jsx
index 1149c565f..efa9eeb2b 100644
--- a/webapp/utils/async_client.jsx
+++ b/webapp/utils/async_client.jsx
@@ -111,26 +111,31 @@ export function getChannel(id) {
}
export function getMyChannelMembers() {
- if (isCallInProgress('getMyChannelMembers')) {
- return;
- }
+ return new Promise((resolve, reject) => {
+ if (isCallInProgress('getMyChannelMembers')) {
+ resolve();
+ return;
+ }
- callTracker.getMyChannelMembers = utils.getTimestamp();
+ callTracker.getMyChannelMembers = utils.getTimestamp();
- Client.getMyChannelMembers(
- (data) => {
- callTracker.getMyChannelMembers = 0;
+ Client.getMyChannelMembers(
+ (data) => {
+ callTracker.getMyChannelMembers = 0;
- AppDispatcher.handleServerAction({
- type: ActionTypes.RECEIVED_MY_CHANNEL_MEMBERS,
- members: data
- });
- },
- (err) => {
- callTracker.getChannelsUnread = 0;
- dispatchError(err, 'getMyChannelMembers');
- }
- );
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_MY_CHANNEL_MEMBERS,
+ members: data
+ });
+ resolve();
+ },
+ (err) => {
+ callTracker.getChannelsUnread = 0;
+ dispatchError(err, 'getMyChannelMembers');
+ reject();
+ }
+ );
+ });
}
export function updateLastViewedAt(id, active) {
@@ -263,28 +268,33 @@ export function getChannelStats(channelId = ChannelStore.getCurrentId(), doVersi
}
export function getChannelMember(channelId, userId) {
- if (isCallInProgress(`getChannelMember${channelId}${userId}`)) {
- return;
- }
+ return new Promise((resolve, reject) => {
+ if (isCallInProgress(`getChannelMember${channelId}${userId}`)) {
+ resolve();
+ return;
+ }
- callTracker[`getChannelMember${channelId}${userId}`] = utils.getTimestamp();
+ callTracker[`getChannelMember${channelId}${userId}`] = utils.getTimestamp();
- Client.getChannelMember(
- channelId,
- userId,
- (data) => {
- callTracker[`getChannelMember${channelId}${userId}`] = 0;
+ Client.getChannelMember(
+ channelId,
+ userId,
+ (data) => {
+ callTracker[`getChannelMember${channelId}${userId}`] = 0;
- AppDispatcher.handleServerAction({
- type: ActionTypes.RECEIVED_CHANNEL_MEMBER,
- member: data
- });
- },
- (err) => {
- callTracker[`getChannelMember${channelId}${userId}`] = 0;
- dispatchError(err, 'getChannelMember');
- }
- );
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_CHANNEL_MEMBER,
+ member: data
+ });
+ resolve();
+ },
+ (err) => {
+ callTracker[`getChannelMember${channelId}${userId}`] = 0;
+ dispatchError(err, 'getChannelMember');
+ reject();
+ }
+ );
+ });
}
export function getUser(userId) {
diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx
index 29f4ea64e..d8965516e 100644
--- a/webapp/utils/constants.jsx
+++ b/webapp/utils/constants.jsx
@@ -70,6 +70,7 @@ export const ActionTypes = keyMirror({
RECEIVED_CHANNELS: null,
RECEIVED_CHANNEL: null,
+ RECEIVED_CHANNEL_MEMBER: null,
RECEIVED_MORE_CHANNELS: null,
RECEIVED_CHANNEL_STATS: null,
RECEIVED_MY_CHANNEL_MEMBERS: null,
diff --git a/webapp/utils/utils.jsx b/webapp/utils/utils.jsx
index 5d456bf83..d2ea25f22 100644
--- a/webapp/utils/utils.jsx
+++ b/webapp/utils/utils.jsx
@@ -1270,7 +1270,15 @@ export function isValidPassword(password) {
}
export function getSiteURL() {
- return global.mm_config.SiteURL || window.location.origin;
+ if (global.mm_config.SiteURL) {
+ return global.mm_config.SiteURL;
+ }
+
+ if (window.location.origin) {
+ return window.location.origin;
+ }
+
+ return window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
}
export function handleFormattedTextClick(e) {