Fixed close button on submission confirmation notice

This commit is contained in:
Ajay Ramachandran
2020-04-02 00:44:38 -04:00
parent 8ecea87c52
commit 72c98923f6
3 changed files with 16 additions and 8 deletions

View File

@@ -8,7 +8,10 @@ export interface NoticeProps {
timed?: boolean, timed?: boolean,
idSuffix?: string, idSuffix?: string,
fadeIn?: boolean fadeIn?: boolean,
// Callback for when this is closed
closeListener?: () => void
} }
export interface NoticeState { export interface NoticeState {
@@ -100,7 +103,7 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> {
{/* Close button */} {/* Close button */}
<img src={chrome.extension.getURL("icons/close.png")} <img src={chrome.extension.getURL("icons/close.png")}
className="sponsorSkipObject sponsorSkipNoticeButton sponsorSkipNoticeCloseButton sponsorSkipNoticeRightButton" className="sponsorSkipObject sponsorSkipNoticeButton sponsorSkipNoticeCloseButton sponsorSkipNoticeRightButton"
onClick={this.close.bind(this)}> onClick={() => this.close()}>
</img> </img>
</td> </td>
</tr> </tr>
@@ -181,8 +184,10 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> {
}); });
} }
//close this notice /**
close() { * @param silent If true, the close listener will not be called
*/
close(silent?: boolean) {
//TODO: Change to a listener in the renderer (not component) //TODO: Change to a listener in the renderer (not component)
let notice = document.getElementById("sponsorSkipNotice" + this.idSuffix); let notice = document.getElementById("sponsorSkipNotice" + this.idSuffix);
if (notice != null) { if (notice != null) {
@@ -191,6 +196,8 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> {
//remove setInterval //remove setInterval
if (this.countdownInterval !== null) clearInterval(this.countdownInterval); if (this.countdownInterval !== null) clearInterval(this.countdownInterval);
if (this.props.closeListener && !silent) this.props.closeListener();
} }
changeNoticeTitle(title) { changeNoticeTitle(title) {

View File

@@ -64,7 +64,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
<span id={"nowButton0" + this.idSuffix} <span id={"nowButton0" + this.idSuffix}
className="sponsorNowButton" className="sponsorNowButton"
onClick={(() => this.setTimeToNow.bind(this)(0)).bind(this)}> onClick={() => this.setTimeToNow(0)}>
{chrome.i18n.getMessage("bracketNow")} {chrome.i18n.getMessage("bracketNow")}
</span> </span>
@@ -122,7 +122,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
<span id={"nowButton1" + this.idSuffix} <span id={"nowButton1" + this.idSuffix}
className="sponsorNowButton" className="sponsorNowButton"
onClick={(() => this.setTimeToNow.bind(this)(1)).bind(this)}> onClick={() => this.setTimeToNow(1)}>
{chrome.i18n.getMessage("bracketNow")} {chrome.i18n.getMessage("bracketNow")}
</span> </span>
</div> </div>

View File

@@ -54,7 +54,8 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
return ( return (
<NoticeComponent noticeTitle={this.state.noticeTitle} <NoticeComponent noticeTitle={this.state.noticeTitle}
idSuffix={this.state.idSuffix} idSuffix={this.state.idSuffix}
ref={this.noticeRef}> ref={this.noticeRef}
closeListener={this.cancel.bind(this)}>
{/* Text Boxes */} {/* Text Boxes */}
{this.getMessageBoxes()} {this.getMessageBoxes()}
@@ -127,7 +128,7 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
} }
cancel() { cancel() {
this.noticeRef.current.close(); this.noticeRef.current.close(true);
this.contentContainer().resetSponsorSubmissionNotice(); this.contentContainer().resetSponsorSubmissionNotice();
} }