Use consistent check for timeline height recomputation
This commit is contained in:
parent
250a89d953
commit
c19a801b89
1 changed files with 10 additions and 9 deletions
|
@ -756,7 +756,7 @@ export class Timeline extends React.PureComponent<PropsType, StateType> {
|
||||||
if (haveOldest && row === 0) {
|
if (haveOldest && row === 0) {
|
||||||
rowContents = (
|
rowContents = (
|
||||||
<div data-row={row} style={styleWithWidth} role="row">
|
<div data-row={row} style={styleWithWidth} role="row">
|
||||||
{this.getWarning() ? (
|
{Timeline.getWarning(this.props, this.state) ? (
|
||||||
<div style={{ height: lastMeasuredWarningHeight }} />
|
<div style={{ height: lastMeasuredWarningHeight }} />
|
||||||
) : null}
|
) : null}
|
||||||
{renderHeroRow(
|
{renderHeroRow(
|
||||||
|
@ -1036,11 +1036,10 @@ export class Timeline extends React.PureComponent<PropsType, StateType> {
|
||||||
// 1. We just started showing it (a loading row changes to a hero row)
|
// 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)
|
// 2. Warnings were shown (they add padding to the hero for the floating warning)
|
||||||
const hadOldest = prevProps.haveOldest;
|
const hadOldest = prevProps.haveOldest;
|
||||||
const hadWarning = Boolean(
|
const hadWarning = Boolean(Timeline.getWarning(prevProps, prevState));
|
||||||
prevProps.warning && !prevState.hasDismissedDirectContactSpoofingWarning
|
const haveWarning = Boolean(Timeline.getWarning(this.props, this.state));
|
||||||
);
|
|
||||||
const shouldRecomputeRowHeights =
|
const shouldRecomputeRowHeights =
|
||||||
(!hadOldest && haveOldest) || hadWarning !== Boolean(this.getWarning());
|
(!hadOldest && haveOldest) || hadWarning !== haveWarning;
|
||||||
if (shouldRecomputeRowHeights) {
|
if (shouldRecomputeRowHeights) {
|
||||||
this.resizeHeroRow();
|
this.resizeHeroRow();
|
||||||
}
|
}
|
||||||
|
@ -1376,7 +1375,7 @@ export class Timeline extends React.PureComponent<PropsType, StateType> {
|
||||||
</AutoSizer>
|
</AutoSizer>
|
||||||
);
|
);
|
||||||
|
|
||||||
const warning = this.getWarning();
|
const warning = Timeline.getWarning(this.props, this.state);
|
||||||
let timelineWarning: ReactNode;
|
let timelineWarning: ReactNode;
|
||||||
if (warning) {
|
if (warning) {
|
||||||
let text: ReactChild;
|
let text: ReactChild;
|
||||||
|
@ -1548,15 +1547,17 @@ export class Timeline extends React.PureComponent<PropsType, StateType> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getWarning(): undefined | WarningType {
|
private static getWarning(
|
||||||
const { warning } = this.props;
|
{ warning }: PropsType,
|
||||||
|
state: StateType
|
||||||
|
): undefined | WarningType {
|
||||||
if (!warning) {
|
if (!warning) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (warning.type) {
|
switch (warning.type) {
|
||||||
case ContactSpoofingType.DirectConversationWithSameTitle: {
|
case ContactSpoofingType.DirectConversationWithSameTitle: {
|
||||||
const { hasDismissedDirectContactSpoofingWarning } = this.state;
|
const { hasDismissedDirectContactSpoofingWarning } = state;
|
||||||
return hasDismissedDirectContactSpoofingWarning ? undefined : warning;
|
return hasDismissedDirectContactSpoofingWarning ? undefined : warning;
|
||||||
}
|
}
|
||||||
case ContactSpoofingType.MultipleGroupMembersWithSameTitle:
|
case ContactSpoofingType.MultipleGroupMembersWithSameTitle:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue