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;
|
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.
|
* A handler function that will deselect a user when clicked on.
|
||||||
|
|
@ -42,7 +42,7 @@ type Props = {
|
||||||
onRemove: (id: string) => void;
|
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>;
|
selectedIds: Set<string>;
|
||||||
|
|
||||||
|
|
@ -161,7 +161,7 @@ export default function SelectedUsers({
|
||||||
|
|
||||||
const usersChipsHeight = useSharedValue(0);
|
const usersChipsHeight = useSharedValue(0);
|
||||||
const [isVisible, setIsVisible] = useState(false);
|
const [isVisible, setIsVisible] = useState(false);
|
||||||
const numberSelectedIds = Object.keys(selectedIds).length;
|
const numberSelectedIds = selectedIds.size;
|
||||||
|
|
||||||
const users = useMemo(() => {
|
const users = useMemo(() => {
|
||||||
const u = [];
|
const u = [];
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ export default function ChannelAddMembers({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const idsToUse = Object.keys(selectedIds);
|
const idsToUse = Array.from(selectedIds);
|
||||||
if (!idsToUse.length) {
|
if (!idsToUse.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -152,14 +152,14 @@ export default function CreateDirectMessage({
|
||||||
return !result.error;
|
return !result.error;
|
||||||
}, [intl, serverUrl]);
|
}, [intl, serverUrl]);
|
||||||
|
|
||||||
const startConversation = useCallback(async (selectedId?: {[id: string]: boolean}) => {
|
const startConversation = useCallback(async (selectedId?: string) => {
|
||||||
if (startingConversation) {
|
if (startingConversation) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setStartingConversation(true);
|
setStartingConversation(true);
|
||||||
|
|
||||||
const idsToUse = selectedId ? Object.keys(selectedId) : Object.keys(selectedIds);
|
const idsToUse = selectedId ? [selectedId] : Array.from(selectedIds);
|
||||||
let success;
|
let success;
|
||||||
if (idsToUse.length === 0) {
|
if (idsToUse.length === 0) {
|
||||||
success = false;
|
success = false;
|
||||||
|
|
@ -178,11 +178,7 @@ export default function CreateDirectMessage({
|
||||||
|
|
||||||
const handleSelectProfile = useCallback((user: UserProfile) => {
|
const handleSelectProfile = useCallback((user: UserProfile) => {
|
||||||
if (user.id === currentUserId) {
|
if (user.id === currentUserId) {
|
||||||
const selectedId = {
|
startConversation(currentUserId);
|
||||||
[currentUserId]: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
startConversation(selectedId);
|
|
||||||
} else {
|
} else {
|
||||||
clearSearch();
|
clearSearch();
|
||||||
setSelectedIds((current) => {
|
setSelectedIds((current) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue