From da8d198676e7ad0ed6d12f25f086180933918e0e Mon Sep 17 00:00:00 2001 From: psychobunny Date: Thu, 21 Nov 2013 17:00:20 -0500 Subject: [PATCH] added some user friendly warnings to chat --- public/src/app.js | 22 ++++++++++++++++++++++ public/src/forum/topic.js | 3 --- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/public/src/app.js b/public/src/app.js index 5b0f7a4c48..9b72751aa3 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -331,6 +331,28 @@ var socket, } app.openChat = function (username, touid) { + if (username === app.username) { + app.alert({ + type: 'warning', + title: 'Invalid Chat', + message: "You can't chat with yourself!", + timeout: 5000 + }); + + return; + } + + if (!app.username) { + app.alert({ + type: 'danger', + title: 'Not Logged In', + message: 'Please log in to chat with ' + username + '', + timeout: 5000 + }); + + return; + } + require(['chat'], function (chat) { var chatModal; if (!chat.modalExists(touid)) { diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index f0133be07c..fde5f56f19 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -362,9 +362,6 @@ define(function() { var username = $(this).parents('li.row').attr('data-username'); var touid = $(this).parents('li.row').attr('data-uid'); - if (username === app.username || !app.username) - return; - app.openChat(username, touid); });