refactor: rename hook

useconversationusernameorshorten to usenicknameorprofilenameorshortenedpubkey
pull/2971/head
William Grant 2 years ago
parent dfe0f6866a
commit da869bfdd3

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

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

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

Loading…
Cancel
Save