From b55665258272e0a5ea7088f793b877952a774597 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Thu, 15 Oct 2015 13:00:32 -0400 Subject: [PATCH] fix chat redirect --- public/src/ajaxify.js | 4 +--- public/src/client/chats.js | 2 +- src/controllers/accounts/chats.js | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 2ab64c65e8..bf30ac0521 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -222,9 +222,7 @@ $(document).ready(function() { $(window).trigger('action:ajaxify.dataLoaded', {url: url, data: data}); - if (callback) { - callback(null, data); - } + callback(null, data); }, error: function(data, textStatus) { if (data.status === 0 && textStatus === 'error') { diff --git a/public/src/client/chats.js b/public/src/client/chats.js index 511a81ca15..3d7bd7bda0 100644 --- a/public/src/client/chats.js +++ b/public/src/client/chats.js @@ -140,7 +140,7 @@ define('forum/chats', ['components', 'string', 'sounds', 'forum/infinitescroll', Chats.switchChat = function(uid, username) { if (!$('[component="chat/messages"]').length) { - ajaxify.go('chats/' + username); + return ajaxify.go('chats/' + utils.slugify(username)); } var contactEl = $('.chats-list [data-uid="' + uid + '"]'); diff --git a/src/controllers/accounts/chats.js b/src/controllers/accounts/chats.js index 11f6535d8c..1f95db984b 100644 --- a/src/controllers/accounts/chats.js +++ b/src/controllers/accounts/chats.js @@ -19,7 +19,7 @@ chatsController.get = function(req, res, callback) { // In case a userNAME is passed in instead of a slug, the route should not 404 var slugified = utils.slugify(req.params.userslug); if (req.params.userslug && req.params.userslug !== slugified) { - return res.redirect(nconf.get('relative_path') + '/chats/' + slugified); + return helpers.redirect(res, '/chats/' + slugified); } async.parallel({