Skip to content

Commit

Permalink
Merge pull request #17450 from tienifr/fix/17164-app-crashes-on-delet…
Browse files Browse the repository at this point in the history
…ing-message-in-offline-mode

Fix: App crashes on message deletion in empty chat in Offline mode
  • Loading branch information
techievivek authored Apr 19, 2023
2 parents fedef5f + 41f9878 commit c144663
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/libs/ReportActionsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ function isConsecutiveActionMadeByPreviousActor(reportActions, actionIndex) {
function getLastVisibleAction(reportID, actionsToMerge = {}) {
const actions = _.toArray(lodashMerge({}, allReportActions[reportID], actionsToMerge));
const visibleActions = _.filter(actions, action => (!isDeletedAction(action)));

if (_.isEmpty(visibleActions)) {
return {};
}

return _.max(visibleActions, action => moment.utc(action.created).valueOf());
}

Expand All @@ -144,7 +149,8 @@ function getLastVisibleAction(reportID, actionsToMerge = {}) {
*/
function getLastVisibleMessageText(reportID, actionsToMerge = {}) {
const lastVisibleAction = getLastVisibleAction(reportID, actionsToMerge);
const message = lodashGet(lastVisibleAction, ['message', 0]);
const message = lodashGet(lastVisibleAction, ['message', 0], {});

if (isReportMessageAttachment(message)) {
return CONST.ATTACHMENT_MESSAGE_TEXT;
}
Expand Down

0 comments on commit c144663

Please sign in to comment.