From 0223aa83071d8b4bbdae40ffa91df6d167a7e247 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 13 Apr 2020 12:43:12 -0400 Subject: [PATCH] Only show selected categories when submitting and added a "show more categories" button --- public/_locales/en/messages.json | 3 ++ src/components/SponsorTimeEditComponent.tsx | 36 +++++++++++++++++---- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index 63d35ae4..b50929bd 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -528,5 +528,8 @@ }, "bracketNow": { "message": "(Now)" + }, + "moreCategories": { + "message": "More Categories" } } diff --git a/src/components/SponsorTimeEditComponent.tsx b/src/components/SponsorTimeEditComponent.tsx index 0235179f..d0ae55eb 100644 --- a/src/components/SponsorTimeEditComponent.tsx +++ b/src/components/SponsorTimeEditComponent.tsx @@ -154,7 +154,7 @@ class SponsorTimeEditComponent extends React.Component + onChange={this.categorySelectionChange.bind(this)}> {this.getCategoryOptions()} @@ -190,13 +190,21 @@ class SponsorTimeEditComponent extends React.Component - {chrome.i18n.getMessage("category_" + category)} + + ); + } + + if (elements.length < CompileConfig.categoryList.length) { + // Add show more button + elements.push( + ); } @@ -204,6 +212,20 @@ class SponsorTimeEditComponent extends React.Component) { + // 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];