Skip to content

Commit

Permalink
[lib/web/native] Show viewer in @-mentioning tooltip
Browse files Browse the repository at this point in the history
Summary:
This enables users to see themselves in the @-mention tooltip so they can mention themselves. We won't have to make any changes to the user-profile on `web`/`native` since we already only just show the 'Message' button if `otherUserInfo` is undefined.

**This does not need to be landed if we decide we don't want to enable this feature**

This is part of [[ https://linear.app/comm/issue/ENG-6297/consider-allowing-users-to-mention-themselves | ENG-6297 ]]

Test Plan:
Please see the videos below

{F1013471}

{F1013475}

Reviewers: atul, ginsu, inka, ashoat

Reviewed By: ashoat

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D10494
  • Loading branch information
RohanK6 committed Dec 29, 2023
1 parent 7f64f3d commit e1798c2
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 6 deletions.
6 changes: 2 additions & 4 deletions lib/shared/mention-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as React from 'react';

import { markdownUserMentionRegexString } from './account-utils.js';
import SentencePrefixSearchIndex from './sentence-prefix-search-index.js';
import { threadOtherMembers } from './thread-utils.js';
import { stringForUserExplicit } from './user-utils.js';
import { useENSNames } from '../hooks/ens-cache.js';
import { useUserSearchIndex } from '../selectors/nav-selectors.js';
Expand Down Expand Up @@ -107,7 +106,6 @@ function getTypeaheadRegexMatches(
const useENSNamesOptions = { allAtOnce: true };
function useMentionTypeaheadUserSuggestions(
threadMembers: $ReadOnlyArray<RelativeMemberInfo>,
viewerID: ?string,
typeaheadMatchedStrings: ?TypeaheadMatchedStrings,
): $ReadOnlyArray<MentionTypeaheadUserSuggestionItem> {
const userSearchIndex = useUserSearchIndex(threadMembers);
Expand All @@ -121,7 +119,7 @@ function useMentionTypeaheadUserSuggestions(
}

const userIDs = userSearchIndex.getSearchResults(usernamePrefix);
const usersInThread = threadOtherMembers(resolvedThreadMembers, viewerID);
const usersInThread = resolvedThreadMembers.filter(member => member.role);

return usersInThread
.filter(user => usernamePrefix.length === 0 || userIDs.includes(user.id))
Expand All @@ -131,7 +129,7 @@ function useMentionTypeaheadUserSuggestions(
),
)
.map(userInfo => ({ type: 'user', userInfo }));
}, [userSearchIndex, resolvedThreadMembers, usernamePrefix, viewerID]);
}, [userSearchIndex, resolvedThreadMembers, usernamePrefix]);
}

function useMentionTypeaheadChatSuggestions(
Expand Down
1 change: 0 additions & 1 deletion native/chat/chat-input-bar.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,6 @@ function ConnectedChatInputBarBase(props: ConnectedChatInputBarBaseProps) {

const suggestedUsers = useMentionTypeaheadUserSuggestions(
userMentionsCandidates,
viewerID,
typeaheadMatchedStrings,
);

Expand Down
1 change: 0 additions & 1 deletion web/chat/chat-input-bar.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,6 @@ const ConnectedChatInputBar: React.ComponentType<BaseProps> =

const suggestedUsers = useMentionTypeaheadUserSuggestions(
props.inputState.typeaheadState.frozenUserMentionsCandidates,
viewerID,
typeaheadMatchedStrings,
);

Expand Down

0 comments on commit e1798c2

Please sign in to comment.