From 0f4eeb4fe904c21b29e01860afb3fe01ce9d0eea Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sat, 16 Oct 2021 01:36:44 -0400 Subject: [PATCH] Add chapter name option when submitting --- src/components/SponsorTimeEditComponent.tsx | 60 ++++++++++++++------- src/content.ts | 1 + 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/src/components/SponsorTimeEditComponent.tsx b/src/components/SponsorTimeEditComponent.tsx index 3466e78a..0e4f72d6 100644 --- a/src/components/SponsorTimeEditComponent.tsx +++ b/src/components/SponsorTimeEditComponent.tsx @@ -35,6 +35,7 @@ class SponsorTimeEditComponent extends React.Component; actionTypeOptionRef: React.RefObject; + descriptionOptionRef: React.RefObject; configUpdateListener: () => void; @@ -43,9 +44,11 @@ class SponsorTimeEditComponent extends React.Component {this.handleOnChange(0, e, sponsorTime, e.target.value)}} - onWheel={(e) => {this.changeTimesWhenScrolling(0, e, sponsorTime)}}> + onChange={(e) => this.handleOnChange(0, e, sponsorTime, e.target.value)} + onWheel={(e) => this.changeTimesWhenScrolling(0, e, sponsorTime)}> {getCategoryActionType(sponsorTime.category) === CategoryActionType.Skippable ? ( @@ -128,8 +131,8 @@ class SponsorTimeEditComponent extends React.Component {this.handleOnChange(1, e, sponsorTime, e.target.value)}} - onWheel={(e) => {this.changeTimesWhenScrolling(1, e, sponsorTime)}}> + onChange={(e) => this.handleOnChange(1, e, sponsorTime, e.target.value)} + onWheel={(e) => this.changeTimesWhenScrolling(1, e, sponsorTime)}> +
{timeDisplay} @@ -172,7 +175,7 @@ class SponsorTimeEditComponent extends React.Component + onChange={(event) => this.categorySelectionChange(event)}> {this.getCategoryOptions()} @@ -199,6 +202,19 @@ class SponsorTimeEditComponent extends React.Component ): ""} + {/* Chapter Name */} + {sponsorTime.actionType === ActionType.Chapter ? ( +
+ this.saveEditTimes()}> + +
+ ): ""} +
{/* Editing Tools */} @@ -243,14 +259,14 @@ class SponsorTimeEditComponent extends React.Component this.saveEditTimes()); } + changeTimesWhenScrolling(index: number, e: React.WheelEvent, sponsorTime: SponsorTime): void { let step = 0; // shift + ctrl = 1 @@ -273,6 +289,7 @@ class SponsorTimeEditComponent extends React.Component): void { + const chosenCategory = event.target.value as Category; + // See if show more categories was pressed if (event.target.value !== DEFAULT_CATEGORY && !Config.config.categorySelections.some((category) => category.name === event.target.value)) { - const chosenCategory = event.target.value; event.target.value = DEFAULT_CATEGORY; // Alert that they have to enable this category first @@ -338,16 +356,16 @@ class SponsorTimeEditComponent extends React.Component segment.category === event.target.value && i !== this.props.index)) { + .some((segment, i) => segment.category === chosenCategory && i !== this.props.index)) { alert(chrome.i18n.getMessage("poiOnlyOneSegment")); } } - + this.saveEditTimes(); } @@ -387,7 +405,7 @@ class SponsorTimeEditComponent extends React.Component this.saveEditTimes()); } toggleEditTime(): void { @@ -429,9 +447,15 @@ class SponsorTimeEditComponent extends React.Component