diff options
Diffstat (limited to 'src/components/SponsorTimeEditComponent.tsx')
-rw-r--r-- | src/components/SponsorTimeEditComponent.tsx | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/src/components/SponsorTimeEditComponent.tsx b/src/components/SponsorTimeEditComponent.tsx index 0235179f..42840405 100644 --- a/src/components/SponsorTimeEditComponent.tsx +++ b/src/components/SponsorTimeEditComponent.tsx @@ -154,7 +154,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo className="sponsorTimeCategories" defaultValue={sponsorTime.category} ref={this.categoryOptionRef} - onChange={this.saveEditTimes.bind(this)}> + onChange={this.categorySelectionChange.bind(this)}> {this.getCategoryOptions()} </select> @@ -190,13 +190,21 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo getCategoryOptions() { let elements = []; - //TODO: Remove this when testing server is not needed - let categoryList = Config.config.testingServer ? CompileConfig.categoryList : ["sponsor"]; - for (const category of categoryList) { + for (const category of Config.config.categorySelections) { elements.push( - <option value={category} - key={category}> - {chrome.i18n.getMessage("category_" + category)} + <option value={category.name} + key={category.name}> + {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> ); } @@ -204,6 +212,20 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo 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) { let sponsorTime = this.props.contentContainer().sponsorTimesSubmitting[this.props.index]; @@ -259,7 +281,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo let sponsorTimes = this.props.contentContainer().sponsorTimesSubmitting; let index = this.props.index; - let skipTime = sponsorTimes[index][0]; + let skipTime = sponsorTimes[index].segment[0]; if (this.state.editing) { // Save edits before previewing |