Only show skip keybind hint on one notice

This commit is contained in:
Ajay Ramachandran
2021-05-11 00:18:40 -04:00
parent ef7e5d1312
commit 2aaee2c1c4
3 changed files with 15 additions and 3 deletions

View File

@@ -23,7 +23,8 @@ export interface SkipNoticeProps {
// 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;
closeListener: () => void closeListener: () => void;
showKeybindHint?: boolean;
} }
export interface SkipNoticeState { export interface SkipNoticeState {
@@ -44,6 +45,8 @@ export interface SkipNoticeState {
thanksForVotingText?: string; //null until the voting buttons should be hidden thanksForVotingText?: string; //null until the voting buttons should be hidden
actionState?: SkipNoticeAction; actionState?: SkipNoticeAction;
showKeybindHint?: boolean;
} }
class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeState> { class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeState> {
@@ -112,7 +115,9 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
choosingCategory: false, choosingCategory: false,
thanksForVotingText: null, thanksForVotingText: null,
actionState: SkipNoticeAction.None actionState: SkipNoticeAction.None,
showKeybindHint: this.props.showKeybindHint ?? true
} }
if (!this.autoSkip) { if (!this.autoSkip) {
@@ -200,7 +205,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
style={{marginLeft: "4px"}} style={{marginLeft: "4px"}}
onClick={() => this.prepAction(SkipNoticeAction.Unskip)}> onClick={() => this.prepAction(SkipNoticeAction.Unskip)}>
{this.state.unskipText + " (" + Config.config.skipKeybind + ")"} {this.state.unskipText + (this.state.showKeybindHint ? " (" + Config.config.skipKeybind + ")" : "")}
</button> </button>
</td> </td>

View File

@@ -1003,6 +1003,7 @@ function skipToTime(v: HTMLVideoElement, skipTime: number[], skippingSegments: S
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) {
skipNotices.forEach((notice) => notice.setShowKeybindHint(false));
skipNotices.push(new SkipNotice(skippingSegments, autoSkip, skipNoticeContentContainer)); skipNotices.push(new SkipNotice(skippingSegments, autoSkip, skipNoticeContentContainer));
} }
} }

View File

@@ -67,6 +67,12 @@ class SkipNotice {
); );
} }
setShowKeybindHint(value: boolean): void {
this.skipNoticeRef.current.setState({
showKeybindHint: value
});
}
close(): void { close(): void {
ReactDOM.unmountComponentAtNode(this.noticeElement); ReactDOM.unmountComponentAtNode(this.noticeElement);