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

View File

@@ -46,8 +46,11 @@ interface SBConfig {
autoHideInfoButton: boolean,
autoSkipOnMusicVideos: boolean,
highlightCategoryUpdate: boolean,
wikiPages: SBMap<string, string>,
colorPalette: SBMap<string, string>
colorPalette: {
red: string,
white: string,
locked: string
}
// What categories should be skipped
categorySelections: CategorySelection[],
@@ -203,24 +206,11 @@ const Config: SBObject = {
option: CategorySkipOption.AutoSkip
}],
wikiPages: new SBMap("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"],
["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"]
]),
colorPalette: {
red: "#780303",
white: "#ffffff",
locked: "#ffc83d"
},
// Preview bar
barTypes: {

View File

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