mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: dont show chat notif if you are already in the room
mark all notifs from chat read when you you mark the chat room read
This commit is contained in:
@@ -90,6 +90,9 @@ define('notifications', [
|
|||||||
if (ajaxify.currentPage === 'notifications') {
|
if (ajaxify.currentPage === 'notifications') {
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
}
|
}
|
||||||
|
if (ajaxify.data.template.chats && parseInt(ajaxify.data.roomId, 10) === parseInt(notifData.roomId, 10)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
socket.emit('notifications.getCount', function (err, count) {
|
socket.emit('notifications.getCount', function (err, count) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ const db = require('../database');
|
|||||||
const user = require('../user');
|
const user = require('../user');
|
||||||
const meta = require('../meta');
|
const meta = require('../meta');
|
||||||
const messaging = require('../messaging');
|
const messaging = require('../messaging');
|
||||||
|
const notifications = require('../notifications');
|
||||||
const plugins = require('../plugins');
|
const plugins = require('../plugins');
|
||||||
const privileges = require('../privileges');
|
const privileges = require('../privileges');
|
||||||
|
|
||||||
@@ -156,6 +157,9 @@ chatsAPI.mark = async (caller, data) => {
|
|||||||
} else {
|
} else {
|
||||||
await messaging.markRead(caller.uid, roomId);
|
await messaging.markRead(caller.uid, roomId);
|
||||||
socketHelpers.emitToUids('event:chats.markedAsRead', { roomId: roomId }, [caller.uid]);
|
socketHelpers.emitToUids('event:chats.markedAsRead', { roomId: roomId }, [caller.uid]);
|
||||||
|
const nids = await user.notifications.getUnreadByField(caller.uid, 'roomId', [roomId]);
|
||||||
|
await notifications.markReadMultiple(nids, caller.uid);
|
||||||
|
user.notifications.pushCount(caller.uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
socketHelpers.emitToUids('event:chats.mark', { roomId, state }, [caller.uid]);
|
socketHelpers.emitToUids('event:chats.mark', { roomId, state }, [caller.uid]);
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ module.exports = function (Messaging) {
|
|||||||
bodyLong: messageObj.content,
|
bodyLong: messageObj.content,
|
||||||
nid: `chat_${roomId}_${fromUid}`,
|
nid: `chat_${roomId}_${fromUid}`,
|
||||||
from: fromUid,
|
from: fromUid,
|
||||||
|
roomId: roomId,
|
||||||
path: `/chats/${messageObj.roomId}`,
|
path: `/chats/${messageObj.roomId}`,
|
||||||
};
|
};
|
||||||
if (roomData.public) {
|
if (roomData.public) {
|
||||||
|
|||||||
Reference in New Issue
Block a user