diff options
author | Ajay <[email protected]> | 2023-11-01 16:08:52 -0400 |
---|---|---|
committer | Ajay <[email protected]> | 2023-11-01 16:08:52 -0400 |
commit | 4ffa019c688993d03dd36a560ce9cce8785f88d6 (patch) | |
tree | 42dfbeb2b015829ec5e5eb4006e1349f50f3a90b /src | |
parent | 9c2007e0cf99fe65b53fcc3c11a102297717a63c (diff) | |
download | SponsorBlock-4ffa019c688993d03dd36a560ce9cce8785f88d6.tar.gz SponsorBlock-4ffa019c688993d03dd36a560ce9cce8785f88d6.zip |
Scroll down when new segment added to notice
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} |