Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3367853
D4462.id14929.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D4462.id14929.diff
View Options
diff --git a/web/chat/chat-thread-composer.react.js b/web/chat/chat-thread-composer.react.js
--- a/web/chat/chat-thread-composer.react.js
+++ b/web/chat/chat-thread-composer.react.js
@@ -1,6 +1,7 @@
// @flow
import classNames from 'classnames';
import * as React from 'react';
+import { useDispatch } from 'react-redux';
import { userSearchIndexForPotentialMembers } from 'lib/selectors/user-selectors';
import { getPotentialMemberItems } from 'lib/shared/search-utils';
@@ -11,6 +12,7 @@
import type { InputState } from '../input/input-state';
import { useSelector } from '../redux/redux-utils';
import SWMansionIcon from '../SWMansionIcon.react';
+import { updateNavInfoActionType } from '../types/nav-types';
import css from './chat-thread-composer.css';
type Props = {
@@ -21,10 +23,11 @@
};
function ChatThreadComposer(props: Props): React.Node {
- const { userInfoInputArray, otherUserInfos } = props;
+ const { userInfoInputArray, otherUserInfos, threadID } = props;
const [usernameInputText, setUsernameInputText] = React.useState('');
+ const dispatch = useDispatch();
const userSearchIndex = useSelector(userSearchIndexForPotentialMembers);
const userInfoInputIDs = React.useMemo(
@@ -43,10 +46,35 @@
[usernameInputText, otherUserInfos, userSearchIndex, userInfoInputIDs],
);
- // eslint-disable-next-line no-unused-vars
- const onSelectUserFromSearch = React.useCallback((id: string) => {}, []);
- // eslint-disable-next-line no-unused-vars
- const onRemoveUserFromSelected = React.useCallback((id: string) => {}, []);
+ const onSelectUserFromSearch = React.useCallback(
+ (id: string) => {
+ const selectedUserIDs = userInfoInputArray.map(user => user.id);
+ dispatch({
+ type: updateNavInfoActionType,
+ payload: {
+ selectedUserList: [...selectedUserIDs, id],
+ },
+ });
+ setUsernameInputText('');
+ },
+ [dispatch, userInfoInputArray],
+ );
+
+ const onRemoveUserFromSelected = React.useCallback(
+ (id: string) => {
+ const selectedUserIDs = userInfoInputArray.map(user => user.id);
+ if (!selectedUserIDs.includes(id)) {
+ return;
+ }
+ dispatch({
+ type: updateNavInfoActionType,
+ payload: {
+ selectedUserList: selectedUserIDs.filter(userID => userID !== id),
+ },
+ });
+ },
+ [dispatch, userInfoInputArray],
+ );
const userSearchResultList = React.useMemo(() => {
if (
@@ -77,7 +105,15 @@
usernameInputText,
]);
- const hideSearch = React.useCallback(() => {}, []);
+ const hideSearch = React.useCallback(() => {
+ dispatch({
+ type: updateNavInfoActionType,
+ payload: {
+ chatMode: 'view',
+ activeChatThreadID: threadID,
+ },
+ });
+ }, [dispatch, threadID]);
const tagsList = React.useMemo(() => {
if (!userInfoInputArray?.length) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 4:44 PM (20 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2585510
Default Alt Text
D4462.id14929.diff (2 KB)
Attached To
Mode
D4462: [web] Implement callbacks modifying navigation from `ChatThreadComposer`
Attached
Detach File
Event Timeline
Log In to Comment