Made non timed notice the default

This commit is contained in:
Ajay Ramachandran
2020-03-10 12:08:54 -04:00
parent 92a6065c98
commit 1a92265e65
2 changed files with 6 additions and 11 deletions

View File

@@ -20,17 +20,11 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> {
countdownInterval: NodeJS.Timeout; countdownInterval: NodeJS.Timeout;
idSuffix: any; idSuffix: any;
timed: boolean
amountOfPreviousNotices: number; amountOfPreviousNotices: number;
constructor(props: NoticeProps) { constructor(props: NoticeProps) {
super(props); super(props);
// Set default to timed
this.timed = props.timed;
if (this.timed === undefined) this.timed = true;
if (props.maxCountdownTime === undefined) props.maxCountdownTime = () => 4; if (props.maxCountdownTime === undefined) props.maxCountdownTime = () => 4;
//the id for the setInterval running the countdown //the id for the setInterval running the countdown
@@ -91,7 +85,7 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> {
style={{top: "11px"}}> style={{top: "11px"}}>
{/* Time left */} {/* Time left */}
{this.timed ? ( {this.props.timed ? (
<span id={"sponsorSkipNoticeTimeLeft" + this.idSuffix} <span id={"sponsorSkipNoticeTimeLeft" + this.idSuffix}
className="sponsorSkipObject sponsorSkipNoticeTimeLeft"> className="sponsorSkipObject sponsorSkipNoticeTimeLeft">
@@ -116,7 +110,7 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> {
//called every second to lower the countdown before hiding the notice //called every second to lower the countdown before hiding the notice
countdown() { countdown() {
if (!this.timed) return; if (!this.props.timed) return;
let countdownTime = this.state.countdownTime - 1; let countdownTime = this.state.countdownTime - 1;
@@ -143,7 +137,7 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> {
} }
pauseCountdown() { pauseCountdown() {
if (!this.timed) return; if (!this.props.timed) return;
//remove setInterval //remove setInterval
clearInterval(this.countdownInterval); clearInterval(this.countdownInterval);
@@ -162,7 +156,7 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> {
} }
startCountdown() { startCountdown() {
if (!this.timed) return; if (!this.props.timed) return;
//if it has already started, don't start it again //if it has already started, don't start it again
if (this.countdownInterval !== null) return; if (this.countdownInterval !== null) return;
@@ -176,7 +170,7 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> {
} }
resetCountdown() { resetCountdown() {
if (!this.timed) return; if (!this.props.timed) return;
this.setState({ this.setState({
countdownTime: this.props.maxCountdownTime(), countdownTime: this.props.maxCountdownTime(),

View File

@@ -87,6 +87,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
<NoticeComponent noticeTitle={this.state.noticeTitle} <NoticeComponent noticeTitle={this.state.noticeTitle}
amountOfPreviousNotices={this.amountOfPreviousNotices} amountOfPreviousNotices={this.amountOfPreviousNotices}
idSuffix={this.idSuffix} idSuffix={this.idSuffix}
timed={true}
maxCountdownTime={this.state.maxCountdownTime} maxCountdownTime={this.state.maxCountdownTime}
ref={this.noticeRef}> ref={this.noticeRef}>