Enter unskip with skip notice hidden

This commit is contained in:
Ajay
2022-04-21 21:28:25 -04:00
parent 9bad5ed324
commit c773b4ecd1
3 changed files with 26 additions and 8 deletions

View File

@@ -18,6 +18,7 @@ export interface SkipNoticeProps {
segments: SponsorTime[]; segments: SponsorTime[];
autoSkip: boolean; autoSkip: boolean;
startReskip?: boolean;
// Contains functions and variables from the content script needed by the skip notice // Contains functions and variables from the content script needed by the skip notice
contentContainer: ContentContainer; contentContainer: ContentContainer;
@@ -120,8 +121,10 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
countdownTime: Config.config.skipNoticeDuration, countdownTime: Config.config.skipNoticeDuration,
countdownText: null, countdownText: null,
skipButtonText: this.getUnskipText(), skipButtonText: this.props.startReskip
skipButtonCallback: (index) => this.unskip(index), ? this.getReskipText() : this.getUnskipText(),
skipButtonCallback: this.props.startReskip
? (index) => this.reskip(index) : (index) => this.unskip(index),
showSkipButton: true, showSkipButton: true,
editing: false, editing: false,

View File

@@ -1357,12 +1357,17 @@ function skipToTime({v, skipTime, skippingSegments, openNotice, forceAutoSkip, u
if (openNotice) { if (openNotice) {
//send out the message saying that a sponsor message was skipped //send out the message saying that a sponsor message was skipped
if (!Config.config.dontShowNotice || !autoSkip) { if (!Config.config.dontShowNotice || !autoSkip) {
const newSkipNotice = new SkipNotice(skippingSegments, autoSkip, skipNoticeContentContainer, unskipTime); createSkipNotice(skippingSegments, autoSkip, unskipTime, false);
if (onMobileYouTube || Config.config.skipKeybind == null) newSkipNotice.setShowKeybindHint(false); } else if (autoSkip) {
skipNotices.push(newSkipNotice);
activeSkipKeybindElement?.setShowKeybindHint(false); activeSkipKeybindElement?.setShowKeybindHint(false);
activeSkipKeybindElement = newSkipNotice; activeSkipKeybindElement = {
setShowKeybindHint: () => {}, //eslint-disable-line @typescript-eslint/no-empty-function
toggleSkip: () => {
unskipSponsorTime(skippingSegments[0], unskipTime);
createSkipNotice(skippingSegments, autoSkip, unskipTime, true);
}
};
} }
} }
} }
@@ -1371,6 +1376,15 @@ function skipToTime({v, skipTime, skippingSegments, openNotice, forceAutoSkip, u
if (autoSkip) sendTelemetryAndCount(skippingSegments, skipTime[1] - skipTime[0], true); if (autoSkip) sendTelemetryAndCount(skippingSegments, skipTime[1] - skipTime[0], true);
} }
function createSkipNotice(skippingSegments: SponsorTime[], autoSkip: boolean, unskipTime: number, startReskip: boolean) {
const newSkipNotice = new SkipNotice(skippingSegments, autoSkip, skipNoticeContentContainer, unskipTime, startReskip);
if (onMobileYouTube || Config.config.skipKeybind == null) newSkipNotice.setShowKeybindHint(false);
skipNotices.push(newSkipNotice);
activeSkipKeybindElement?.setShowKeybindHint(false);
activeSkipKeybindElement = newSkipNotice;
}
function unskipSponsorTime(segment: SponsorTime, unskipTime: number = null) { function unskipSponsorTime(segment: SponsorTime, unskipTime: number = null) {
if (segment.actionType === ActionType.Mute) { if (segment.actionType === ActionType.Mute) {
video.muted = false; video.muted = false;

View File

@@ -19,7 +19,7 @@ class SkipNotice {
skipNoticeRef: React.MutableRefObject<SkipNoticeComponent>; skipNoticeRef: React.MutableRefObject<SkipNoticeComponent>;
constructor(segments: SponsorTime[], autoSkip = false, contentContainer: ContentContainer, unskipTime: number = null) { constructor(segments: SponsorTime[], autoSkip = false, contentContainer: ContentContainer, unskipTime: number = null, startReskip = false) {
this.skipNoticeRef = React.createRef(); this.skipNoticeRef = React.createRef();
this.segments = segments; this.segments = segments;
@@ -44,6 +44,7 @@ class SkipNotice {
ReactDOM.render( ReactDOM.render(
<SkipNoticeComponent segments={segments} <SkipNoticeComponent segments={segments}
autoSkip={autoSkip} autoSkip={autoSkip}
startReskip={startReskip}
contentContainer={contentContainer} contentContainer={contentContainer}
ref={this.skipNoticeRef} ref={this.skipNoticeRef}
closeListener={() => this.close()} closeListener={() => this.close()}