refactor: rename hook

useconversationusernameorshorten to usenicknameorprofilenameorshortenedpubkey
pull/2971/head
William Grant 9 months ago
parent dfe0f6866a
commit da869bfdd3

@ -2,7 +2,7 @@ import React from 'react';
import styled from 'styled-components';
import { Avatar, AvatarSize, CrownIcon } from './avatar/Avatar';
import { useConversationUsernameOrShorten } from '../hooks/useParamSelector';
import { useNicknameOrProfileNameOrShortenedPubkey } from '../hooks/useParamSelector';
import { SessionRadio } from './basic/SessionRadio';
const AvatarContainer = styled.div`
@ -91,7 +91,7 @@ export const MemberListItem = (props: {
dataTestId,
} = props;
const memberName = useConversationUsernameOrShorten(pubkey);
const memberName = useNicknameOrProfileNameOrShortenedPubkey(pubkey);
return (
<StyledSessionMemberItem

@ -3,7 +3,10 @@ import classNames from 'classnames';
import { CSSProperties } from 'styled-components';
import { Emojify } from './Emojify';
import { useConversationUsernameOrShorten, useIsPrivate } from '../../hooks/useParamSelector';
import {
useNicknameOrProfileNameOrShortenedPubkey,
useIsPrivate,
} from '../../hooks/useParamSelector';
type Props = {
pubkey: string;
@ -19,7 +22,7 @@ export const ContactName = (props: Props) => {
const { pubkey, name, profileName, module, boldProfileName, compact, shouldShowPubkey } = props;
const prefix = module || 'module-contact-name';
const convoName = useConversationUsernameOrShorten(pubkey);
const convoName = useNicknameOrProfileNameOrShortenedPubkey(pubkey);
const isPrivate = useIsPrivate(pubkey);
const shouldShowProfile = Boolean(convoName || profileName || name);
const styles = (boldProfileName

@ -34,11 +34,14 @@ export function useConversationUsername(convoId?: string) {
/**
* Returns either the nickname, displayNameInProfile, or the shorten pubkey
*/
export function useConversationUsernameOrShorten(convoId?: string) {
export function useNicknameOrProfileNameOrShortenedPubkey(convoId?: string) {
const convoProps = useConversationPropsById(convoId);
return (
convoProps?.nickname || convoProps?.displayNameInProfile || (convoId && PubKey.shorten(convoId))
convoProps?.nickname ||
convoProps?.displayNameInProfile ||
(convoId && PubKey.shorten(convoId)) ||
window.i18n('unknown')
);
}

Loading…
Cancel
Save