Merge branch 'master' of https://github.com/ajayyy/SponsorBlock into chapters

This commit is contained in:
Ajay
2022-02-22 01:34:12 -05:00
3 changed files with 15 additions and 9 deletions

View File

@@ -1,7 +1,7 @@
{ {
"name": "__MSG_fullName__", "name": "__MSG_fullName__",
"short_name": "SponsorBlock", "short_name": "SponsorBlock",
"version": "4.1.3", "version": "4.1.4",
"default_locale": "en", "default_locale": "en",
"description": "__MSG_Description__", "description": "__MSG_Description__",
"homepage_url": "https://sponsor.ajay.app", "homepage_url": "https://sponsor.ajay.app",

View File

@@ -416,21 +416,21 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
} }
const sponsorTime = this.props.contentContainer().sponsorTimesSubmitting[this.props.index]; const sponsorTime = this.props.contentContainer().sponsorTimesSubmitting[this.props.index];
this.handleReplacingLostTimes(chosenCategory, sponsorTime.actionType); this.handleReplacingLostTimes(chosenCategory, sponsorTime.actionType, sponsorTime);
this.saveEditTimes(); this.saveEditTimes();
} }
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.handleReplacingLostTimes(sponsorTime.category, event.target.value as ActionType); this.handleReplacingLostTimes(sponsorTime.category, event.target.value as ActionType, sponsorTime);
this.saveEditTimes(); this.saveEditTimes();
} }
private handleReplacingLostTimes(category: Category, actionType: ActionType): void { private handleReplacingLostTimes(category: Category, actionType: ActionType, segment: SponsorTime): void {
if (CompileConfig.categorySupport[category]?.includes(ActionType.Poi)) { if (CompileConfig.categorySupport[category]?.includes(ActionType.Poi)) {
if (this.previousSkipType !== ActionType.Poi) { if (this.previousSkipType !== ActionType.Poi) {
this.timesBeforeChanging = [null, utils.getFormattedTimeToSeconds(this.state.sponsorTimeEdits[1])]; this.timesBeforeChanging = [null, segment.segment[1]];
} }
this.setTimeTo(1, null); this.setTimeTo(1, null);
@@ -445,12 +445,13 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
} else if (CompileConfig.categorySupport[category]?.length === 1 } else if (CompileConfig.categorySupport[category]?.length === 1
&& CompileConfig.categorySupport[category]?.[0] === ActionType.Full) { && CompileConfig.categorySupport[category]?.[0] === ActionType.Full) {
if (this.previousSkipType !== ActionType.Full) { if (this.previousSkipType !== ActionType.Full) {
this.timesBeforeChanging = [utils.getFormattedTimeToSeconds(this.state.sponsorTimeEdits[0]), utils.getFormattedTimeToSeconds(this.state.sponsorTimeEdits[1])]; this.timesBeforeChanging = [...segment.segment];
} }
this.previousSkipType = ActionType.Full; this.previousSkipType = ActionType.Full;
} else if (CompileConfig.categorySupport[category]?.includes(ActionType.Skip) } else if ((category === "chooseACategory" || (CompileConfig.categorySupport[category]?.includes(ActionType.Skip)
&& ![ActionType.Poi, ActionType.Full].includes(this.getNextActionType(category, actionType)) && this.previousSkipType !== ActionType.Skip) { && ![ActionType.Poi, ActionType.Full].includes(this.getNextActionType(category, actionType))))
&& this.previousSkipType !== ActionType.Skip) {
if (this.timesBeforeChanging[0]) { if (this.timesBeforeChanging[0]) {
this.setTimeTo(0, this.timesBeforeChanging[0]); this.setTimeTo(0, this.timesBeforeChanging[0]);
} }

View File

@@ -767,7 +767,7 @@ async function sponsorsLookup(id: string, keepOldSubmissions = true) {
// Hide all submissions smaller than the minimum duration // Hide all submissions smaller than the minimum duration
if (Config.config.minDuration !== 0) { if (Config.config.minDuration !== 0) {
for (const segment of sponsorTimes) { for (const segment of sponsorTimes) {
const duration = segment[1] - segment[0]; const duration = segment.segment[1] - segment.segment[0];
if (duration > 0 && duration < Config.config.minDuration) { if (duration > 0 && duration < Config.config.minDuration) {
segment.hidden = SponsorHideType.MinimumDuration; segment.hidden = SponsorHideType.MinimumDuration;
} }
@@ -1947,6 +1947,11 @@ async function sendSubmitMessage() {
sponsorTimesSubmitting = []; sponsorTimesSubmitting = [];
updatePreviewBar(); updatePreviewBar();
const fullVideoSegment = sponsorTimes.filter((time) => time.actionType === ActionType.Full)[0];
if (fullVideoSegment) {
categoryPill?.setSegment(fullVideoSegment);
}
} else { } else {
// Show that the upload failed // Show that the upload failed
playerButtons.submit.button.style.animation = "unset"; playerButtons.submit.button.style.animation = "unset";