From 41b488a71e2b0579d3c54c8e145de38e7f7082e6 Mon Sep 17 00:00:00 2001 From: William Grant Date: Wed, 5 Jul 2023 15:51:48 +1000 Subject: [PATCH] feat: dont show your pubkey in community quotes --- .../message/message-content/quote/QuoteAuthor.tsx | 4 ++-- ts/hooks/useParamSelector.ts | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ts/components/conversation/message/message-content/quote/QuoteAuthor.tsx b/ts/components/conversation/message/message-content/quote/QuoteAuthor.tsx index d724b1203..cb5ede16e 100644 --- a/ts/components/conversation/message/message-content/quote/QuoteAuthor.tsx +++ b/ts/components/conversation/message/message-content/quote/QuoteAuthor.tsx @@ -29,7 +29,7 @@ export const QuoteAuthor = (props: QuoteAuthorProps) => { const { author, isIncoming } = props; const isPublic = useSelectedIsPublic(); - const authorName = useQuoteAuthorName(author); + const { authorName, isMe } = useQuoteAuthorName(author); if (!author || !authorName) { return null; @@ -41,7 +41,7 @@ export const QuoteAuthor = (props: QuoteAuthorProps) => { pubkey={PubKey.shorten(author)} name={authorName} compact={true} - shouldShowPubkey={Boolean(authorName && isPublic)} + shouldShowPubkey={Boolean(authorName && !isMe && isPublic)} /> ); diff --git a/ts/hooks/useParamSelector.ts b/ts/hooks/useParamSelector.ts index 59e4411bf..a46bc4776 100644 --- a/ts/hooks/useParamSelector.ts +++ b/ts/hooks/useParamSelector.ts @@ -264,11 +264,17 @@ export function useIsTyping(conversationId?: string): boolean { return useConversationPropsById(conversationId)?.isTyping || false; } -export function useQuoteAuthorName(authorId?: string) { +export function useQuoteAuthorName( + authorId?: string +): { authorName: string | undefined; isMe: boolean } { const convoProps = useConversationPropsById(authorId); - return authorId && isUsAnySogsFromCache(authorId) + + const isMe = Boolean(authorId && isUsAnySogsFromCache(authorId)); + const authorName = isMe ? window.i18n('you') : convoProps?.nickname || convoProps?.isPrivate ? convoProps?.displayNameInProfile : undefined; + + return { authorName, isMe }; }