mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-11 22:17:21 +03:00
Added category update info on the notice
This commit is contained in:
@@ -2,7 +2,8 @@ import * as React from "react";
|
||||
|
||||
export interface NoticeTextSelectionProps {
|
||||
text: string,
|
||||
idSuffix: string
|
||||
idSuffix: string,
|
||||
onClick?: (event: React.MouseEvent) => any
|
||||
}
|
||||
|
||||
export interface NoticeTextSelectionState {
|
||||
@@ -16,8 +17,16 @@ class NoticeTextSelectionComponent extends React.Component<NoticeTextSelectionPr
|
||||
}
|
||||
|
||||
render() {
|
||||
let style: React.CSSProperties = {};
|
||||
if (this.props.onClick) {
|
||||
style.cursor = "pointer";
|
||||
style.textDecoration = "underline"
|
||||
}
|
||||
|
||||
return (
|
||||
<p id={"sponsorTimesInfoMessage" + this.props.idSuffix}
|
||||
onClick={this.props.onClick}
|
||||
style={style}
|
||||
className="sponsorTimesInfoMessage">
|
||||
{this.props.text}
|
||||
</p>
|
||||
|
||||
@@ -31,6 +31,7 @@ export interface SkipNoticeState {
|
||||
noticeTitle: string;
|
||||
|
||||
messages: string[];
|
||||
messageOnClick: (event: React.MouseEvent) => any;
|
||||
|
||||
countdownTime: number;
|
||||
maxCountdownTime: () => number;
|
||||
@@ -105,6 +106,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
|
||||
this.state = {
|
||||
noticeTitle,
|
||||
messages: [],
|
||||
messageOnClick: null,
|
||||
|
||||
//the countdown until this notice closes
|
||||
maxCountdownTime: () => 4,
|
||||
@@ -132,6 +134,13 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
|
||||
this.audio.volume = this.contentContainer().v.volume * 0.1;
|
||||
this.audio.play();
|
||||
}
|
||||
|
||||
if (Config.config.categoryUpdateShowCount < 3 && Config.config.categorySelections.length <= 1) {
|
||||
this.setNoticeInfoMessageWithOnClick(() => chrome.runtime.sendMessage({"message": "openConfig"})
|
||||
, chrome.i18n.getMessage("categoryUpdate1"), chrome.i18n.getMessage("categoryUpdate2"));
|
||||
|
||||
Config.config.categoryUpdateShowCount = Config.config.categoryUpdateShowCount + 1
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -325,6 +334,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
|
||||
elements.push(
|
||||
<NoticeTextSelectionComponent idSuffix={this.idSuffix}
|
||||
text={this.state.messages[i]}
|
||||
onClick={this.state.messageOnClick}
|
||||
key={i}>
|
||||
</NoticeTextSelectionComponent>
|
||||
)
|
||||
@@ -505,6 +515,13 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
|
||||
}
|
||||
}
|
||||
|
||||
setNoticeInfoMessageWithOnClick(onClick: (event: React.MouseEvent) => any, ...messages: string[]) {
|
||||
this.setState({
|
||||
messages,
|
||||
messageOnClick: (event) => onClick(event)
|
||||
});
|
||||
}
|
||||
|
||||
setNoticeInfoMessage(...messages: string[]) {
|
||||
this.setState({
|
||||
messages
|
||||
|
||||
Reference in New Issue
Block a user