diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/components/SubmissionNoticeComponent.tsx | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/components/SubmissionNoticeComponent.tsx b/src/components/SubmissionNoticeComponent.tsx index e81c2bdf..c10472e1 100644 --- a/src/components/SubmissionNoticeComponent.tsx +++ b/src/components/SubmissionNoticeComponent.tsx @@ -38,6 +38,8 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S guidelinesReminder: GenericNotice; + lastSegmentCount: number; + constructor(props: SubmissionNoticeProps) { super(props); this.noticeRef = React.createRef(); @@ -47,12 +49,14 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S const noticeTitle = chrome.i18n.getMessage("confirmNoticeTitle"); + this.lastSegmentCount = this.props.contentContainer().sponsorTimesSubmitting.length; + // Setup state this.state = { noticeTitle, messages: [], idSuffix: "SubmissionNotice" - } + }; } componentDidMount(): void { @@ -73,6 +77,18 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S } } + componentDidUpdate() { + const currentSegmentCount = this.props.contentContainer().sponsorTimesSubmitting.length; + if (currentSegmentCount > this.lastSegmentCount) { + this.lastSegmentCount = currentSegmentCount; + + const scrollElement = this.noticeRef.current.getElement().current.querySelector("#sponsorSkipNoticeMiddleRowSubmissionNotice"); + scrollElement.scrollTo({ + top: scrollElement.scrollHeight + 1000 + }); + } + } + render(): React.ReactElement { const sortButton = <img id={"sponsorSkipSortButton" + this.state.idSuffix} |