Fix selected users not showing in add member screen (#9183)
* Fix selected users not showing in add member screen * Fix other instances where the set was still treated as an object
This commit is contained in:
parent
1f9fc9bda7
commit
240f7c5aab
3 changed files with 8 additions and 12 deletions
|
|
@ -32,9 +32,9 @@ type Props = {
|
|||
keyboardOverlap?: number;
|
||||
|
||||
/**
|
||||
* A handler function that will select or deselect a user when clicked on.
|
||||
* A handler function that will trigger when the button is pressed.
|
||||
*/
|
||||
onPress: (selectedId?: {[id: string]: boolean}) => void;
|
||||
onPress: () => void;
|
||||
|
||||
/**
|
||||
* A handler function that will deselect a user when clicked on.
|
||||
|
|
@ -42,7 +42,7 @@ type Props = {
|
|||
onRemove: (id: string) => void;
|
||||
|
||||
/**
|
||||
* An object mapping user ids to a falsey value indicating whether or not they have been selected.
|
||||
* A set of the selected user ids.
|
||||
*/
|
||||
selectedIds: Set<string>;
|
||||
|
||||
|
|
@ -161,7 +161,7 @@ export default function SelectedUsers({
|
|||
|
||||
const usersChipsHeight = useSharedValue(0);
|
||||
const [isVisible, setIsVisible] = useState(false);
|
||||
const numberSelectedIds = Object.keys(selectedIds).length;
|
||||
const numberSelectedIds = selectedIds.size;
|
||||
|
||||
const users = useMemo(() => {
|
||||
const u = [];
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ export default function ChannelAddMembers({
|
|||
return;
|
||||
}
|
||||
|
||||
const idsToUse = Object.keys(selectedIds);
|
||||
const idsToUse = Array.from(selectedIds);
|
||||
if (!idsToUse.length) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,14 +152,14 @@ export default function CreateDirectMessage({
|
|||
return !result.error;
|
||||
}, [intl, serverUrl]);
|
||||
|
||||
const startConversation = useCallback(async (selectedId?: {[id: string]: boolean}) => {
|
||||
const startConversation = useCallback(async (selectedId?: string) => {
|
||||
if (startingConversation) {
|
||||
return;
|
||||
}
|
||||
|
||||
setStartingConversation(true);
|
||||
|
||||
const idsToUse = selectedId ? Object.keys(selectedId) : Object.keys(selectedIds);
|
||||
const idsToUse = selectedId ? [selectedId] : Array.from(selectedIds);
|
||||
let success;
|
||||
if (idsToUse.length === 0) {
|
||||
success = false;
|
||||
|
|
@ -178,11 +178,7 @@ export default function CreateDirectMessage({
|
|||
|
||||
const handleSelectProfile = useCallback((user: UserProfile) => {
|
||||
if (user.id === currentUserId) {
|
||||
const selectedId = {
|
||||
[currentUserId]: true,
|
||||
};
|
||||
|
||||
startConversation(selectedId);
|
||||
startConversation(currentUserId);
|
||||
} else {
|
||||
clearSearch();
|
||||
setSelectedIds((current) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue