diff --git a/src/libs/Notification/LocalNotification/BrowserNotifications.js b/src/libs/Notification/LocalNotification/BrowserNotifications.js index 6db3fdb7f50c..e55c0430fe17 100644 --- a/src/libs/Notification/LocalNotification/BrowserNotifications.js +++ b/src/libs/Notification/LocalNotification/BrowserNotifications.js @@ -3,6 +3,7 @@ import _ from 'underscore'; import focusApp from './focusApp'; import * as AppUpdate from '../../actions/AppUpdate'; import EXPENSIFY_ICON_URL from '../../../../assets/images/expensify-logo-round-clearspace.png'; +import * as ReportUtils from '../../ReportUtils'; const DEFAULT_DELAY = 4000; @@ -92,20 +93,35 @@ export default { * Create a report comment notification * * @param {Object} params + * @param {Object} params.report * @param {Object} params.reportAction * @param {Function} params.onClick * @param {Boolean} usesIcon true if notification uses right circular icon */ - pushReportCommentNotification({reportAction, onClick}, usesIcon = false) { + pushReportCommentNotification({report, reportAction, onClick}, usesIcon = false) { + let title; + let body; + + const isChatRoom = ReportUtils.isChatRoom(report); + const {person, message} = reportAction; const plainTextPerson = _.map(person, (f) => f.text).join(); // Specifically target the comment part of the message const plainTextMessage = (_.find(message, (f) => f.type === 'COMMENT') || {}).text; + if (isChatRoom) { + const roomName = _.get(report, 'displayName', ''); + title = roomName; + body = `${plainTextPerson}: ${plainTextMessage}`; + } else { + title = plainTextPerson; + body = plainTextMessage; + } + push({ - title: plainTextPerson, - body: plainTextMessage, + title, + body, delay: 0, onClick, icon: usesIcon ? EXPENSIFY_ICON_URL : '', diff --git a/src/libs/Notification/LocalNotification/index.desktop.js b/src/libs/Notification/LocalNotification/index.desktop.js index 9564b0ef7f26..2bef51cea0a6 100644 --- a/src/libs/Notification/LocalNotification/index.desktop.js +++ b/src/libs/Notification/LocalNotification/index.desktop.js @@ -1,7 +1,7 @@ import BrowserNotifications from './BrowserNotifications'; -function showCommentNotification({reportAction, onClick}) { - BrowserNotifications.pushReportCommentNotification({reportAction, onClick}); +function showCommentNotification({report, reportAction, onClick}) { + BrowserNotifications.pushReportCommentNotification({report, reportAction, onClick}); } function showUpdateAvailableNotification() { diff --git a/src/libs/Notification/LocalNotification/index.website.js b/src/libs/Notification/LocalNotification/index.website.js index 5c94f3360f4c..3410b3144caf 100644 --- a/src/libs/Notification/LocalNotification/index.website.js +++ b/src/libs/Notification/LocalNotification/index.website.js @@ -1,7 +1,7 @@ import BrowserNotifications from './BrowserNotifications'; -function showCommentNotification({reportAction, onClick}) { - BrowserNotifications.pushReportCommentNotification({reportAction, onClick}, true); +function showCommentNotification({report, reportAction, onClick}) { + BrowserNotifications.pushReportCommentNotification({report, reportAction, onClick}, true); } function showUpdateAvailableNotification() { diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 268a052d4a4e..d23cce4f5e0f 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1378,6 +1378,7 @@ function showReportActionNotification(reportID, action) { Log.info('[LocalNotification] Creating notification'); LocalNotification.showCommentNotification({ + report: allReports[reportID], reportAction: action, onClick: () => { // Navigate to this report onClick