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,
idSuffix?: string,
fadeIn?: boolean
fadeIn?: boolean,
// Callback for when this is closed
closeListener?: () => void
}
export interface NoticeState {
@@ -100,7 +103,7 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> {
{/* Close button */}
<img src={chrome.extension.getURL("icons/close.png")}
className="sponsorSkipObject sponsorSkipNoticeButton sponsorSkipNoticeCloseButton sponsorSkipNoticeRightButton"
onClick={this.close.bind(this)}>
onClick={() => this.close()}>
</img>
</td>
</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)
let notice = document.getElementById("sponsorSkipNotice" + this.idSuffix);
if (notice != null) {
@@ -191,6 +196,8 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> {
//remove setInterval
if (this.countdownInterval !== null) clearInterval(this.countdownInterval);
if (this.props.closeListener && !silent) this.props.closeListener();
}
changeNoticeTitle(title) {

View File

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

View File

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