From 029f50c52c8d1109f523325775bf909ffda95ebb Mon Sep 17 00:00:00 2001 From: Vyrtsev Mikhail Date: Sun, 19 Jan 2020 02:05:49 +0300 Subject: [PATCH] do not render dummy for comment once it gets into viewport --- frontend/app/components/comment/comment.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/app/components/comment/comment.tsx b/frontend/app/components/comment/comment.tsx index d48d0220..e40c20d9 100644 --- a/frontend/app/components/comment/comment.tsx +++ b/frontend/app/components/comment/comment.tsx @@ -52,6 +52,7 @@ export type Props = { } & Partial; export interface State { + renderDummy: boolean; isCopied: boolean; editDeadline: Date | null; voteErrorMessage: string | null; @@ -79,6 +80,7 @@ export class Comment extends Component { super(props); this.state = { + renderDummy: typeof props.inView === 'boolean' ? !props.inView : false, isCopied: false, editDeadline: null, voteErrorMessage: null, @@ -115,6 +117,10 @@ export class Comment extends Component { cachedScore: props.data.score, }; + if (props.inView) { + newState.renderDummy = false; + } + // set comment edit timer if (props.user && props.user.id === props.data.user.id) { const editDuration = StaticStore.config.edit_duration; @@ -540,7 +546,7 @@ export class Comment extends Component { ); } - if (!props.editMode && this.props.inView === false) { + if (this.state.renderDummy && !props.editMode) { const [width, height] = this.base ? [(this.base as Element).scrollWidth, (this.base as Element).scrollHeight] : [100, 100];