From 8be2090a57030297c15d1c6c4d70dd92ac7e1629 Mon Sep 17 00:00:00 2001 From: tienifr Date: Fri, 17 Nov 2023 16:20:53 +0700 Subject: [PATCH 1/4] fix: app crashes on open notification --- src/libs/actions/Report.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 58d7a9399533..72a96dbfc9fa 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1794,6 +1794,11 @@ function shouldShowReportActionNotification(reportID, action = null, isRemote = // If this notification was delayed and the user saw the message already, don't show it const report = allReports[reportID]; + if (!report || (report && report.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE)) { + Log.info(`${tag} No notification because the report does not exist or is pending deleted`, false); + return false; + } + if (action && report && report.lastReadTime >= action.created) { Log.info(`${tag} No notification because the comment was already read`, false, {created: action.created, lastReadTime: report.lastReadTime}); return false; From 042d6b643545b94d27841533482053858e741b83 Mon Sep 17 00:00:00 2001 From: tienifr Date: Fri, 8 Dec 2023 16:14:06 +0700 Subject: [PATCH 2/4] fix: test --- src/libs/actions/Report.js | 2 +- src/libs/actions/User.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 12a72db88a92..22d2eb2d723b 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1781,13 +1781,13 @@ function shouldShowReportActionNotification(reportID, action = null, isRemote = return false; } - // If this notification was delayed and the user saw the message already, don't show it const report = allReports[reportID]; if (!report || (report && report.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE)) { Log.info(`${tag} No notification because the report does not exist or is pending deleted`, false); return false; } + // If this notification was delayed and the user saw the message already, don't show it if (action && report && report.lastReadTime >= action.created) { Log.info(`${tag} No notification because the comment was already read`, false, {created: action.created, lastReadTime: report.lastReadTime}); return false; diff --git a/src/libs/actions/User.js b/src/libs/actions/User.js index 1bd1cb0b763b..233b319d97d5 100644 --- a/src/libs/actions/User.js +++ b/src/libs/actions/User.js @@ -528,8 +528,10 @@ function subscribeToUserEvents() { return; } - const onyxUpdatePromise = Onyx.update(pushJSON); - triggerNotifications(pushJSON); + const onyxUpdatePromise = Onyx.update(pushJSON).then(()=>{ + triggerNotifications(pushJSON); + }); + // Return a promise when Onyx is done updating so that the OnyxUpdatesManager can properly apply all // the onyx updates in order From 6b7cc70cc2458999b7e3af45a38b47b2447bd553 Mon Sep 17 00:00:00 2001 From: tienifr Date: Fri, 8 Dec 2023 16:17:41 +0700 Subject: [PATCH 3/4] lint fix --- src/libs/actions/User.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/actions/User.js b/src/libs/actions/User.js index 233b319d97d5..1fbdda385a43 100644 --- a/src/libs/actions/User.js +++ b/src/libs/actions/User.js @@ -531,7 +531,6 @@ function subscribeToUserEvents() { const onyxUpdatePromise = Onyx.update(pushJSON).then(()=>{ triggerNotifications(pushJSON); }); - // Return a promise when Onyx is done updating so that the OnyxUpdatesManager can properly apply all // the onyx updates in order From 9a7627a42b54a7de5f27366bdead67f25f3509c5 Mon Sep 17 00:00:00 2001 From: tienifr Date: Fri, 8 Dec 2023 16:25:05 +0700 Subject: [PATCH 4/4] format code --- src/libs/actions/User.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/User.js b/src/libs/actions/User.js index 1fbdda385a43..3aa0e9642cdb 100644 --- a/src/libs/actions/User.js +++ b/src/libs/actions/User.js @@ -528,7 +528,7 @@ function subscribeToUserEvents() { return; } - const onyxUpdatePromise = Onyx.update(pushJSON).then(()=>{ + const onyxUpdatePromise = Onyx.update(pushJSON).then(() => { triggerNotifications(pushJSON); });