diff --git a/web/redux/actions/notification-actions.js b/web/redux/actions/notification-actions.js index 6af9480..c0a57b0 100644 --- a/web/redux/actions/notification-actions.js +++ b/web/redux/actions/notification-actions.js @@ -40,6 +40,8 @@ export function handleSendNotification(title, body, roomName) { export function handleMessageUserMentionNotification(message) { return (dispatch, getStore) => { + const store = getStore(); + // Prop validation if (!message.message.mentionedUsernames || !message.message.mentionedUsernames.length) { return null; @@ -49,7 +51,7 @@ export function handleMessageUserMentionNotification(message) { return null; } - const authUsername = getStore().getIn(['authUser', 'username'], '').toLowerCase(); + const authUsername = store.getIn(['authUser', 'username'], '').toLowerCase(); if (message.user.username.toLowerCase() === authUsername) { return null; } @@ -73,6 +75,11 @@ export function handleNewMessageNotification(message) { return null; } + const lastSeenRoomTime = store.getIn(['lastSeenTimes', message.room.name]); + if (message.message.createDateLongUTC < lastSeenRoomTime) { + return null; + } + dispatch(handleMessageUserMentionNotification(message)); }; }