Show all categories when voting to change category

This commit is contained in:
Ajay Ramachandran
2021-06-25 10:30:49 -04:00
parent 278394e48a
commit 31855f7501

View File

@@ -242,8 +242,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
<select id={"sponsorTimeCategories" + this.idSuffix} <select id={"sponsorTimeCategories" + this.idSuffix}
className="sponsorTimeCategories" className="sponsorTimeCategories"
defaultValue={this.segments[0].category} //Just default to the first segment, as we don't know which they'll choose defaultValue={this.segments[0].category} //Just default to the first segment, as we don't know which they'll choose
ref={this.categoryOptionRef} ref={this.categoryOptionRef}>
onChange={this.categorySelectionChange.bind(this)}>
{this.getCategoryOptions()} {this.getCategoryOptions()}
</select> </select>
@@ -388,21 +387,11 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
getCategoryOptions(): React.ReactElement[] { getCategoryOptions(): React.ReactElement[] {
const elements = []; const elements = [];
for (const category of Config.config.categorySelections) { for (const category of CompileConfig.categoryList) {
elements.push( elements.push(
<option value={category.name} <option value={category}
key={category.name}> key={category}>
{chrome.i18n.getMessage("category_" + category.name)} {chrome.i18n.getMessage("category_" + category)}
</option>
);
}
if (elements.length < CompileConfig.categoryList.length) {
// Add show more button
elements.push(
<option value={"moreCategories"}
key={"moreCategories"}>
{chrome.i18n.getMessage("moreCategories")}
</option> </option>
); );
} }
@@ -410,18 +399,6 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
return elements; return elements;
} }
categorySelectionChange(event: React.ChangeEvent<HTMLSelectElement>): void {
// See if show more categories was pressed
if (event.target.value === "moreCategories") {
// Open options page
chrome.runtime.sendMessage({"message": "openConfig"});
// Reset option to original
event.target.value = this.segments[0].category;
return;
}
}
unskip(index: number): void { unskip(index: number): void {
this.contentContainer().unskipSponsorTime(this.segments[index]); this.contentContainer().unskipSponsorTime(this.segments[index]);