Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32188171
D5518.1765087855.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D5518.1765087855.diff
View Options
diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js
--- a/lib/shared/thread-utils.js
+++ b/lib/shared/thread-utils.js
@@ -1177,7 +1177,7 @@
+searching: boolean,
+userInfoInputArray: $ReadOnlyArray<AccountUserInfo>,
};
-type ExistingThreadInfoFinder = (
+export type ExistingThreadInfoFinder = (
params: ExistingThreadInfoFinderParams,
) => ?ThreadInfo;
function useExistingThreadInfoFinder(
diff --git a/web/chat/chat-message-list-container.react.js b/web/chat/chat-message-list-container.react.js
--- a/web/chat/chat-message-list-container.react.js
+++ b/web/chat/chat-message-list-container.react.js
@@ -229,6 +229,9 @@
<ChatThreadComposer
userInfoInputArray={userInfoInputArray}
setUserInfoInputArray={setUserInfoInputArray}
+ existingThreadInfoFinderForCreatingThread={
+ existingThreadInfoFinderForCreatingThread
+ }
otherUserInfos={otherUserInfos}
threadID={threadInfo.id}
inputState={inputState}
@@ -246,6 +249,7 @@
</>
);
}, [
+ existingThreadInfoFinderForCreatingThread,
inputState,
isChatCreation,
otherUserInfos,
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
@@ -4,6 +4,7 @@
import { useDispatch } from 'react-redux';
import { searchUsers } from 'lib/actions/user-actions.js';
+import { useModalContext } from 'lib/components/modal-provider.react.js';
import SWMansionIcon from 'lib/components/SWMansionIcon.react.js';
import { useENSNames } from 'lib/hooks/ens-cache.js';
import {
@@ -11,8 +12,12 @@
userSearchIndexForPotentialMembers,
searchIndexFromUserInfos,
} from 'lib/selectors/user-selectors.js';
-import { getPotentialMemberItems } from 'lib/shared/search-utils.js';
+import {
+ getPotentialMemberItems,
+ notFriendNotice,
+} from 'lib/shared/search-utils.js';
import { threadIsPending } from 'lib/shared/thread-utils.js';
+import type { ExistingThreadInfoFinder } from 'lib/shared/thread-utils.js';
import type { SetState } from 'lib/types/hook-types.js';
import type {
AccountUserInfo,
@@ -26,12 +31,14 @@
import Label from '../components/label.react.js';
import Search from '../components/search.react.js';
import type { InputState } from '../input/input-state.js';
+import Alert from '../modals/alert.react.js';
import { updateNavInfoActionType } from '../redux/action-types.js';
import { useSelector } from '../redux/redux-utils.js';
type Props = {
+userInfoInputArray: $ReadOnlyArray<AccountUserInfo>,
+setUserInfoInputArray: SetState<$ReadOnlyArray<AccountUserInfo>>,
+ +existingThreadInfoFinderForCreatingThread: ExistingThreadInfoFinder,
+otherUserInfos: { [id: string]: AccountUserInfo },
+threadID: string,
+inputState: InputState,
@@ -45,6 +52,7 @@
const {
userInfoInputArray,
setUserInfoInputArray,
+ existingThreadInfoFinderForCreatingThread,
otherUserInfos,
threadID,
inputState,
@@ -116,15 +124,49 @@
);
const userListItemsWithENSNames = useENSNames(userListItems);
+ const dispatch = useDispatch();
+ const { pushModal } = useModalContext();
const onSelectUserFromSearch = React.useCallback(
- (id: string, username: string) => {
- setUserInfoInputArray(previousUserInfoInputArray => [
- ...previousUserInfoInputArray,
- { id, username },
- ]);
+ (userItem: UserListItem) => {
setUsernameInputText('');
+ if (!userItem.alert) {
+ setUserInfoInputArray(previousUserInfoInputArray => [
+ ...previousUserInfoInputArray,
+ { id: userItem.id, username: userItem.username },
+ ]);
+ } else if (
+ userItem.notice === notFriendNotice &&
+ userInfoInputArray.length === 0
+ ) {
+ const newUserInfoInputArray = [
+ { id: userItem.id, username: userItem.username },
+ ];
+ setUserInfoInputArray(newUserInfoInputArray);
+ const threadInfo = existingThreadInfoFinderForCreatingThread({
+ searching: true,
+ userInfoInputArray: newUserInfoInputArray,
+ });
+ dispatch({
+ type: updateNavInfoActionType,
+ payload: {
+ chatMode: 'view',
+ activeChatThreadID: threadInfo?.id,
+ pendingThread: threadInfo,
+ },
+ });
+ } else {
+ pushModal(
+ <Alert title={userItem.alert.title}>{userItem.alert.text}</Alert>,
+ );
+ }
},
- [setUserInfoInputArray],
+ [
+ dispatch,
+ existingThreadInfoFinderForCreatingThread,
+ pushModal,
+ setUserInfoInputArray,
+ userInfoInputArray.length,
+ ],
);
const onRemoveUserFromSelected = React.useCallback(
@@ -150,18 +192,11 @@
<li key={userSearchResult.id} className={css.searchResultsItem}>
<Button
variant="text"
- onClick={() =>
- onSelectUserFromSearch(
- userSearchResult.id,
- userSearchResult.username,
- )
- }
+ onClick={() => onSelectUserFromSearch(userSearchResult)}
className={css.searchResultsButton}
>
<div className={css.userName}>{userSearchResult.username}</div>
- <div className={css.userInfo}>
- {userSearchResult.alert?.title}
- </div>
+ <div className={css.userInfo}>{userSearchResult.notice}</div>
</Button>
</li>
))}
@@ -174,7 +209,6 @@
usernameInputText,
]);
- const dispatch = useDispatch();
const hideSearch = React.useCallback(
(threadBehavior: ActiveThreadBehavior = 'keep-active-thread') => {
dispatch({
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 6:10 AM (7 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5842803
Default Alt Text
D5518.1765087855.diff (5 KB)
Attached To
Mode
D5518: [web] Unify behaviour of chat composer with native
Attached
Detach File
Event Timeline
Log In to Comment