diff --git a/ts/components/conversation/ConversationHero.tsx b/ts/components/conversation/ConversationHero.tsx index 2394b49b88..531be838c1 100644 --- a/ts/components/conversation/ConversationHero.tsx +++ b/ts/components/conversation/ConversationHero.tsx @@ -2,7 +2,6 @@ // SPDX-License-Identifier: AGPL-3.0-only import React, { useEffect, useRef, useState } from 'react'; -import Measure from 'react-measure'; import { Avatar, AvatarBlur, Props as AvatarProps } from '../Avatar'; import { ContactName } from './ContactName'; import { About } from './About'; @@ -11,7 +10,6 @@ import { SharedGroupNames } from '../SharedGroupNames'; import { LocalizerType } from '../../types/Util'; import { ConfirmationDialog } from '../ConfirmationDialog'; import { Button, ButtonSize, ButtonVariant } from '../Button'; -import { assert } from '../../util/assert'; import { shouldBlurAvatar } from '../../util/shouldBlurAvatar'; export type Props = { @@ -114,9 +112,6 @@ export const ConversationHero = ({ }: Props): JSX.Element => { const firstRenderRef = useRef(true); - const previousHeightRef = useRef(); - const [height, setHeight] = useState(); - const [ isShowingMessageRequestWarning, setIsShowingMessageRequestWarning, @@ -130,26 +125,29 @@ export const ConversationHero = ({ updateSharedGroups(); }, [updateSharedGroups]); + const sharedGroupNamesStringified = JSON.stringify(sharedGroupNames); useEffect(() => { - firstRenderRef.current = false; - }, []); - - useEffect(() => { - // We only want to kick off a "height change" when the height goes from number to - // number. We DON'T want to do it when we measure the height for the first time, as - // this will cause a re-render loop. - const previousHeight = previousHeightRef.current; - if (previousHeight && height && previousHeight !== height) { - window.log.info( - `ConversationHero height changed from ${previousHeight} to ${height}` - ); - onHeightChange?.(); + const isFirstRender = firstRenderRef.current; + if (isFirstRender) { + firstRenderRef.current = false; + return; } - }, [height, onHeightChange]); - useEffect(() => { - previousHeightRef.current = height; - }, [height]); + window.log.info('ConversationHero: calling onHeightChange'); + onHeightChange?.(); + }, [ + about, + conversationType, + groupDescription, + isMe, + membersCount, + name, + onHeightChange, + phoneNumber, + profileName, + title, + sharedGroupNamesStringified, + ]); let avatarBlur: AvatarBlur; let avatarOnClick: undefined | (() => void); @@ -175,81 +173,71 @@ export const ConversationHero = ({ /* eslint-disable no-nested-ternary */ return ( <> - { - assert(bounds, 'We should be measuring the bounds'); - setHeight(Math.ceil(bounds.height)); - }} - > - {({ measureRef }) => ( -
- + +

+ {isMe ? ( + i18n('noteToSelf') + ) : ( + -

- {isMe ? ( - i18n('noteToSelf') - ) : ( - - )} -

- {about && !isMe && ( -
- -
- )} - {!isMe ? ( -
- {groupDescription ? ( - - ) : membersCount === 1 ? ( - i18n('ConversationHero--members-1') - ) : membersCount !== undefined ? ( - i18n('ConversationHero--members', [`${membersCount}`]) - ) : phoneNumberOnly ? null : ( - phoneNumber - )} -
- ) : null} - {renderMembershipRow({ - acceptedMessageRequest, - conversationType, - i18n, - isMe, - onClickMessageRequestWarning() { - setIsShowingMessageRequestWarning(true); - }, - phoneNumber, - sharedGroupNames, - })} + )} +

+ {about && !isMe && ( +
+
)} - + {!isMe ? ( +
+ {groupDescription ? ( + + ) : membersCount === 1 ? ( + i18n('ConversationHero--members-1') + ) : membersCount !== undefined ? ( + i18n('ConversationHero--members', [`${membersCount}`]) + ) : phoneNumberOnly ? null : ( + phoneNumber + )} +
+ ) : null} + {renderMembershipRow({ + acceptedMessageRequest, + conversationType, + i18n, + isMe, + onClickMessageRequestWarning() { + setIsShowingMessageRequestWarning(true); + }, + phoneNumber, + sharedGroupNames, + })} +
{isShowingMessageRequestWarning && ( ();", - "reasonCategory": "usageTrusted", - "updated": "2021-07-30T16:57:33.618Z" - }, { "rule": "React-useRef", "path": "ts/components/conversation/GIF.js",