mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 01:01:55 +01:00
Refactored inspectTime into previewTime
This commit is contained in:
parent
c8c141f5c9
commit
951515873b
1 changed files with 10 additions and 15 deletions
|
@ -291,7 +291,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
||||||
{(!isNaN(segment[1]) && sponsorTime.actionType != ActionType.Full) ? (
|
{(!isNaN(segment[1]) && sponsorTime.actionType != ActionType.Full) ? (
|
||||||
<span id={"sponsorTimeInspectButton" + this.idSuffix}
|
<span id={"sponsorTimeInspectButton" + this.idSuffix}
|
||||||
className="sponsorTimeEditButton"
|
className="sponsorTimeEditButton"
|
||||||
onClick={this.inspectTime.bind(this)}>
|
onClick={(e) => this.previewTime(e.ctrlKey, e.shiftKey, true, false)}>
|
||||||
{chrome.i18n.getMessage("inspect")}
|
{chrome.i18n.getMessage("inspect")}
|
||||||
</span>
|
</span>
|
||||||
): ""}
|
): ""}
|
||||||
|
@ -299,7 +299,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
||||||
{(!isNaN(segment[1]) && ![ActionType.Poi, ActionType.Full].includes(sponsorTime.actionType)) ? (
|
{(!isNaN(segment[1]) && ![ActionType.Poi, ActionType.Full].includes(sponsorTime.actionType)) ? (
|
||||||
<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, false, true)}>
|
||||||
{chrome.i18n.getMessage("End")}
|
{chrome.i18n.getMessage("End")}
|
||||||
</span>
|
</span>
|
||||||
): ""}
|
): ""}
|
||||||
|
@ -637,29 +637,24 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
||||||
: CompileConfig.categorySupport[category]?.[0] ?? ActionType.Skip
|
: CompileConfig.categorySupport[category]?.[0] ?? ActionType.Skip
|
||||||
}
|
}
|
||||||
|
|
||||||
previewTime(ctrlPressed = false, shiftPressed = false, skipToEndTime = false): void {
|
previewTime(ctrlPressed = false, shiftPressed = false, skipToStartTime = false, skipToEndTime = false): void {
|
||||||
const sponsorTimes = this.props.contentContainer().sponsorTimesSubmitting;
|
const sponsorTimes = this.props.contentContainer().sponsorTimesSubmitting;
|
||||||
const index = this.props.index;
|
const index = this.props.index;
|
||||||
let seekTime = 2;
|
let seekTime = 2;
|
||||||
if (ctrlPressed) seekTime = 0.5;
|
if (ctrlPressed) seekTime = 0.5;
|
||||||
if (shiftPressed) seekTime = 0.25;
|
if (shiftPressed) seekTime = 0.25;
|
||||||
|
|
||||||
|
seekTime *= this.props.contentContainer().v.playbackRate;
|
||||||
|
|
||||||
|
if (skipToStartTime) seekTime = -0.0001;
|
||||||
|
|
||||||
const startTime = sponsorTimes[index].segment[0];
|
const startTime = sponsorTimes[index].segment[0];
|
||||||
const endTime = sponsorTimes[index].segment[1];
|
const endTime = sponsorTimes[index].segment[1];
|
||||||
|
|
||||||
// If segment starts at 0:00, start playback at the end of the segment
|
// If segment starts at 0:00, start playback at the end of the segment
|
||||||
const skipTime = (startTime === 0 || skipToEndTime) ? endTime : (startTime - (seekTime * this.props.contentContainer().v.playbackRate));
|
const skipTime = ((startTime === 0 && !skipToStartTime) || skipToEndTime) ? endTime : (startTime - seekTime);
|
||||||
|
|
||||||
this.props.contentContainer().previewTime(skipTime, !skipToEndTime);
|
this.props.contentContainer().previewTime(skipTime, !(skipToStartTime || skipToEndTime));
|
||||||
}
|
|
||||||
|
|
||||||
inspectTime(): void {
|
|
||||||
const sponsorTimes = this.props.contentContainer().sponsorTimesSubmitting;
|
|
||||||
const index = this.props.index;
|
|
||||||
|
|
||||||
const skipTime = sponsorTimes[index].segment[0];
|
|
||||||
|
|
||||||
this.props.contentContainer().previewTime(skipTime + 0.0001, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteTime(): void {
|
deleteTime(): void {
|
||||||
|
|
Loading…
Reference in a new issue