Skip to content

Node.js based forum software built for the modern web

added some user friendly warnings to chat

psychobunnyda8d198676e7
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 <strong>' + username + '</strong>',
+ 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);
});