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

Fix pending delete room members are not strikethrough-ed #39231

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
22 changes: 11 additions & 11 deletions src/components/OptionRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ function OptionRow({
}

return (
<OfflineWithFeedback
pendingAction={option.pendingAction}
errors={option.allReportErrors}
shouldShowErrorMessages={false}
needsOffscreenAlphaCompositing
>
<Hoverable>
{(hovered) => (
<Hoverable>
{(hovered) => (
<OfflineWithFeedback
pendingAction={option.pendingAction}
errors={option.allReportErrors}
shouldShowErrorMessages={false}
needsOffscreenAlphaCompositing
>
<PressableWithFeedback
nativeID={keyForList}
ref={pressableRef}
Expand Down Expand Up @@ -314,9 +314,9 @@ function OptionRow({
</View>
)}
</PressableWithFeedback>
)}
</Hoverable>
</OfflineWithFeedback>
</OfflineWithFeedback>
)}
</Hoverable>
);
}

Expand Down
5 changes: 0 additions & 5 deletions src/libs/actions/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -780,15 +780,12 @@ function removeOptimisticAnnounceRoomMembers(policyID: string, accountIDs: numbe
}

if (announceReport?.participantAccountIDs) {
const remainUsers = announceReport.participantAccountIDs.filter((e) => !accountIDs.includes(e));
const pendingChatMembers = ReportUtils.getPendingChatMembers(accountIDs, announceReport?.pendingChatMembers ?? [], CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE);

announceRoomMembers.onyxOptimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${announceReport.reportID}`,
value: {
participantAccountIDs: [...remainUsers],
visibleChatMemberAccountIDs: [...remainUsers],
pendingChatMembers,
},
});
Expand All @@ -797,8 +794,6 @@ function removeOptimisticAnnounceRoomMembers(policyID: string, accountIDs: numbe
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${announceReport.reportID}`,
value: {
participantAccountIDs: announceReport.participantAccountIDs,
visibleChatMemberAccountIDs: announceReport.visibleChatMemberAccountIDs,
pendingChatMembers: announceReport?.pendingChatMembers ?? null,
},
});
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ReportParticipantsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const getAllParticipants = (
!!userPersonalDetail?.login && !CONST.RESTRICTED_ACCOUNT_IDS.includes(accountID) ? LocalePhoneNumber.formatPhoneNumber(userPersonalDetail.login) : translate('common.hidden');
const displayName = PersonalDetailsUtils.getDisplayNameOrDefault(userPersonalDetail);

const pendingChatMember = report?.pendingChatMembers?.find((member) => member.accountID === accountID.toString());
const pendingChatMember = report?.pendingChatMembers?.findLast((member) => member.accountID === accountID.toString());
return {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, I applied the fix to the report participants page too, but when I tested it, I found out that removing a WS member removes the user completely from the report participants, so we can't see it getting strikethrough. (see video below).

Screen.Recording.2024-03-29.at.18.28.35.mov

This is the same issue as #31764, just on a different page. (they fix for room members, but not for announce report participants)

We can fix this with the same solution by removing this optimistic code that removes the user from the list. Do we want to do it here? Or should #31764 handle it as part of the issue?

const remainUsers = announceReport.participantAccountIDs.filter((e) => !accountIDs.includes(e));

announceRoomMembers.onyxOptimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${announceReport.reportID}`,
value: {
participantAccountIDs: [...remainUsers],
visibleChatMemberAccountIDs: [...remainUsers],
pendingChatMembers,

@francoisl @mollfpr

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, would be great to do it here in this PR if you can. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.
image

I also need to update OptionRow because OfflineWithFeedback strikethrough can't work if the child is a function. So, 2 bug is fixed.

alternateText: userLogin,
pendingAction: pendingChatMember?.pendingAction,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/RoomMembersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function RoomMembersPage({report, session, policies}: RoomMembersPageProps) {
return;
}
}
const pendingChatMember = report?.pendingChatMembers?.find((member) => member.accountID === accountID.toString());
const pendingChatMember = report?.pendingChatMembers?.findLast((member) => member.accountID === accountID.toString());

result.push({
keyForList: String(accountID),
Expand Down
Loading