diff --git a/web/modals/threads/members/add-members-modal.react.js b/web/modals/threads/members/add-members-modal.react.js --- a/web/modals/threads/members/add-members-modal.react.js +++ b/web/modals/threads/members/add-members-modal.react.js @@ -2,6 +2,10 @@ import * as React from 'react'; +import { + changeThreadSettingsActionTypes, + changeThreadSettings, +} from 'lib/actions/thread-actions'; import { threadInfoSelector } from 'lib/selectors/thread-selectors'; import { userSearchIndexForPotentialMembers, @@ -9,6 +13,10 @@ } from 'lib/selectors/user-selectors'; import { getPotentialMemberItems } from 'lib/shared/search-utils'; import { threadActualMembers } from 'lib/shared/thread-utils'; +import { + useDispatchActionPromise, + useServerCall, +} from 'lib/utils/action-utils'; import Button from '../../../components/button.react'; import { useSelector } from '../../../redux/redux-utils'; @@ -76,6 +84,26 @@ [], ); + const dispatchActionPromise = useDispatchActionPromise(); + const callChangeThreadSettings = useServerCall(changeThreadSettings); + + const addUsers = React.useCallback(() => { + dispatchActionPromise( + changeThreadSettingsActionTypes, + callChangeThreadSettings({ + threadID, + changes: { newMemberIDs: pendingUsersToAdd }, + }), + ); + onClose(); + }, [ + callChangeThreadSettings, + dispatchActionPromise, + onClose, + pendingUsersToAdd, + threadID, + ]); + return (