mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-11 05:57:07 +03:00
Scroll down when new segment added to notice
This commit is contained in:
@@ -38,6 +38,8 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
|
|||||||
|
|
||||||
guidelinesReminder: GenericNotice;
|
guidelinesReminder: GenericNotice;
|
||||||
|
|
||||||
|
lastSegmentCount: number;
|
||||||
|
|
||||||
constructor(props: SubmissionNoticeProps) {
|
constructor(props: SubmissionNoticeProps) {
|
||||||
super(props);
|
super(props);
|
||||||
this.noticeRef = React.createRef();
|
this.noticeRef = React.createRef();
|
||||||
@@ -47,12 +49,14 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
|
|||||||
|
|
||||||
const noticeTitle = chrome.i18n.getMessage("confirmNoticeTitle");
|
const noticeTitle = chrome.i18n.getMessage("confirmNoticeTitle");
|
||||||
|
|
||||||
|
this.lastSegmentCount = this.props.contentContainer().sponsorTimesSubmitting.length;
|
||||||
|
|
||||||
// Setup state
|
// Setup state
|
||||||
this.state = {
|
this.state = {
|
||||||
noticeTitle,
|
noticeTitle,
|
||||||
messages: [],
|
messages: [],
|
||||||
idSuffix: "SubmissionNotice"
|
idSuffix: "SubmissionNotice"
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount(): void {
|
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 {
|
render(): React.ReactElement {
|
||||||
const sortButton =
|
const sortButton =
|
||||||
<img id={"sponsorSkipSortButton" + this.state.idSuffix}
|
<img id={"sponsorSkipSortButton" + this.state.idSuffix}
|
||||||
|
|||||||
Reference in New Issue
Block a user