Added category update info on the notice

This commit is contained in:
Ajay Ramachandran
2020-06-07 11:16:24 -04:00
parent 89cc6ed184
commit 9f4fec2a43
6 changed files with 46 additions and 4 deletions

View File

@@ -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>

View File

@@ -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