From e055a66342585a10c1653adf66f2daa86a1f8666 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Thu, 2 Apr 2020 00:59:11 -0400 Subject: [PATCH] Submission notice now updates when sponsors are added --- src/components/SponsorTimeEditComponent.tsx | 6 +++--- src/content.ts | 4 ++++ src/render/SubmissionNotice.tsx | 11 ++++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/components/SponsorTimeEditComponent.tsx b/src/components/SponsorTimeEditComponent.tsx index a3ad3c3b..2ca8b020 100644 --- a/src/components/SponsorTimeEditComponent.tsx +++ b/src/components/SponsorTimeEditComponent.tsx @@ -133,7 +133,7 @@ class SponsorTimeEditComponent extends React.Component {utils.getFormattedTime(sponsorTime[0], true) + - ((sponsorTime.length >= 1) ? " " + chrome.i18n.getMessage("to") + " " + utils.getFormattedTime(sponsorTime[1], true) : "")} + ((!isNaN(sponsorTime[1])) ? " " + chrome.i18n.getMessage("to") + " " + utils.getFormattedTime(sponsorTime[1], true) : "")} ); } @@ -149,7 +149,7 @@ class SponsorTimeEditComponent extends React.Component - {(sponsorTime.length >= 1) ? ( + {(!isNaN(sponsorTime[1])) ? ( @@ -157,7 +157,7 @@ class SponsorTimeEditComponent extends React.Component ): ""} - {(sponsorTime.length >= 1) ? ( + {(!isNaN(sponsorTime[1])) ? ( diff --git a/src/content.ts b/src/content.ts index c90e6ea3..187bb264 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1105,6 +1105,10 @@ function updateSponsorTimesSubmitting() { // Restart skipping schedule startSponsorSchedule(); + + if (submissionNotice !== null) { + submissionNotice.update(); + } } } }); diff --git a/src/render/SubmissionNotice.tsx b/src/render/SubmissionNotice.tsx index 0c961fcd..bebed3e2 100644 --- a/src/render/SubmissionNotice.tsx +++ b/src/render/SubmissionNotice.tsx @@ -9,7 +9,11 @@ class SubmissionNotice { callback: () => any; + noticeRef: React.MutableRefObject; + constructor(contentContainer: () => any, callback: () => any) { + this.noticeRef = React.createRef(); + this.contentContainer = contentContainer; this.callback = callback; @@ -38,10 +42,15 @@ class SubmissionNotice { ReactDOM.render( , + callback={callback} + ref={this.noticeRef} />, noticeElement ); } + + update() { + this.noticeRef.current.forceUpdate(); + } } export default SubmissionNotice; \ No newline at end of file