diff options
Diffstat (limited to 'src/components/SubmissionNoticeComponent.tsx')
-rw-r--r-- | src/components/SubmissionNoticeComponent.tsx | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/components/SubmissionNoticeComponent.tsx b/src/components/SubmissionNoticeComponent.tsx index 9aa52670..2cf394f1 100644 --- a/src/components/SubmissionNoticeComponent.tsx +++ b/src/components/SubmissionNoticeComponent.tsx @@ -14,7 +14,7 @@ export interface SubmissionNoticeProps { // Contains functions and variables from the content script needed by the skip notice contentContainer: ContentContainer; - callback: () => unknown; + callback: () => Promise<boolean>; closeListener: () => void; } @@ -69,6 +69,13 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S this.videoObserver.observe(this.contentContainer().v, { attributes: true }); + + // Prevent zooming while changing times + document.getElementById("sponsorSkipNoticeMiddleRow" + this.state.idSuffix).addEventListener('wheel', function (event) { + if (event.ctrlKey) { + event.preventDefault(); + } + }, {passive: false}); } componentWillUnmount(): void { @@ -82,13 +89,17 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S if (currentSegmentCount > this.lastSegmentCount) { this.lastSegmentCount = currentSegmentCount; - const scrollElement = this.noticeRef.current.getElement().current.querySelector("#sponsorSkipNoticeMiddleRowSubmissionNotice"); - scrollElement.scrollTo({ - top: scrollElement.scrollHeight + 1000 - }); + this.scrollToBottom(); } } + scrollToBottom() { + 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} @@ -96,7 +107,7 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S onClick={() => this.sortSegments()} title={chrome.i18n.getMessage("sortSegments")} key="sortButton" - src={chrome.extension.getURL("icons/sort.svg")}> + src={chrome.runtime.getURL("icons/sort.svg")}> </img>; const exportButton = <img id={"sponsorSkipExportButton" + this.state.idSuffix} @@ -104,7 +115,7 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S onClick={() => this.exportSegments()} title={chrome.i18n.getMessage("exportSegments")} key="exportButton" - src={chrome.extension.getURL("icons/export.svg")}> + src={chrome.runtime.getURL("icons/export.svg")}> </img>; return ( <NoticeComponent noticeTitle={this.state.noticeTitle} @@ -228,9 +239,11 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S } } - this.props.callback(); - - this.cancel(); + this.props.callback().then((success) => { + if (success) { + this.cancel(); + } + }); } sortSegments(): void { |