mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 13:07:05 +03:00
Submission notice size now updates when the video size changes.
React listeners are properly cleaned up now.
This commit is contained in:
@@ -30,6 +30,8 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
|
|||||||
noticeRef: React.MutableRefObject<NoticeComponent>;
|
noticeRef: React.MutableRefObject<NoticeComponent>;
|
||||||
timeEditRefs: React.RefObject<SponsorTimeEditComponent>[];
|
timeEditRefs: React.RefObject<SponsorTimeEditComponent>[];
|
||||||
|
|
||||||
|
videoObserver: MutationObserver;
|
||||||
|
|
||||||
constructor(props: SubmissionNoticeProps) {
|
constructor(props: SubmissionNoticeProps) {
|
||||||
super(props);
|
super(props);
|
||||||
this.noticeRef = React.createRef();
|
this.noticeRef = React.createRef();
|
||||||
@@ -47,6 +49,24 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
// Catch and rerender when the video size changes
|
||||||
|
//TODO: Use ResizeObserver when it is supported in TypeScript
|
||||||
|
this.videoObserver = new MutationObserver(() => {
|
||||||
|
this.forceUpdate();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.videoObserver.observe(this.contentContainer().v, {
|
||||||
|
attributes: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
if (this.videoObserver) {
|
||||||
|
this.videoObserver.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<NoticeComponent noticeTitle={this.state.noticeTitle}
|
<NoticeComponent noticeTitle={this.state.noticeTitle}
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ class SkipNotice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
|
ReactDOM.unmountComponentAtNode(this.noticeElement);
|
||||||
|
|
||||||
this.noticeElement.remove();
|
this.noticeElement.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ class SubmissionNotice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
|
ReactDOM.unmountComponentAtNode(this.noticeElement);
|
||||||
|
|
||||||
this.noticeElement.remove();
|
this.noticeElement.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user