Page MenuHomePhabricator

D11760.id39495.diff
No OneTemporary

D11760.id39495.diff

diff --git a/web/chat/chat-message-list.react.js b/web/chat/chat-message-list.react.js
--- a/web/chat/chat-message-list.react.js
+++ b/web/chat/chat-message-list.react.js
@@ -24,7 +24,10 @@
useMessageListData,
} from 'lib/selectors/chat-selectors.js';
import { messageKey } from 'lib/shared/message-utils.js';
-import { threadIsPending } from 'lib/shared/thread-utils.js';
+import {
+ threadIsPending,
+ threadOtherMembers,
+} from 'lib/shared/thread-utils.js';
import type { FetchMessageInfosPayload } from 'lib/types/message-types.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import { threadTypes } from 'lib/types/thread-types-enum.js';
@@ -76,6 +79,7 @@
+isEditState: boolean,
+addScrollToMessageListener: ScrollToMessageCallback => mixed,
+removeScrollToMessageListener: ScrollToMessageCallback => mixed,
+ +viewerID: ?string,
};
type Snapshot = {
+scrollTop: number,
@@ -315,7 +319,26 @@
let relationshipPrompt = null;
if (threadInfo.type === threadTypes.PERSONAL) {
- relationshipPrompt = <RelationshipPrompt threadInfo={threadInfo} />;
+ const otherMembers = threadOtherMembers(
+ threadInfo.members,
+ this.props.viewerID,
+ );
+
+ let pendingPersonalThreadUserInfo;
+ if (otherMembers.length === 1) {
+ const otherMember = otherMembers[0];
+ pendingPersonalThreadUserInfo = {
+ id: otherMember.id,
+ username: otherMember.username,
+ };
+ }
+
+ relationshipPrompt = (
+ <RelationshipPrompt
+ threadInfo={threadInfo}
+ pendingPersonalThreadUserInfo={pendingPersonalThreadUserInfo}
+ />
+ );
}
const messageContainerStyle = classNames({
@@ -462,6 +485,8 @@
} = useEditModalContext();
const isEditState = editState !== null;
+ const viewerID = useSelector(state => state.currentUserInfo?.id);
+
return (
<MessageListContext.Provider value={messageListContext}>
<ChatMessageList
@@ -478,6 +503,7 @@
isEditState={isEditState}
addScrollToMessageListener={addScrollToMessageListener}
removeScrollToMessageListener={removeScrollToMessageListener}
+ viewerID={viewerID}
/>
</MessageListContext.Provider>
);
diff --git a/web/chat/relationship-prompt/relationship-prompt.js b/web/chat/relationship-prompt/relationship-prompt.js
--- a/web/chat/relationship-prompt/relationship-prompt.js
+++ b/web/chat/relationship-prompt/relationship-prompt.js
@@ -11,19 +11,26 @@
import { useRelationshipPrompt } from 'lib/hooks/relationship-prompt.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import { userRelationshipStatus } from 'lib/types/relationship-types.js';
+import type { UserInfo } from 'lib/types/user-types.js';
import RelationshipPromptButtonContainer from './relationship-prompt-button-container.js';
import RelationshipPromptButton from './relationship-prompt-button.js';
import { buttonThemes } from '../../components/button.react.js';
-type Props = { +threadInfo: ThreadInfo };
-
+type Props = {
+ +pendingPersonalThreadUserInfo: ?UserInfo,
+ +threadInfo: ThreadInfo,
+};
function RelationshipPrompt(props: Props) {
const { threadInfo } = props;
const {
otherUserInfo,
callbacks: { blockUser, unblockUser, friendUser, unfriendUser },
- } = useRelationshipPrompt(threadInfo);
+ } = useRelationshipPrompt(
+ threadInfo,
+ undefined,
+ props.pendingPersonalThreadUserInfo,
+ );
if (!otherUserInfo?.username) {
return null;
}

File Metadata

Mime Type
text/plain
Expires
Sat, Jan 11, 1:15 AM (16 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2854213
Default Alt Text
D11760.id39495.diff (3 KB)

Event Timeline