diff --git a/web/settings/relationship/add-users-list-modal.react.js b/web/settings/relationship/add-users-list-modal.react.js --- a/web/settings/relationship/add-users-list-modal.react.js +++ b/web/settings/relationship/add-users-list-modal.react.js @@ -12,6 +12,7 @@ UserRelationshipStatus, RelationshipAction, } from 'lib/types/relationship-types.js'; +import type { GlobalAccountUserInfo } from 'lib/types/user-types.js'; import { useLegacyAshoatKeyserverCall } from 'lib/utils/action-utils.js'; import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js'; @@ -47,8 +48,8 @@ const { popModal } = useModalContext(); const [pendingUsersToAdd, setPendingUsersToAdd] = React.useState< - $ReadOnlySet, - >(new Set()); + $ReadOnlyMap, + >(new Map()); const [errorMessage, setErrorMessage] = React.useState(''); @@ -75,7 +76,7 @@ setErrorMessage(''); const result = await callUpdateRelationships({ action: relationshipAction, - userIDs: Array.from(pendingUsersToAdd), + userIDs: Array.from(pendingUsersToAdd.keys()), }); popModal(); return result; diff --git a/web/settings/relationship/add-users-list.react.js b/web/settings/relationship/add-users-list.react.js --- a/web/settings/relationship/add-users-list.react.js +++ b/web/settings/relationship/add-users-list.react.js @@ -21,8 +21,8 @@ type Props = { +searchText: string, +excludedStatuses?: $ReadOnlySet, - +pendingUsersToAdd: $ReadOnlySet, - +setPendingUsersToAdd: SetState<$ReadOnlySet>, + +pendingUsersToAdd: $ReadOnlyMap, + +setPendingUsersToAdd: SetState<$ReadOnlyMap>, +errorMessage: string, }; @@ -95,16 +95,22 @@ const toggleUser = React.useCallback( (userID: string) => { setPendingUsersToAdd(pendingUsers => { - const newPendingUsers = new Set(pendingUsers); + const newPendingUsers = new Map(pendingUsers); if (!newPendingUsers.delete(userID)) { - newPendingUsers.add(userID); + const newPendingUser: GlobalAccountUserInfo = { + id: userID, + username: mergedUserInfos[userID].username, + avatar: mergedUserInfos[userID].avatar, + }; + + newPendingUsers.set(userID, newPendingUser); } return newPendingUsers; }); }, - [setPendingUsersToAdd], + [mergedUserInfos, setPendingUsersToAdd], ); const sortedUsersWithENSNames = useENSNames(sortedUsers); @@ -123,7 +129,7 @@ ); const onClickClearAll = React.useCallback(() => { - setPendingUsersToAdd(new Set()); + setPendingUsersToAdd(new Map()); }, [setPendingUsersToAdd]); const clearAllButtonColor = React.useMemo(() => {