Skip to content

Commit

Permalink
fix: deleted message not show when deleting thread
Browse files Browse the repository at this point in the history
  • Loading branch information
dukenv0307 committed Jul 14, 2023
1 parent 754b6ed commit 147ec31
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/LHNOptionsList/OptionRowLHN.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ function OptionRowLHN(props) {
numberOfLines={1}
accessibilityLabel={props.translate('accessibilityHints.lastChatMessagePreview')}
>
{optionItem.alternateText}
{optionItem.isLastMessageDeletedParentAction ? props.translate('parentReportAction.deletedMessage') : optionItem.alternateText}
</Text>
) : null}
</View>
Expand Down
21 changes: 15 additions & 6 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ function addActions(reportID, text = '', file) {
lastMessageHtml: lastCommentText,
lastActorAccountID: currentUserAccountID,
lastReadTime: currentTime,
isLastMessageDeletedParentAction: null,
};

// Optimistically add the new actions to the store before waiting to save them to the server
Expand Down Expand Up @@ -899,14 +900,22 @@ function deleteReportComment(reportID, reportAction) {
lastMessageText: '',
lastVisibleActionCreated: '',
};
const {lastMessageText = '', lastMessageTranslationKey = ''} = ReportActionsUtils.getLastVisibleMessage(originalReportID, optimisticReportActions);
if (lastMessageText || lastMessageTranslationKey) {
const lastVisibleActionCreated = ReportActionsUtils.getLastVisibleAction(originalReportID, optimisticReportActions).created;
if (reportAction.reportActionID && reportAction.childVisibleActionCount > 0) {
optimisticReport = {
lastMessageTranslationKey,
lastMessageText,
lastVisibleActionCreated,
lastMessageTranslationKey: '',
lastMessageText: '',
isLastMessageDeletedParentAction: true,
};
} else {
const {lastMessageText = '', lastMessageTranslationKey = ''} = ReportActionsUtils.getLastVisibleMessage(originalReportID, optimisticReportActions);
if (lastMessageText || lastMessageTranslationKey) {
const lastVisibleActionCreated = ReportActionsUtils.getLastVisibleAction(originalReportID, optimisticReportActions).created;
optimisticReport = {
lastMessageTranslationKey,
lastMessageText,
lastVisibleActionCreated,
};
}
}

// If the API call fails we must show the original message again, so we revert the message content back to how it was
Expand Down

0 comments on commit 147ec31

Please sign in to comment.