Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintain grayed out chats with multiple offline splits #13602

Merged
merged 4 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/libs/ReportActionsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ function getSortedReportActions(reportActions, shouldSortInDescendingOrder = fal
}
const invertedMultiplier = shouldSortInDescendingOrder ? -1 : 1;
reportActions.sort((first, second) => {
// If only one action is a report created action, return the created action first.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already being discussed here #13310 is not a priority for now. So maybe we can just focus on greying out the LHN.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a reportActionID to created report actions to fix a console error where the report action item in the list was missing a key (the reportActionID). As a result of that change the created messages would appear after the IOU message because they have the same created timestamp. Adding this condition fixes that issue and helps with the ordering so I would like to keep the change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB from my end. But I guess we will anyhow need to clean the sort method because reportActions would be random now, right?

if ((first.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED || second.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) && first.actionName !== second.actionName) {
return ((first.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) ? -1 : 1) * invertedMultiplier;
}

if (first.created !== second.created) {
return (first.created < second.created ? -1 : 1) * invertedMultiplier;
}
Expand Down
1 change: 1 addition & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,7 @@ function buildOptimisticCreatedReportAction(ownerEmail) {
return {
0: {
actionName: CONST.REPORT.ACTIONS.TYPE.CREATED,
reportActionID: NumberUtils.rand64(),
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
actorAccountID: currentUserAccountID,
message: [
Expand Down
18 changes: 12 additions & 6 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,13 @@ function createSplitsAndOnyxData(participants, currentUserLogin, amount, comment
groupChatReport.lastReadTimestamp = Date.now();
groupChatReport.lastMessageText = groupIOUReportAction.message[0].text;
groupChatReport.lastMessageHtml = groupIOUReportAction.message[0].html;
groupChatReport.pendingFields = {
createChat: existingGroupChatReport ? null : CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
};

// If we have an existing groupChatReport use it's pending fields, otherwise indicate that we are adding a chat
if (!existingGroupChatReport) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

groupChatReport.pendingFields = {
createChat: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
};
}

const optimisticData = [
{
Expand Down Expand Up @@ -379,9 +383,11 @@ function createSplitsAndOnyxData(participants, currentUserLogin, amount, comment
oneOnOneChatReport.lastReadSequenceNumber = oneOnOneChatReportMaxSequenceNumber + 1;
oneOnOneChatReport.lastMessageText = oneOnOneIOUReportAction.message[0].text;
oneOnOneChatReport.lastMessageHtml = oneOnOneIOUReportAction.message[0].html;
oneOnOneChatReport.pendingFields = {
createChat: existingOneOnOneChatReport ? null : CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
};
if (!existingOneOnOneChatReport) {
oneOnOneChatReport.pendingFields = {
createChat: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
};
}

optimisticData.push(
{
Expand Down