From c692f7e8fe88ee782f8e81a2f16f0926568548b6 Mon Sep 17 00:00:00 2001
From: psychobunny <psycho.bunny@hotmail.com>
Date: Thu, 25 Sep 2014 10:28:09 -0400
Subject: [PATCH] closes #2148

---
 public/src/forum/chats.js | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/public/src/forum/chats.js b/public/src/forum/chats.js
index 84bf4fd4cc..aa1af729b3 100644
--- a/public/src/forum/chats.js
+++ b/public/src/forum/chats.js
@@ -66,9 +66,14 @@ define('forum/chats', ['string', 'sounds', 'forum/infinitescroll'], function(S,
 		popoutEl.on('click', function() {
 			var	username = $('.expanded-chat').attr('data-username'),
 				uid = Chats.getRecipientUid();
-			ajaxify.go('chats', function() {
-				app.openChat(username, uid);
-			}, true);
+
+			if (app.previousUrl && app.previousUrl.match(/chats/)) {
+				ajaxify.go('chats', function() {
+					app.openChat(username, uid);
+				}, true);
+			} else {
+				window.history.go(-1);
+			}
 		});
 
 		$('.recent-chats').on('scroll', function() {