Default to blank category when submitting

This commit is contained in:
Ajay Ramachandran
2020-07-12 20:59:35 -04:00
parent 2d74ce2093
commit 3dc6563048
6 changed files with 29 additions and 5 deletions

View File

@@ -571,6 +571,12 @@
"moreCategories": {
"message": "More Categories"
},
"chooseACategory": {
"message": "Choose a Category"
},
"youMustSelectACategory": {
"message": "You must select a category for all segments you are submitting!"
},
"bracketEnd": {
"message": "(End)"
},

View File

@@ -230,7 +230,12 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
}
getCategoryOptions() {
let elements = [];
let elements = [(
<option value={"chooseACategory"}
key={"chooseACategory"}>
{chrome.i18n.getMessage("chooseACategory")}
</option>
)];
for (const category of Config.config.categorySelections) {
elements.push(

View File

@@ -167,9 +167,16 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
ref.current.saveEditTimes();
}
let sponsorTimesSubmitting = this.props.contentContainer().sponsorTimesSubmitting;
for (const sponsorTime of sponsorTimesSubmitting) {
if (sponsorTime.category === "chooseACategory") {
alert(chrome.i18n.getMessage("youMustSelectACategory"));
return;
}
}
// Check if any non music categories are being used on a music video
if (this.contentContainer().videoInfo?.microformat?.playerMicroformatRenderer?.category === "Music") {
let sponsorTimesSubmitting = this.props.contentContainer().sponsorTimesSubmitting;
for (const sponsorTime of sponsorTimesSubmitting) {
if (!sponsorTime.category.startsWith("music_")) {
if (!confirm(chrome.i18n.getMessage("nonMusicCategoryOnMusic"))) return;

View File

@@ -8,6 +8,7 @@ interface SBConfig {
userID: string,
// sponsorTimes: SBMap<string, SponsorTime[]>,
segmentTimes: SBMap<string, SponsorTime[]>,
defaultCategory: string,
whitelistedChannels: string[],
forceChannelCheck: boolean,
startSponsorKeybind: string,
@@ -40,6 +41,7 @@ interface SBConfig {
// Preview bar
barTypes: {
"preview-chooseACategory": PreviewBarOption,
"sponsor": PreviewBarOption,
"preview-sponsor": PreviewBarOption,
"intro": PreviewBarOption,
@@ -137,6 +139,7 @@ var Config: SBObject = {
defaults: {
userID: null,
segmentTimes: new SBMap("segmentTimes"),
defaultCategory: "chooseACategory",
whitelistedChannels: [],
forceChannelCheck: false,
startSponsorKeybind: ";",
@@ -171,6 +174,10 @@ var Config: SBObject = {
// Preview bar
barTypes: {
"preview-chooseACategory": {
color: "#ffffff",
opacity: "0.7"
},
"sponsor": {
color: "#00d400",
opacity: "0.7"

View File

@@ -1150,8 +1150,7 @@ function startSponsorClicked() {
sponsorTimesSubmitting.push({
segment: [getRealCurrentTime()],
UUID: null,
// Default to sponsor
category: "sponsor"
category: Config.config.defaultCategory
});
}

View File

@@ -338,7 +338,7 @@ async function runThePopup(messageListener?: MessageListener) {
if (sponsorTimes[sponsorTimesIndex] == undefined) {
sponsorTimes[sponsorTimesIndex] = {
segment: [],
category: "sponsor",
category: Config.config.defaultCategory,
UUID: null
};
}