mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-10 13:37:04 +03:00
Hide unmute buttons after segment is finished
This commit is contained in:
@@ -41,6 +41,7 @@ export interface SkipNoticeState {
|
||||
|
||||
skipButtonText?: string;
|
||||
skipButtonCallback?: (index: number) => void;
|
||||
showSkipButton?: boolean;
|
||||
|
||||
downvoting?: boolean;
|
||||
choosingCategory?: boolean;
|
||||
@@ -112,6 +113,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
|
||||
|
||||
skipButtonText: this.getUnskipText(),
|
||||
skipButtonCallback: (index) => this.unskip(index),
|
||||
showSkipButton: true,
|
||||
|
||||
downvoting: false,
|
||||
choosingCategory: false,
|
||||
@@ -296,9 +298,9 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
|
||||
}
|
||||
|
||||
getSkipButton(): JSX.Element {
|
||||
if (this.segments.length > 1
|
||||
if (this.state.showSkipButton && (this.segments.length > 1
|
||||
|| getCategoryActionType(this.segments[0].category) !== CategoryActionType.POI
|
||||
|| this.props.unskipTime) {
|
||||
|| this.props.unskipTime)) {
|
||||
return (
|
||||
<span className="sponsorSkipNoticeUnskipSection">
|
||||
<button id={"sponsorSkipUnskipButton" + this.idSuffix}
|
||||
@@ -559,6 +561,16 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
|
||||
this.props.closeListener();
|
||||
}
|
||||
|
||||
unmutedListener(): void {
|
||||
if (this.props.segments.length === 1
|
||||
&& this.props.segments[0].actionType === ActionType.Mute
|
||||
&& this.contentContainer().v.currentTime >= this.props.segments[0].segment[1]) {
|
||||
this.setState({
|
||||
showSkipButton: false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private getUnskipText(): string {
|
||||
switch (this.props.segments[0].actionType) {
|
||||
case ActionType.Mute: {
|
||||
|
||||
@@ -417,6 +417,11 @@ function startSponsorSchedule(includeIntersectingSegments = false, currentTime?:
|
||||
if (videoMuted && !inMuteSegment(currentTime)) {
|
||||
video.muted = false;
|
||||
videoMuted = false;
|
||||
|
||||
for (const notice of skipNotices) {
|
||||
// So that the notice can hide buttons
|
||||
notice.unmutedListener();
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.config.disableSkipping || channelWhitelisted || (channelIDInfo.status === ChannelIDStatus.Fetching && Config.config.forceChannelCheck)){
|
||||
|
||||
@@ -71,6 +71,10 @@ class SkipNotice {
|
||||
toggleSkip(): void {
|
||||
this.skipNoticeRef?.current?.prepAction(SkipNoticeAction.Unskip);
|
||||
}
|
||||
|
||||
unmutedListener(): void {
|
||||
this.skipNoticeRef?.current?.unmutedListener();
|
||||
}
|
||||
}
|
||||
|
||||
export default SkipNotice;
|
||||
Reference in New Issue
Block a user