aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/components/NoticeComponent.tsx
diff options
context:
space:
mode:
authorAjay Ramachandran <[email protected]>2021-01-17 14:25:45 -0500
committerAjay Ramachandran <[email protected]>2021-01-17 14:25:45 -0500
commite269b1aec605ae5afb55572cb9a0177529862209 (patch)
treee96855685ea6c0b433d7045e0ce2d1d49fa71f4f /src/components/NoticeComponent.tsx
parentff0dc6e5706ffae19502b192061189c6e0c2199f (diff)
downloadSponsorBlock-e269b1aec605ae5afb55572cb9a0177529862209.tar.gz
SponsorBlock-e269b1aec605ae5afb55572cb9a0177529862209.zip
Add skip keybind
https://github.com/ajayyy/SponsorBlock/issues/299
Diffstat (limited to 'src/components/NoticeComponent.tsx')
-rw-r--r--src/components/NoticeComponent.tsx23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/components/NoticeComponent.tsx b/src/components/NoticeComponent.tsx
index d699c204..da25aa65 100644
--- a/src/components/NoticeComponent.tsx
+++ b/src/components/NoticeComponent.tsx
@@ -177,12 +177,19 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> {
countdownTime
})
}
+
+ removeFadeAnimation(): void {
+ //remove the fade out class if it exists
+ const notice = document.getElementById("sponsorSkipNotice" + this.idSuffix);
+ notice.classList.remove("sponsorSkipNoticeFadeOut");
+ notice.style.animation = "none";
+ }
pauseCountdown(): void {
if (!this.props.timed) return;
//remove setInterval
- clearInterval(this.countdownInterval);
+ if (this.countdownInterval) clearInterval(this.countdownInterval);
this.countdownInterval = null;
//reset countdown and inform the user
@@ -191,10 +198,7 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> {
countdownText: this.state.countdownManuallyPaused ? chrome.i18n.getMessage("manualPaused") : chrome.i18n.getMessage("paused")
});
- //remove the fade out class if it exists
- const notice = document.getElementById("sponsorSkipNotice" + this.idSuffix);
- notice.classList.remove("sponsorSkipNoticeFadeOut");
- notice.style.animation = "none";
+ this.removeFadeAnimation();
}
startCountdown(): void {
@@ -208,16 +212,25 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> {
countdownText: null
});
+ this.setupInterval();
+ }
+
+ setupInterval(): void {
+ if (this.countdownInterval) clearInterval(this.countdownInterval);
this.countdownInterval = setInterval(this.countdown.bind(this), 1000);
}
resetCountdown(): void {
if (!this.props.timed) return;
+ this.setupInterval();
+
this.setState({
countdownTime: this.state.maxCountdownTime(),
countdownText: null
});
+
+ this.removeFadeAnimation();
}
/**