From 9ff1c1e50d9405302d2c253650ba5be555073ec0 Mon Sep 17 00:00:00 2001 From: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com> Date: Thu, 16 Sep 2021 16:47:08 -0500 Subject: [PATCH] Recompute hero row size when it appears --- ts/components/conversation/Timeline.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ts/components/conversation/Timeline.tsx b/ts/components/conversation/Timeline.tsx index df05749a6a..28e93e3faf 100644 --- a/ts/components/conversation/Timeline.tsx +++ b/ts/components/conversation/Timeline.tsx @@ -1020,6 +1020,7 @@ export class Timeline extends React.PureComponent { ): void { const { clearChangedMessages, + haveOldest, id, isIncomingMessageRequest, items, @@ -1030,13 +1031,18 @@ export class Timeline extends React.PureComponent { typingContact, } = this.props; - // Warnings can increase the size of the first row (adding padding for the floating - // warning), so we recompute it when the warnings change. + // We recompute the hero row's height if: + // + // 1. We just started showing it (a loading row changes to a hero row) + // 2. Warnings were shown (they add padding to the hero for the floating warning) + const hadOldest = prevProps.haveOldest; const hadWarning = Boolean( prevProps.warning && !prevState.hasDismissedDirectContactSpoofingWarning ); - if (hadWarning !== Boolean(this.getWarning())) { - this.recomputeRowHeights(0); + const shouldRecomputeRowHeights = + (!hadOldest && haveOldest) || hadWarning !== Boolean(this.getWarning()); + if (shouldRecomputeRowHeights) { + this.resizeHeroRow(); } // There are a number of situations which can necessitate that we forget about row