mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-10 13:37:04 +03:00
Fix action type and category related items sometimes not updating in submission menu
This commit is contained in:
@@ -26,6 +26,7 @@ export interface SponsorTimeEditState {
|
|||||||
editing: boolean;
|
editing: boolean;
|
||||||
sponsorTimeEdits: [string, string];
|
sponsorTimeEdits: [string, string];
|
||||||
selectedCategory: Category;
|
selectedCategory: Category;
|
||||||
|
selectedActionType: ActionType;
|
||||||
description: string;
|
description: string;
|
||||||
suggestedNames: SelectorOption[];
|
suggestedNames: SelectorOption[];
|
||||||
chapterNameSelectorOpen: boolean;
|
chapterNameSelectorOpen: boolean;
|
||||||
@@ -68,7 +69,8 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
this.state = {
|
this.state = {
|
||||||
editing: false,
|
editing: false,
|
||||||
sponsorTimeEdits: [null, null],
|
sponsorTimeEdits: [null, null],
|
||||||
selectedCategory: DEFAULT_CATEGORY as Category,
|
selectedCategory: sponsorTime.category ?? DEFAULT_CATEGORY as Category,
|
||||||
|
selectedActionType: sponsorTime.actionType,
|
||||||
description: sponsorTime.description || "",
|
description: sponsorTime.description || "",
|
||||||
suggestedNames: [],
|
suggestedNames: [],
|
||||||
chapterNameSelectorOpen: false,
|
chapterNameSelectorOpen: false,
|
||||||
@@ -119,14 +121,14 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
const timeDisplayStyle: React.CSSProperties = {};
|
const timeDisplayStyle: React.CSSProperties = {};
|
||||||
const sponsorTime = this.props.contentContainer().sponsorTimesSubmitting[this.props.index];
|
const sponsorTime = this.props.contentContainer().sponsorTimesSubmitting[this.props.index];
|
||||||
const segment = sponsorTime.segment;
|
const segment = sponsorTime.segment;
|
||||||
if (sponsorTime?.actionType === ActionType.Full) timeDisplayStyle.display = "none";
|
if (this.state.selectedActionType === ActionType.Full) timeDisplayStyle.display = "none";
|
||||||
if (this.state.editing) {
|
if (this.state.editing) {
|
||||||
timeDisplay = (
|
timeDisplay = (
|
||||||
<div id={"sponsorTimesContainer" + this.idSuffix}
|
<div id={"sponsorTimesContainer" + this.idSuffix}
|
||||||
style={timeDisplayStyle}
|
style={timeDisplayStyle}
|
||||||
className="sponsorTimeDisplay">
|
className="sponsorTimeDisplay">
|
||||||
|
|
||||||
{sponsorTime.actionType !== ActionType.Poi ? (
|
{this.state.selectedActionType !== ActionType.Poi ? (
|
||||||
<span id={"startButton" + this.idSuffix}
|
<span id={"startButton" + this.idSuffix}
|
||||||
className="sponsorNowButton"
|
className="sponsorNowButton"
|
||||||
onClick={() => this.setTimeTo(0, 0)}>
|
onClick={() => this.setTimeTo(0, 0)}>
|
||||||
@@ -150,7 +152,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
onWheel={(e) => this.changeTimesWhenScrolling(0, e, sponsorTime)}>
|
onWheel={(e) => this.changeTimesWhenScrolling(0, e, sponsorTime)}>
|
||||||
</input>
|
</input>
|
||||||
|
|
||||||
{sponsorTime.actionType !== ActionType.Poi ? (
|
{this.state.selectedActionType !== ActionType.Poi ? (
|
||||||
<span>
|
<span>
|
||||||
<span>
|
<span>
|
||||||
{" " + chrome.i18n.getMessage("to") + " "}
|
{" " + chrome.i18n.getMessage("to") + " "}
|
||||||
@@ -190,7 +192,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
className="sponsorTimeDisplay"
|
className="sponsorTimeDisplay"
|
||||||
onClick={this.toggleEditTime.bind(this)}>
|
onClick={this.toggleEditTime.bind(this)}>
|
||||||
{getFormattedTime(segment[0], true) +
|
{getFormattedTime(segment[0], true) +
|
||||||
((!isNaN(segment[1]) && sponsorTime.actionType !== ActionType.Poi)
|
((!isNaN(segment[1]) && this.state.selectedActionType !== ActionType.Poi)
|
||||||
? " " + chrome.i18n.getMessage("to") + " " + getFormattedTime(segment[1], true) : "")}
|
? " " + chrome.i18n.getMessage("to") + " " + getFormattedTime(segment[1], true) : "")}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -205,9 +207,9 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
<div style={{position: "relative"}}>
|
<div style={{position: "relative"}}>
|
||||||
<select id={"sponsorTimeCategories" + this.idSuffix}
|
<select id={"sponsorTimeCategories" + this.idSuffix}
|
||||||
className="sponsorTimeEditSelector sponsorTimeCategories"
|
className="sponsorTimeEditSelector sponsorTimeCategories"
|
||||||
defaultValue={sponsorTime.category}
|
|
||||||
ref={this.categoryOptionRef}
|
ref={this.categoryOptionRef}
|
||||||
style={{color: "inherit", backgroundColor: "inherit"}}
|
style={{color: "inherit", backgroundColor: "inherit"}}
|
||||||
|
value={this.state.selectedCategory}
|
||||||
onChange={(event) => this.categorySelectionChange(event)}>
|
onChange={(event) => this.categorySelectionChange(event)}>
|
||||||
{this.getCategoryOptions()}
|
{this.getCategoryOptions()}
|
||||||
</select>
|
</select>
|
||||||
@@ -230,7 +232,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
<div style={{position: "relative"}}>
|
<div style={{position: "relative"}}>
|
||||||
<select id={"sponsorTimeActionTypes" + this.idSuffix}
|
<select id={"sponsorTimeActionTypes" + this.idSuffix}
|
||||||
className="sponsorTimeEditSelector sponsorTimeActionTypes"
|
className="sponsorTimeEditSelector sponsorTimeActionTypes"
|
||||||
defaultValue={sponsorTime.actionType}
|
value={this.state.selectedActionType}
|
||||||
style={{color: "inherit", backgroundColor: "inherit"}}
|
style={{color: "inherit", backgroundColor: "inherit"}}
|
||||||
ref={this.actionTypeOptionRef}
|
ref={this.actionTypeOptionRef}
|
||||||
onChange={(e) => this.actionTypeSelectionChange(e)}>
|
onChange={(e) => this.actionTypeSelectionChange(e)}>
|
||||||
@@ -240,7 +242,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
): ""}
|
): ""}
|
||||||
|
|
||||||
{/* Chapter Name */}
|
{/* Chapter Name */}
|
||||||
{sponsorTime.actionType === ActionType.Chapter ? (
|
{this.state.selectedActionType=== ActionType.Chapter ? (
|
||||||
<div onBlur={() => this.setState({chapterNameSelectorOpen: false})}>
|
<div onBlur={() => this.setState({chapterNameSelectorOpen: false})}>
|
||||||
<input id={"chapterName" + this.idSuffix}
|
<input id={"chapterName" + this.idSuffix}
|
||||||
className="sponsorTimeEdit sponsorTimeEditInput sponsorChapterNameInput"
|
className="sponsorTimeEdit sponsorTimeEditInput sponsorChapterNameInput"
|
||||||
@@ -277,8 +279,8 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
{chrome.i18n.getMessage("delete")}
|
{chrome.i18n.getMessage("delete")}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
{(!isNaN(segment[1]) && ![ActionType.Poi, ActionType.Full].includes(sponsorTime.actionType))
|
{(!isNaN(segment[1]) && ![ActionType.Poi, ActionType.Full].includes(this.state.selectedActionType))
|
||||||
&& sponsorTime.actionType !== ActionType.Chapter ? (
|
&& this.state.selectedActionType !== ActionType.Chapter ? (
|
||||||
<span id={"sponsorTimePreviewButton" + this.idSuffix}
|
<span id={"sponsorTimePreviewButton" + this.idSuffix}
|
||||||
className="sponsorTimeEditButton"
|
className="sponsorTimeEditButton"
|
||||||
onClick={(e) => this.previewTime(e.ctrlKey, e.shiftKey)}>
|
onClick={(e) => this.previewTime(e.ctrlKey, e.shiftKey)}>
|
||||||
@@ -286,7 +288,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
</span>
|
</span>
|
||||||
): ""}
|
): ""}
|
||||||
|
|
||||||
{(!isNaN(segment[1]) && sponsorTime.actionType != ActionType.Full) ? (
|
{(!isNaN(segment[1]) && this.state.selectedActionType != ActionType.Full) ? (
|
||||||
<span id={"sponsorTimeInspectButton" + this.idSuffix}
|
<span id={"sponsorTimeInspectButton" + this.idSuffix}
|
||||||
className="sponsorTimeEditButton"
|
className="sponsorTimeEditButton"
|
||||||
onClick={this.inspectTime.bind(this)}>
|
onClick={this.inspectTime.bind(this)}>
|
||||||
@@ -294,7 +296,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
</span>
|
</span>
|
||||||
): ""}
|
): ""}
|
||||||
|
|
||||||
{(!isNaN(segment[1]) && ![ActionType.Poi, ActionType.Full].includes(sponsorTime.actionType)) ? (
|
{(!isNaN(segment[1]) && ![ActionType.Poi, ActionType.Full].includes(this.state.selectedActionType)) ? (
|
||||||
<span id={"sponsorTimePreviewEndButton" + this.idSuffix}
|
<span id={"sponsorTimePreviewEndButton" + this.idSuffix}
|
||||||
className="sponsorTimeEditButton"
|
className="sponsorTimeEditButton"
|
||||||
onClick={(e) => this.previewTime(e.ctrlKey, e.shiftKey, true)}>
|
onClick={(e) => this.previewTime(e.ctrlKey, e.shiftKey, true)}>
|
||||||
@@ -302,7 +304,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
</span>
|
</span>
|
||||||
): ""}
|
): ""}
|
||||||
|
|
||||||
{(!isNaN(segment[1]) && sponsorTime.actionType != ActionType.Full) ? (
|
{(!isNaN(segment[1]) && this.state.selectedActionType != ActionType.Full) ? (
|
||||||
<span id={"sponsorTimeEditButton" + this.idSuffix}
|
<span id={"sponsorTimeEditButton" + this.idSuffix}
|
||||||
className="sponsorTimeEditButton"
|
className="sponsorTimeEditButton"
|
||||||
onClick={this.toggleEditTime.bind(this)}>
|
onClick={this.toggleEditTime.bind(this)}>
|
||||||
@@ -452,6 +454,9 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
|
|
||||||
categorySelectionChange(event: React.ChangeEvent<HTMLSelectElement>): void {
|
categorySelectionChange(event: React.ChangeEvent<HTMLSelectElement>): void {
|
||||||
const chosenCategory = event.target.value as Category;
|
const chosenCategory = event.target.value as Category;
|
||||||
|
this.setState({
|
||||||
|
selectedCategory: chosenCategory
|
||||||
|
});
|
||||||
|
|
||||||
// See if show more categories was pressed
|
// See if show more categories was pressed
|
||||||
if (chosenCategory !== DEFAULT_CATEGORY && !Config.config.categorySelections.some((category) => category.name === chosenCategory)) {
|
if (chosenCategory !== DEFAULT_CATEGORY && !Config.config.categorySelections.some((category) => category.name === chosenCategory)) {
|
||||||
@@ -479,6 +484,10 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
actionTypeSelectionChange(event: React.ChangeEvent<HTMLSelectElement>): void {
|
actionTypeSelectionChange(event: React.ChangeEvent<HTMLSelectElement>): void {
|
||||||
const sponsorTime = this.props.contentContainer().sponsorTimesSubmitting[this.props.index];
|
const sponsorTime = this.props.contentContainer().sponsorTimesSubmitting[this.props.index];
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
selectedActionType: event.target.value as ActionType
|
||||||
|
});
|
||||||
|
|
||||||
this.handleReplacingLostTimes(sponsorTime.category, event.target.value as ActionType, sponsorTime);
|
this.handleReplacingLostTimes(sponsorTime.category, event.target.value as ActionType, sponsorTime);
|
||||||
this.saveEditTimes();
|
this.saveEditTimes();
|
||||||
}
|
}
|
||||||
@@ -635,6 +644,9 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
|
|
||||||
const actionType = this.getNextActionType(category, this.actionTypeOptionRef?.current?.value as ActionType);
|
const actionType = this.getNextActionType(category, this.actionTypeOptionRef?.current?.value as ActionType);
|
||||||
sponsorTimesSubmitting[this.props.index].actionType = actionType;
|
sponsorTimesSubmitting[this.props.index].actionType = actionType;
|
||||||
|
this.setState({
|
||||||
|
selectedActionType: actionType
|
||||||
|
});
|
||||||
|
|
||||||
const description = actionType === ActionType.Chapter ? this.descriptionOptionRef?.current?.value : "";
|
const description = actionType === ActionType.Chapter ? this.descriptionOptionRef?.current?.value : "";
|
||||||
sponsorTimesSubmitting[this.props.index].description = description;
|
sponsorTimesSubmitting[this.props.index].description = description;
|
||||||
|
|||||||
Reference in New Issue
Block a user