Skip to content

Commit 12f6038

Browse files
Fix selected users not showing in add member screen (#9183) (#9186)
* Fix selected users not showing in add member screen * Fix other instances where the set was still treated as an object (cherry picked from commit 240f7c5) Co-authored-by: Daniel Espino García <[email protected]>
1 parent 33dcdc0 commit 12f6038

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

app/components/selected_users/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ type Props = {
3232
keyboardOverlap?: number;
3333

3434
/**
35-
* A handler function that will select or deselect a user when clicked on.
35+
* A handler function that will trigger when the button is pressed.
3636
*/
37-
onPress: (selectedId?: {[id: string]: boolean}) => void;
37+
onPress: () => void;
3838

3939
/**
4040
* A handler function that will deselect a user when clicked on.
4141
*/
4242
onRemove: (id: string) => void;
4343

4444
/**
45-
* An object mapping user ids to a falsey value indicating whether or not they have been selected.
45+
* A set of the selected user ids.
4646
*/
4747
selectedIds: Set<string>;
4848

@@ -161,7 +161,7 @@ export default function SelectedUsers({
161161

162162
const usersChipsHeight = useSharedValue(0);
163163
const [isVisible, setIsVisible] = useState(false);
164-
const numberSelectedIds = Object.keys(selectedIds).length;
164+
const numberSelectedIds = selectedIds.size;
165165

166166
const users = useMemo(() => {
167167
const u = [];

app/screens/channel_add_members/channel_add_members.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export default function ChannelAddMembers({
163163
return;
164164
}
165165

166-
const idsToUse = Object.keys(selectedIds);
166+
const idsToUse = Array.from(selectedIds);
167167
if (!idsToUse.length) {
168168
return;
169169
}

app/screens/create_direct_message/create_direct_message.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ export default function CreateDirectMessage({
152152
return !result.error;
153153
}, [intl, serverUrl]);
154154

155-
const startConversation = useCallback(async (selectedId?: {[id: string]: boolean}) => {
155+
const startConversation = useCallback(async (selectedId?: string) => {
156156
if (startingConversation) {
157157
return;
158158
}
159159

160160
setStartingConversation(true);
161161

162-
const idsToUse = selectedId ? Object.keys(selectedId) : Object.keys(selectedIds);
162+
const idsToUse = selectedId ? [selectedId] : Array.from(selectedIds);
163163
let success;
164164
if (idsToUse.length === 0) {
165165
success = false;
@@ -178,11 +178,7 @@ export default function CreateDirectMessage({
178178

179179
const handleSelectProfile = useCallback((user: UserProfile) => {
180180
if (user.id === currentUserId) {
181-
const selectedId = {
182-
[currentUserId]: true,
183-
};
184-
185-
startConversation(selectedId);
181+
startConversation(currentUserId);
186182
} else {
187183
clearSearch();
188184
setSelectedIds((current) => {

0 commit comments

Comments
 (0)