mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-11 14:07:13 +03:00
Fix inaccurate timer on upcoming notice
This commit is contained in:
@@ -245,7 +245,7 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> {
|
|||||||
id={"skipNoticeTimerText" + this.idSuffix}
|
id={"skipNoticeTimerText" + this.idSuffix}
|
||||||
key="skipNoticeTimerText"
|
key="skipNoticeTimerText"
|
||||||
className={this.state.countdownMode !== CountdownMode.Timer ? "sbhidden" : ""} >
|
className={this.state.countdownMode !== CountdownMode.Timer ? "sbhidden" : ""} >
|
||||||
{chrome.i18n.getMessage("NoticeTimeAfterSkip").replace("{seconds}", this.state.countdownTime.toString())}
|
{chrome.i18n.getMessage("NoticeTimeAfterSkip").replace("{seconds}", Math.ceil(this.state.countdownTime).toString())}
|
||||||
</span>
|
</span>
|
||||||
),(
|
),(
|
||||||
<img
|
<img
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ export interface SkipNoticeProps {
|
|||||||
showKeybindHint?: boolean;
|
showKeybindHint?: boolean;
|
||||||
smaller: boolean;
|
smaller: boolean;
|
||||||
fadeIn: boolean;
|
fadeIn: boolean;
|
||||||
|
maxCountdownTime?: number;
|
||||||
|
|
||||||
componentDidMount?: () => void;
|
componentDidMount?: () => void;
|
||||||
|
|
||||||
@@ -124,7 +125,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
|
|||||||
this.lockedColor = Config.config.colorPalette.locked;
|
this.lockedColor = Config.config.colorPalette.locked;
|
||||||
|
|
||||||
const isMuteSegment = this.segments[0].actionType === ActionType.Mute;
|
const isMuteSegment = this.segments[0].actionType === ActionType.Mute;
|
||||||
const maxCountdownTime = isMuteSegment ? this.getFullDurationCountdown(0) : () => Config.config.skipNoticeDuration;
|
const maxCountdownTime = props.maxCountdownTime ? () => props.maxCountdownTime : (isMuteSegment ? this.getFullDurationCountdown(0) : () => Config.config.skipNoticeDuration);
|
||||||
|
|
||||||
const defaultSkipButtonState = this.props.startReskip ? SkipButtonState.Redo : SkipButtonState.Undo;
|
const defaultSkipButtonState = this.props.startReskip ? SkipButtonState.Redo : SkipButtonState.Undo;
|
||||||
const skipButtonStates = [defaultSkipButtonState, isMuteSegment ? SkipButtonState.Start : defaultSkipButtonState];
|
const skipButtonStates = [defaultSkipButtonState, isMuteSegment ? SkipButtonState.Start : defaultSkipButtonState];
|
||||||
|
|||||||
@@ -806,16 +806,15 @@ async function startSponsorSchedule(includeIntersectingSegments = false, current
|
|||||||
// Show the notice only if the segment hasn't already started
|
// Show the notice only if the segment hasn't already started
|
||||||
if (Config.config.showUpcomingNotice && getCurrentTime() < skippingSegments[0].segment[0]
|
if (Config.config.showUpcomingNotice && getCurrentTime() < skippingSegments[0].segment[0]
|
||||||
&& !sponsorTimesSubmitting?.some((segment) => segment.segment === currentSkip.segment)
|
&& !sponsorTimesSubmitting?.some((segment) => segment.segment === currentSkip.segment)
|
||||||
&& [ActionType.Skip, ActionType.Mute].includes(skippingSegments[0].actionType)) {
|
&& [ActionType.Skip, ActionType.Mute].includes(skippingSegments[0].actionType)
|
||||||
|
&& !getVideo()?.paused) {
|
||||||
const maxPopupTime = 3000;
|
const maxPopupTime = 3000;
|
||||||
const timeUntilPopup = Math.max(0, offsetDelayTime - maxPopupTime);
|
const timeUntilPopup = Math.max(0, offsetDelayTime - maxPopupTime);
|
||||||
const popupTime = Math.min(maxPopupTime, timeUntilPopup);
|
const popupTime = offsetDelayTime - timeUntilPopup;
|
||||||
const autoSkip = shouldAutoSkip(skippingSegments[0]);
|
const autoSkip = shouldAutoSkip(skippingSegments[0]);
|
||||||
|
|
||||||
if (timeUntilPopup > 0) {
|
if (currentUpcomingSchedule) clearTimeout(currentUpcomingSchedule);
|
||||||
if (currentUpcomingSchedule) clearTimeout(currentUpcomingSchedule);
|
currentUpcomingSchedule = setTimeout(createUpcomingNotice, timeUntilPopup, skippingSegments, popupTime, autoSkip);
|
||||||
currentUpcomingSchedule = setTimeout(createUpcomingNotice, timeUntilPopup, skippingSegments, popupTime, autoSkip);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1823,7 +1822,7 @@ function createUpcomingNotice(skippingSegments: SponsorTime[], timeLeft: number,
|
|||||||
}
|
}
|
||||||
|
|
||||||
upcomingNotice?.close();
|
upcomingNotice?.close();
|
||||||
upcomingNotice = new UpcomingNotice(skippingSegments, skipNoticeContentContainer, timeLeft, autoSkip);
|
upcomingNotice = new UpcomingNotice(skippingSegments, skipNoticeContentContainer, timeLeft / 1000, autoSkip);
|
||||||
}
|
}
|
||||||
|
|
||||||
function unskipSponsorTime(segment: SponsorTime, unskipTime: number = null, forceSeek = false) {
|
function unskipSponsorTime(segment: SponsorTime, unskipTime: number = null, forceSeek = false) {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class UpcomingNotice {
|
|||||||
closeListener={() => this.close()}
|
closeListener={() => this.close()}
|
||||||
smaller={true}
|
smaller={true}
|
||||||
fadeIn={true}
|
fadeIn={true}
|
||||||
unskipTime={timeLeft} />
|
maxCountdownTime={timeLeft} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user