Skip to content

Commit f3091a2

Browse files
authored
Merge pull request #1563 from session-foundation/fix-pro-badge-more-issues
fix: more qa issues with pro badges
2 parents 6d5c4e6 + c9e166b commit f3091a2

File tree

8 files changed

+39
-9
lines changed

8 files changed

+39
-9
lines changed

ts/components/conversation/ContactName/ContactName.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,29 @@ const boldStyles: CSSProperties = {
177177
fontWeight: 'bold',
178178
};
179179

180+
function allowShowUPMForNtsCtx(ctx: ContactNameContext) {
181+
// We are doing this as a switch instead of an array so we have to be explicit anytime we add a new context,
182+
// thanks to the assertUnreachable below
183+
switch (ctx) {
184+
case 'message-info-author':
185+
case 'member-list-item':
186+
case 'member-list-item-mention-row':
187+
case 'contact-list-row':
188+
case 'message-author':
189+
case 'quote-author':
190+
case 'quoted-message-composition':
191+
case 'react-list-modal':
192+
case 'message-search-result-conversation':
193+
case 'message-search-result-from':
194+
case 'conversation-list-item':
195+
case 'conversation-list-item-search':
196+
return false;
197+
default:
198+
assertUnreachable(ctx, 'isForceSingleLineCtx');
199+
throw new Error('isForceSingleLineCtx: unreachable');
200+
}
201+
}
202+
180203
export const ContactName = ({
181204
pubkey,
182205
module,
@@ -231,7 +254,10 @@ export const ContactName = ({
231254

232255
const userHasPro = useUserHasPro(pubkey);
233256

234-
const showConversationSettingsCb = useShowUserDetailsCbFromConversation(pubkey);
257+
const showConversationSettingsCb = useShowUserDetailsCbFromConversation(
258+
pubkey,
259+
allowShowUPMForNtsCtx(contactNameContext)
260+
);
235261

236262
const showProBadge = useProBadgeOnClickCb({
237263
context: 'contact-name',

ts/components/conversation/right-panel/overlay/message-info/components/MessageFrom.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const MessageFrom = (props: { sender: string; isSenderAdmin: boolean }) =
4949

5050
const selectedConvoId = useSelectedConversationKey();
5151

52-
const showUserProfileModalCb = useShowUserDetailsCbFromConversation(sender) ?? undefined;
52+
const showUserProfileModalCb = useShowUserDetailsCbFromConversation(sender, true) ?? undefined;
5353

5454
return (
5555
<StyledMessageInfoAuthor>

ts/components/dialog/SessionProInfoModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ export function SessionProInfoModal(props: SessionProInfoState) {
264264
if (isNil(props?.variant) || (hasPro && !isProVisibleCTA(props.variant))) {
265265
return null;
266266
}
267+
const isGroupCta = props.variant === SessionProInfoVariant.GROUP_ACTIVATED;
267268

268269
return (
269270
<SessionWrapperModal
@@ -316,7 +317,7 @@ export function SessionProInfoModal(props: SessionProInfoState) {
316317
>
317318
<SpacerSM />
318319
<StyledCTATitle reverseDirection={hasPro}>
319-
{tr(hasPro ? 'proActivated' : 'upgradeTo')}
320+
{tr(hasPro ? (isGroupCta ? 'proGroupActivated' : 'proActivated') : 'upgradeTo')}
320321
<ProIconButton iconSize={'huge'} dataTestId="invalid-data-testid" onClick={undefined} />
321322
</StyledCTATitle>
322323
<SpacerXL />

ts/components/dialog/conversationSettings/ConversationTitleDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export const ConversationTitleDialog = ({
8080
}}
8181
onClick={onClickCb || undefined}
8282
>
83-
{isMe ? tr('noteToSelf') : nicknameOrDisplayName}
83+
{isMe ? tr('you') : nicknameOrDisplayName}
8484
<ProBadge conversationId={conversationId} />
8585
</H5>
8686
);

ts/components/leftpane/conversation-list-item/ConversationListItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const Portal = ({ children }: { children: ReactNode }) => {
2828
const AvatarItem = () => {
2929
const conversationId = useConvoIdFromContext();
3030

31-
const showUserDetailsCb = useShowUserDetailsCbFromConversation(conversationId);
31+
const showUserDetailsCb = useShowUserDetailsCbFromConversation(conversationId, true);
3232

3333
return (
3434
<div>

ts/components/leftpane/overlay/choose-action/ContactRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const StyledAvatarItem = styled.div`
1313
const AvatarItem = (props: Pick<Props, 'id'>) => {
1414
const { id } = props;
1515

16-
const showUserDetailsFromConversationCb = useShowUserDetailsCbFromConversation(id) ?? undefined;
16+
const showUserDetailsFromConversationCb = useShowUserDetailsCbFromConversation(id, true) ?? undefined;
1717

1818
return (
1919
<StyledAvatarItem>

ts/components/menu/Menu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export const DeletePrivateContactMenuItem = () => {
9494
export const ShowUserProfileMenuItem = () => {
9595
const convoId = useConvoIdFromContext();
9696

97-
const showUserDetailsCb = useShowUserDetailsCbFromConversation(convoId);
97+
const showUserDetailsCb = useShowUserDetailsCbFromConversation(convoId, true);
9898

9999
if (showUserDetailsCb) {
100100
return (

ts/components/menuAndSettingsHooks/useShowUserDetailsCb.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,17 @@ export function useShowUserDetailsCbFromMessage() {
7979
* Show the user details modal for a given conversation.
8080
* Note: this is only a valid action for private chats (blinded or not, friends or not)
8181
*/
82-
export function useShowUserDetailsCbFromConversation(conversationId?: string) {
82+
export function useShowUserDetailsCbFromConversation(
83+
conversationId?: string,
84+
allowForNts?: boolean
85+
) {
8386
const dispatch = useDispatch();
8487

8588
const isPrivate = useIsPrivate(conversationId);
8689

8790
const isMe = useIsMe(conversationId);
8891

89-
if (!conversationId || isMe) {
92+
if (!conversationId || (isMe && !allowForNts)) {
9093
return null;
9194
}
9295

0 commit comments

Comments
 (0)