diff --git a/public/src/app.js b/public/src/app.js index 837764db53..a462e53b6f 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -314,6 +314,18 @@ var socket, }); } + app.openChat = function(username, touid) { + require(['chat'], function(chat) { + var chatModal; + if(!chat.modalExists(touid)) { + chatModal = chat.createModal(username, touid); + } else { + chatModal = chat.getModal(touid); + } + chat.load(chatModal.attr('UUID')); + }); + } + app.createNewPosts = function(data) { data.posts[0].display_moderator_tools = 'none'; var html = templates.prepare(templates['topic'].blocks['posts']).parse(data), diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index 5ff3091bb4..752d703f87 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -288,15 +288,7 @@ if(username === app.username || !app.username) return; - require(['chat'], function(chat) { - var chatModal; - if(!chat.modalExists(touid)) { - chatModal = chat.createModal(username, touid); - } else { - chatModal = chat.getModal(touid); - } - chat.load(chatModal.attr('UUID')); - }); + app.openChat(username, touid); }); ajaxify.register_events([ diff --git a/src/websockets.js b/src/websockets.js index 5bbcd049b4..572843156b 100644 --- a/src/websockets.js +++ b/src/websockets.js @@ -533,7 +533,7 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }), notifText = 'New message from ' + username + ''; if(!isUserOnline(touid)) { - notifications.create(notifText, 5, '#', 'notification_' + uid + '_' + touid, function(nid) { + notifications.create(notifText, 5, 'javascript:app.openChat(''+username+'', '+uid+');', 'notification_' + uid + '_' + touid, function(nid) { notifications.push(nid, [touid], function(success) { });