Skip to content
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
3 changes: 3 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2327,6 +2327,9 @@ export default {
memberNotFound: 'Member not found. To invite a new member to the room, please use the Invite button above.',
notAuthorized: `You do not have access to this page. Are you trying to join the room? Please reach out to a member of this room so they can add you as a member! Something else? Reach out to ${CONST.EMAIL.CONCIERGE}`,
removeMembersPrompt: 'Are you sure you want to remove the selected members from the room?',
error: {
genericAdd: 'There was a problem adding this room member.',
},
},
newTaskPage: {
assignTask: 'Assign task',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2358,6 +2358,9 @@ export default {
memberNotFound: 'Miembro no encontrado. Para invitar a un nuevo miembro a la sala de chat, por favor, utiliza el botón Invitar que está más arriba.',
notAuthorized: `No tienes acceso a esta página. ¿Estás tratando de unirte a la sala de chat? Comunícate con el propietario de esta sala de chat para que pueda añadirte como miembro. ¿Necesitas algo más? Comunícate con ${CONST.EMAIL.CONCIERGE}`,
removeMembersPrompt: '¿Estás seguro de que quieres eliminar a los miembros seleccionados de la sala de chat?',
error: {
genericAdd: 'Hubo un problema al añadir este miembro a la sala de chat.',
},
},
newTaskPage: {
assignTask: 'Asignar tarea',
Expand Down
34 changes: 25 additions & 9 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2593,17 +2593,18 @@ function inviteToRoom(reportID: string, inviteeEmailsToAccountIDs: InvitedEmails
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: {
participantAccountIDs: report.participantAccountIDs,
visibleChatMemberAccountIDs: report.visibleChatMemberAccountIDs,
participants: inviteeAccountIDs.reduce((revertedParticipants: Record<number, null>, accountID) => {
// eslint-disable-next-line no-param-reassign
revertedParticipants[accountID] = null;
return revertedParticipants;
}, {}),
pendingChatMembers: report?.pendingChatMembers ?? null,
pendingChatMembers:
pendingChatMembers.map((pendingChatMember) => {
if (!inviteeAccountIDs.includes(Number(pendingChatMember.accountID))) {
return pendingChatMember;
}
return {
...pendingChatMember,
errors: ErrorUtils.getMicroSecondOnyxError('roomMembersPage.error.genericAdd'),
};
}) ?? null,
},
},
...newPersonalDetailsOnyxData.finallyData,
];

if (ReportUtils.isGroupChat(report)) {
Expand All @@ -2626,6 +2627,20 @@ function inviteToRoom(reportID: string, inviteeEmailsToAccountIDs: InvitedEmails
API.write(WRITE_COMMANDS.INVITE_TO_ROOM, parameters, {optimisticData, successData, failureData});
}

function clearAddRoomMemberError(reportID: string, invitedAccountID: string) {
const report = currentReportData?.[reportID];
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {
pendingChatMembers: report?.pendingChatMembers?.filter((pendingChatMember) => pendingChatMember.accountID !== invitedAccountID),
participantAccountIDs: report?.parentReportActionIDs?.filter((parentReportActionID) => parentReportActionID !== Number(invitedAccountID)),
participants: {
[invitedAccountID]: null,
},
});
Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {
[invitedAccountID]: null,
});
}

function updateGroupChatMemberRoles(reportID: string, accountIDList: number[], role: ValueOf<typeof CONST.REPORT.ROLE>) {
const participants: Participants = {};
const memberRoles: Record<number, string> = {};
Expand Down Expand Up @@ -3310,4 +3325,5 @@ export {
leaveGroupChat,
removeFromGroupChat,
updateGroupChatMemberRoles,
clearAddRoomMemberError,
};
10 changes: 10 additions & 0 deletions src/pages/RoomMembersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ function RoomMembersPage({report, session, policies}: RoomMembersPageProps) {
},
],
pendingAction: pendingChatMember?.pendingAction,
errors: pendingChatMember?.errors,
});
});

Expand All @@ -224,6 +225,13 @@ function RoomMembersPage({report, session, policies}: RoomMembersPageProps) {
return result;
};

const dismissError = useCallback(
(item: ListItem) => {
Report.clearAddRoomMemberError(report.reportID, String(item.accountID ?? ''));
},
[report.reportID],
);

const isPolicyEmployee = useMemo(() => {
if (!report?.policyID || policies === null) {
return false;
Expand All @@ -232,6 +240,7 @@ function RoomMembersPage({report, session, policies}: RoomMembersPageProps) {
}, [report?.policyID, policies]);
const data = getMemberOptions();
const headerMessage = searchValue.trim() && !data.length ? translate('roomMembersPage.memberNotFound') : '';

return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
Expand Down Expand Up @@ -300,6 +309,7 @@ function RoomMembersPage({report, session, policies}: RoomMembersPageProps) {
showScrollIndicator
shouldPreventDefaultFocusOnSelectRow={!DeviceCapabilities.canUseTouchScreen()}
ListItem={UserListItem}
onDismissError={dismissError}
/>
</View>
</View>
Expand Down
1 change: 1 addition & 0 deletions src/types/onyx/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Note = OnyxCommon.OnyxValueWithOfflineFeedback<{
type PendingChatMember = {
accountID: string;
pendingAction: OnyxCommon.PendingAction;
errors?: OnyxCommon.Errors;
};

type Participant = {
Expand Down