diff options
author | Ajay Ramachandran <[email protected]> | 2021-09-01 21:03:32 -0400 |
---|---|---|
committer | Ajay Ramachandran <[email protected]> | 2021-09-01 22:00:48 -0400 |
commit | 60e54ee1294747c3d15a8b17dad0940dbcf1345a (patch) | |
tree | b1708fb73895db00407f3d38c32d1580b38dd02b | |
parent | 4092bf9b0546f13be383937fbc052d3b9c1abdca (diff) | |
download | SponsorBlock-60e54ee1294747c3d15a8b17dad0940dbcf1345a.tar.gz SponsorBlock-60e54ee1294747c3d15a8b17dad0940dbcf1345a.zip |
Hide unmute buttons after segment is finished
-rw-r--r-- | src/components/SkipNoticeComponent.tsx | 16 | ||||
-rw-r--r-- | src/content.ts | 5 | ||||
-rw-r--r-- | src/render/SkipNotice.tsx | 4 |
3 files changed, 23 insertions, 2 deletions
diff --git a/src/components/SkipNoticeComponent.tsx b/src/components/SkipNoticeComponent.tsx index b3ca619b..0900557f 100644 --- a/src/components/SkipNoticeComponent.tsx +++ b/src/components/SkipNoticeComponent.tsx @@ -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: { diff --git a/src/content.ts b/src/content.ts index 45856871..ce87b98e 100644 --- a/src/content.ts +++ b/src/content.ts @@ -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)){ diff --git a/src/render/SkipNotice.tsx b/src/render/SkipNotice.tsx index 24f98369..5113c2da 100644 --- a/src/render/SkipNotice.tsx +++ b/src/render/SkipNotice.tsx @@ -71,6 +71,10 @@ class SkipNotice { toggleSkip(): void { this.skipNoticeRef?.current?.prepAction(SkipNoticeAction.Unskip); } + + unmutedListener(): void { + this.skipNoticeRef?.current?.unmutedListener(); + } } export default SkipNotice;
\ No newline at end of file |