diff options
author | Ajay Ramachandran <[email protected]> | 2020-05-16 23:48:41 -0400 |
---|---|---|
committer | Ajay Ramachandran <[email protected]> | 2020-05-16 23:48:41 -0400 |
commit | 99373c3e552adaeef6c0cc4d7bed58ccafabf23c (patch) | |
tree | 2d83592b2890c62a2992d69b5720e78a7d8959aa /src/components/SkipNoticeComponent.tsx | |
parent | dce69b364255ac8ccb9a539757f15c108bbcb055 (diff) | |
download | SponsorBlock-99373c3e552adaeef6c0cc4d7bed58ccafabf23c.tar.gz SponsorBlock-99373c3e552adaeef6c0cc4d7bed58ccafabf23c.zip |
Added category names to notice
Diffstat (limited to 'src/components/SkipNoticeComponent.tsx')
-rw-r--r-- | src/components/SkipNoticeComponent.tsx | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/components/SkipNoticeComponent.tsx b/src/components/SkipNoticeComponent.tsx index e1ecf01c..602b0ffc 100644 --- a/src/components/SkipNoticeComponent.tsx +++ b/src/components/SkipNoticeComponent.tsx @@ -62,10 +62,10 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta this.contentContainer = props.contentContainer; this.audio = null; - let noticeTitle = chrome.i18n.getMessage("noticeTitle"); + let noticeTitle = chrome.i18n.getMessage("category_" + this.getSponsorTime().category) + " " + chrome.i18n.getMessage("skipped"); if (!this.autoSkip) { - noticeTitle = chrome.i18n.getMessage("noticeTitleNotSkipped"); + noticeTitle = chrome.i18n.getMessage("skip") + " " + chrome.i18n.getMessage("category_" + this.getSponsorTime().category) + "?"; } //add notice @@ -103,6 +103,11 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta } } + // Helper method + getSponsorTime() { + return utils.getSponsorTimeFromUUID(this.contentContainer().sponsorTimes, this.UUID); + } + componentDidMount() { if (Config.config.audioNotificationOnSkip && this.audio) { this.audio.volume = this.contentContainer().v.volume * 0.1; @@ -215,7 +220,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta {/* Category Selector */} <select id={"sponsorTimeCategories" + this.idSuffix} className="sponsorTimeCategories" - defaultValue={utils.getSponsorTimeFromUUID(this.props.contentContainer().sponsorTimes, this.props.UUID).category} + defaultValue={this.getSponsorTime().category} ref={this.categoryOptionRef} onChange={this.categorySelectionChange.bind(this)}> @@ -319,7 +324,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta chrome.runtime.sendMessage({"message": "openConfig"}); // Reset option to original - event.target.value = utils.getSponsorTimeFromUUID(this.props.contentContainer().sponsorTimes, this.props.UUID).category; + event.target.value = this.getSponsorTime().category; return; } } @@ -340,7 +345,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta getUnskippedModeInfo(buttonText: string) { let maxCountdownTime = function() { - let sponsorTime = utils.getSponsorTimeFromUUID(this.contentContainer().sponsorTimes, this.UUID); + let sponsorTime = this.getSponsorTime(); let duration = Math.round((sponsorTime.segment[1] - this.contentContainer().v.currentTime) * (1 / this.contentContainer().v.playbackRate)); return Math.max(duration, 4); @@ -387,7 +392,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta this.adjustDownvotingState(false); // Change the sponsor locally - let sponsorTime = utils.getSponsorTimeFromUUID(this.contentContainer().sponsorTimes, this.UUID); + let sponsorTime = this.getSponsorTime(); if (sponsorTime) { if (type === 0) { sponsorTime.hidden = SponsorHideType.Downvoted; |