From 2b80620cee554560ef5f6eb078c2c5f5d0532326 Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Fri, 14 Aug 2015 17:12:02 -0700 Subject: Private message channels no longer refresh on creation/first use --- web/react/utils/client.jsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'web/react/utils') diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx index ce044457a..1b9ad942e 100644 --- a/web/react/utils/client.jsx +++ b/web/react/utils/client.jsx @@ -438,6 +438,23 @@ module.exports.createChannel = function(channel, success, error) { module.exports.track('api', 'api_channels_create', channel.type, 'name', channel.name); }; +module.exports.createPMChannelIfNotExists = function(channel, userId, success, error) { + $.ajax({ + url: '/api/v1/channels/create_direct', + dataType: 'json', + contentType: 'application/json', + type: 'POST', + data: JSON.stringify({user_id: userId}), + success: success, + error: function(xhr, status, err) { + var e = handleError('createPMIfNotExists', xhr, status, err); + error(e); + } + }); + + module.exports.track('api', 'api_channels_create_direct', channel.type, 'name', channel.name); +}; + module.exports.updateChannel = function(channel, success, error) { $.ajax({ url: "/api/v1/channels/update", -- cgit v1.2.3-1-g7c22 From f2b06cfc7c847f687582b1855959fdd885e3fac8 Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Fri, 14 Aug 2015 18:26:09 -0700 Subject: Added feature to the 'More...' PM channel list and fixed small cosmetic issues --- web/react/utils/client.jsx | 4 ++-- web/react/utils/utils.jsx | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'web/react/utils') diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx index 1b9ad942e..da0b74081 100644 --- a/web/react/utils/client.jsx +++ b/web/react/utils/client.jsx @@ -438,7 +438,7 @@ module.exports.createChannel = function(channel, success, error) { module.exports.track('api', 'api_channels_create', channel.type, 'name', channel.name); }; -module.exports.createPMChannelIfNotExists = function(channel, userId, success, error) { +module.exports.createDirectChannel = function(channel, userId, success, error) { $.ajax({ url: '/api/v1/channels/create_direct', dataType: 'json', @@ -447,7 +447,7 @@ module.exports.createPMChannelIfNotExists = function(channel, userId, success, e data: JSON.stringify({user_id: userId}), success: success, error: function(xhr, status, err) { - var e = handleError('createPMIfNotExists', xhr, status, err); + var e = handleError('createDirectChannel', xhr, status, err); error(e); } }); diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index 32793809d..f1fd3da67 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -964,4 +964,17 @@ module.exports.generateId = function() { module.exports.isBrowserFirefox = function() { return navigator && navigator.userAgent && navigator.userAgent.toLowerCase().indexOf('firefox') > -1; -} +}; + +// Used to get the id of the other user from a DM channel +module.exports.getUserIdFromChannelName = function(channel) { + var ids = channel.name.split('__'); + var otherUserId = ''; + if (ids[0] === UserStore.getCurrentId()) { + otherUserId = ids[1]; + } else { + otherUserId = ids[0]; + } + + return otherUserId; +}; -- cgit v1.2.3-1-g7c22