mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 13:07:05 +03:00
Only show selected categories when submitting and added a "show more categories" button
This commit is contained in:
@@ -528,5 +528,8 @@
|
|||||||
},
|
},
|
||||||
"bracketNow": {
|
"bracketNow": {
|
||||||
"message": "(Now)"
|
"message": "(Now)"
|
||||||
|
},
|
||||||
|
"moreCategories": {
|
||||||
|
"message": "More Categories"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
className="sponsorTimeCategories"
|
className="sponsorTimeCategories"
|
||||||
defaultValue={sponsorTime.category}
|
defaultValue={sponsorTime.category}
|
||||||
ref={this.categoryOptionRef}
|
ref={this.categoryOptionRef}
|
||||||
onChange={this.saveEditTimes.bind(this)}>
|
onChange={this.categorySelectionChange.bind(this)}>
|
||||||
{this.getCategoryOptions()}
|
{this.getCategoryOptions()}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -190,13 +190,21 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
getCategoryOptions() {
|
getCategoryOptions() {
|
||||||
let elements = [];
|
let elements = [];
|
||||||
|
|
||||||
//TODO: Remove this when testing server is not needed
|
for (const category of Config.config.categorySelections) {
|
||||||
let categoryList = Config.config.testingServer ? CompileConfig.categoryList : ["sponsor"];
|
|
||||||
for (const category of categoryList) {
|
|
||||||
elements.push(
|
elements.push(
|
||||||
<option value={category}
|
<option value={category.name}
|
||||||
key={category}>
|
key={category.name}>
|
||||||
{chrome.i18n.getMessage("category_" + category)}
|
{chrome.i18n.getMessage("category_" + category.name)}
|
||||||
|
</option>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (elements.length < CompileConfig.categoryList.length) {
|
||||||
|
// Add show more button
|
||||||
|
elements.push(
|
||||||
|
<option value={"moreCategories"}
|
||||||
|
key={"moreCategories"}>
|
||||||
|
{chrome.i18n.getMessage("moreCategories")}
|
||||||
</option>
|
</option>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -204,6 +212,20 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
categorySelectionChange(event: React.ChangeEvent<HTMLSelectElement>) {
|
||||||
|
// See if show more categories was pressed
|
||||||
|
if (event.target.value === "moreCategories") {
|
||||||
|
// Open options page
|
||||||
|
chrome.runtime.sendMessage({"message": "openConfig"});
|
||||||
|
|
||||||
|
// Reset option to previous
|
||||||
|
event.target.value = this.props.contentContainer().sponsorTimesSubmitting[this.props.index].category;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.saveEditTimes();
|
||||||
|
}
|
||||||
|
|
||||||
setTimeToNow(index: number) {
|
setTimeToNow(index: number) {
|
||||||
let sponsorTime = this.props.contentContainer().sponsorTimesSubmitting[this.props.index];
|
let sponsorTime = this.props.contentContainer().sponsorTimesSubmitting[this.props.index];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user