Move config values and close notice

This commit is contained in:
Ajay Ramachandran
2021-10-13 23:14:51 -04:00
parent 93e440385f
commit ff5fa4c724
4 changed files with 35 additions and 25 deletions

View File

@@ -12,5 +12,17 @@
"preview": ["skip"], "preview": ["skip"],
"music_offtopic": ["skip"], "music_offtopic": ["skip"],
"poi_highlight": ["skip"] "poi_highlight": ["skip"]
},
"wikiLinks": {
"sponsor": "https://wiki.sponsor.ajay.app/w/Sponsor",
"selfpromo": "https://wiki.sponsor.ajay.app/w/Unpaid/Self_Promotion",
"interaction": "https://wiki.sponsor.ajay.app/w/Interaction_Reminder_(Subscribe)",
"intro": "https://wiki.sponsor.ajay.app/w/Intermission/Intro_Animation",
"outro": "https://wiki.sponsor.ajay.app/w/Endcards/Credits",
"preview": "https://wiki.sponsor.ajay.app/w/Preview/Recap",
"music_offtopic": "https://wiki.sponsor.ajay.app/w/Music:_Non-Music_Section",
"poi_highlight": "https://wiki.sponsor.ajay.app/w/Highlight",
"guidelines": "https://wiki.sponsor.ajay.app/w/Guidelines",
"mute": "https://wiki.sponsor.ajay.app/w/Mute_Segment"
} }
} }

View File

@@ -116,9 +116,9 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
} }
this.idSuffix += this.amountOfPreviousNotices; this.idSuffix += this.amountOfPreviousNotices;
this.selectedColor = Config.config.colorPalette.get("SponsorBlockRed"); this.selectedColor = Config.config.colorPalette.red;
this.unselectedColor = Config.config.colorPalette.get("SponsorBlockWhite"); this.unselectedColor = Config.config.colorPalette.white;
this.lockedColor = Config.config.colorPalette.get("SponsorBlockLocked"); this.lockedColor = Config.config.colorPalette.locked;
// Setup state // Setup state
this.state = { this.state = {
@@ -627,26 +627,32 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
afterVote(segment: SponsorTime, type: number, category: Category): void { afterVote(segment: SponsorTime, type: number, category: Category): void {
const index = utils.getSponsorIndexFromUUID(this.segments, segment.UUID); const index = utils.getSponsorIndexFromUUID(this.segments, segment.UUID);
const wikiLinkText = Config.config.wikiPages.get(segment.category); const wikiLinkText = CompileConfig.wikiLinks[segment.category];
switch (type) { switch (type) {
case 0: case 0:
this.setNoticeInfoMessageWithOnClick(() => window.open(wikiLinkText), chrome.i18n.getMessage("OpenCategoryWikiPage")); this.setNoticeInfoMessageWithOnClick(() => window.open(wikiLinkText), chrome.i18n.getMessage("OpenCategoryWikiPage"));
this.setState({ this.setState({
voted: utils.replaceArrayElement(this.state.voted, SkipNoticeAction.Downvote, index) voted: utils.replaceArrayElement(this.state.voted, SkipNoticeAction.Downvote, index)
}); });
break; break;
case 1: case 1:
this.setState({ this.setState({
voted: utils.replaceArrayElement(this.state.voted, SkipNoticeAction.Upvote, index) voted: utils.replaceArrayElement(this.state.voted, SkipNoticeAction.Upvote, index)
}); });
break; break;
case 20: case 20:
this.setState({ this.setState({
voted: utils.replaceArrayElement(this.state.voted, SkipNoticeAction.None, index) voted: utils.replaceArrayElement(this.state.voted, SkipNoticeAction.None, index)
}); });
break; break;
} }
this.addVoteButtonInfo(chrome.i18n.getMessage("voted")); this.addVoteButtonInfo(chrome.i18n.getMessage("voted"));
// Change the sponsor locally // Change the sponsor locally
if (segment) { if (segment) {
if (type === 0) { if (type === 0) {
@@ -657,6 +663,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
} else if (type === 1) { } else if (type === 1) {
segment.hidden = SponsorHideType.Visible; segment.hidden = SponsorHideType.Visible;
} }
this.contentContainer().updatePreviewBar(); this.contentContainer().updatePreviewBar();
} }
} }

View File

@@ -46,8 +46,11 @@ interface SBConfig {
autoHideInfoButton: boolean, autoHideInfoButton: boolean,
autoSkipOnMusicVideos: boolean, autoSkipOnMusicVideos: boolean,
highlightCategoryUpdate: boolean, highlightCategoryUpdate: boolean,
wikiPages: SBMap<string, string>, colorPalette: {
colorPalette: SBMap<string, string> red: string,
white: string,
locked: string
}
// What categories should be skipped // What categories should be skipped
categorySelections: CategorySelection[], categorySelections: CategorySelection[],
@@ -203,24 +206,11 @@ const Config: SBObject = {
option: CategorySkipOption.AutoSkip option: CategorySkipOption.AutoSkip
}], }],
wikiPages: new SBMap("wikiLinks", [ colorPalette: {
["sponsor", "https://wiki.sponsor.ajay.app/w/Sponsor"], red: "#780303",
["selfpromo", "https://wiki.sponsor.ajay.app/w/Unpaid/Self_Promotion"], white: "#ffffff",
["interaction", "https://wiki.sponsor.ajay.app/w/Interaction_Reminder_(Subscribe)"], locked: "#ffc83d"
["intro", "https://wiki.sponsor.ajay.app/w/Intermission/Intro_Animation"], },
["outro", "https://wiki.sponsor.ajay.app/w/Endcards/Credits"],
["preview", "https://wiki.sponsor.ajay.app/w/Preview/Recap"],
["music_offtopic", "https://wiki.sponsor.ajay.app/w/Music:_Non-Music_Section"],
["highlight_poi", "https://wiki.sponsor.ajay.app/w/Highlight"],
["guidelines", "https://wiki.sponsor.ajay.app/w/Guidelines"],
["mute", "https://wiki.sponsor.ajay.app/w/Mute_Segment"],
]),
colorPalette: new SBMap("colorPalette", [
["SponsorBlockRed", "#780303"],
["SponsorBlockWhite", "#ffffff"],
["SponsorBlockLocked", "#ffc83d"]
]),
// Preview bar // Preview bar
barTypes: { barTypes: {

View File

@@ -1746,7 +1746,8 @@ function resetSponsorSubmissionNotice() {
function submitSponsorTimes() { function submitSponsorTimes() {
if (submissionNotice !== null){ if (submissionNotice !== null){
submissionNotice.noticeElement.style.display = (submissionNotice.noticeElement.style.display === "none") ? null : "none"; submissionNotice.close();
submissionNotice = null;
return; return;
} }