diff options
author | Ajay <[email protected]> | 2024-11-27 13:31:39 -0500 |
---|---|---|
committer | Ajay <[email protected]> | 2024-11-27 13:31:39 -0500 |
commit | b98300596c45191cff096dfc0a0327e7713822bd (patch) | |
tree | 3a44da480bed2244eb1964ba4ea6fb1005a96aba | |
parent | 38e6d5469fc8293fc16ea58015c06f6e7908d855 (diff) | |
download | SponsorBlock-b98300596c45191cff096dfc0a0327e7713822bd.tar.gz SponsorBlock-b98300596c45191cff096dfc0a0327e7713822bd.zip |
Fix inaccurate timer on upcoming notice
-rw-r--r-- | src/components/NoticeComponent.tsx | 2 | ||||
-rw-r--r-- | src/components/SkipNoticeComponent.tsx | 3 | ||||
-rw-r--r-- | src/content.ts | 13 | ||||
-rw-r--r-- | src/render/UpcomingNotice.tsx | 2 |
4 files changed, 10 insertions, 10 deletions
diff --git a/src/components/NoticeComponent.tsx b/src/components/NoticeComponent.tsx index a6dcb768..db0bce77 100644 --- a/src/components/NoticeComponent.tsx +++ b/src/components/NoticeComponent.tsx @@ -245,7 +245,7 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> { id={"skipNoticeTimerText" + this.idSuffix} key="skipNoticeTimerText" 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> ),( <img diff --git a/src/components/SkipNoticeComponent.tsx b/src/components/SkipNoticeComponent.tsx index 73612d2a..188890e4 100644 --- a/src/components/SkipNoticeComponent.tsx +++ b/src/components/SkipNoticeComponent.tsx @@ -36,6 +36,7 @@ export interface SkipNoticeProps { showKeybindHint?: boolean; smaller: boolean; fadeIn: boolean; + maxCountdownTime?: number; componentDidMount?: () => void; @@ -124,7 +125,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta this.lockedColor = Config.config.colorPalette.locked; 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 skipButtonStates = [defaultSkipButtonState, isMuteSegment ? SkipButtonState.Start : defaultSkipButtonState]; diff --git a/src/content.ts b/src/content.ts index 6b7982f1..9fcf3381 100644 --- a/src/content.ts +++ b/src/content.ts @@ -806,16 +806,15 @@ async function startSponsorSchedule(includeIntersectingSegments = false, current // Show the notice only if the segment hasn't already started if (Config.config.showUpcomingNotice && getCurrentTime() < skippingSegments[0].segment[0] && !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 timeUntilPopup = Math.max(0, offsetDelayTime - maxPopupTime); - const popupTime = Math.min(maxPopupTime, timeUntilPopup); + const popupTime = offsetDelayTime - timeUntilPopup; const autoSkip = shouldAutoSkip(skippingSegments[0]); - if (timeUntilPopup > 0) { - if (currentUpcomingSchedule) clearTimeout(currentUpcomingSchedule); - currentUpcomingSchedule = setTimeout(createUpcomingNotice, timeUntilPopup, skippingSegments, popupTime, autoSkip); - } + if (currentUpcomingSchedule) clearTimeout(currentUpcomingSchedule); + currentUpcomingSchedule = setTimeout(createUpcomingNotice, timeUntilPopup, skippingSegments, popupTime, autoSkip); } } } @@ -1823,7 +1822,7 @@ function createUpcomingNotice(skippingSegments: SponsorTime[], timeLeft: number, } 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) { diff --git a/src/render/UpcomingNotice.tsx b/src/render/UpcomingNotice.tsx index 3b8e4f90..b3380ce1 100644 --- a/src/render/UpcomingNotice.tsx +++ b/src/render/UpcomingNotice.tsx @@ -41,7 +41,7 @@ class UpcomingNotice { closeListener={() => this.close()} smaller={true} fadeIn={true} - unskipTime={timeLeft} /> + maxCountdownTime={timeLeft} /> ); } |