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

@@ -617,5 +617,11 @@
"readTheGuidelines": { "readTheGuidelines": {
"message": "Read The Guidelines!!", "message": "Read The Guidelines!!",
"description": "Show the first time they submit or if they are \"high risk\"" "description": "Show the first time they submit or if they are \"high risk\""
},
"categoryUpdate1": {
"message": "Categories are here!"
},
"categoryUpdate2": {
"message": "Open the options to skip intros, outros, merch, etc."
} }
} }

View File

@@ -2,7 +2,8 @@ import * as React from "react";
export interface NoticeTextSelectionProps { export interface NoticeTextSelectionProps {
text: string, text: string,
idSuffix: string idSuffix: string,
onClick?: (event: React.MouseEvent) => any
} }
export interface NoticeTextSelectionState { export interface NoticeTextSelectionState {
@@ -16,8 +17,16 @@ class NoticeTextSelectionComponent extends React.Component<NoticeTextSelectionPr
} }
render() { render() {
let style: React.CSSProperties = {};
if (this.props.onClick) {
style.cursor = "pointer";
style.textDecoration = "underline"
}
return ( return (
<p id={"sponsorTimesInfoMessage" + this.props.idSuffix} <p id={"sponsorTimesInfoMessage" + this.props.idSuffix}
onClick={this.props.onClick}
style={style}
className="sponsorTimesInfoMessage"> className="sponsorTimesInfoMessage">
{this.props.text} {this.props.text}
</p> </p>

View File

@@ -31,6 +31,7 @@ export interface SkipNoticeState {
noticeTitle: string; noticeTitle: string;
messages: string[]; messages: string[];
messageOnClick: (event: React.MouseEvent) => any;
countdownTime: number; countdownTime: number;
maxCountdownTime: () => number; maxCountdownTime: () => number;
@@ -105,6 +106,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
this.state = { this.state = {
noticeTitle, noticeTitle,
messages: [], messages: [],
messageOnClick: null,
//the countdown until this notice closes //the countdown until this notice closes
maxCountdownTime: () => 4, maxCountdownTime: () => 4,
@@ -132,6 +134,13 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
this.audio.volume = this.contentContainer().v.volume * 0.1; this.audio.volume = this.contentContainer().v.volume * 0.1;
this.audio.play(); 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() { render() {
@@ -325,6 +334,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
elements.push( elements.push(
<NoticeTextSelectionComponent idSuffix={this.idSuffix} <NoticeTextSelectionComponent idSuffix={this.idSuffix}
text={this.state.messages[i]} text={this.state.messages[i]}
onClick={this.state.messageOnClick}
key={i}> key={i}>
</NoticeTextSelectionComponent> </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[]) { setNoticeInfoMessage(...messages: string[]) {
this.setState({ this.setState({
messages messages

View File

@@ -30,9 +30,10 @@ interface SBConfig {
minDuration: number, minDuration: number,
audioNotificationOnSkip, audioNotificationOnSkip,
checkForUnlistedVideos: boolean, checkForUnlistedVideos: boolean,
mobileUpdateShowCount: number,
testingServer: boolean, testingServer: boolean,
categoryUpdateShowCount: number,
// What categories should be skipped // What categories should be skipped
categorySelections: CategorySelection[], categorySelections: CategorySelection[],
@@ -146,9 +147,10 @@ var Config: SBObject = {
minDuration: 0, minDuration: 0,
audioNotificationOnSkip: false, audioNotificationOnSkip: false,
checkForUnlistedVideos: false, checkForUnlistedVideos: false,
mobileUpdateShowCount: 0,
testingServer: false, testingServer: false,
categoryUpdateShowCount: 0,
categorySelections: [{ categorySelections: [{
name: "sponsor", name: "sponsor",
option: CategorySkipOption.AutoSkip option: CategorySkipOption.AutoSkip
@@ -325,6 +327,11 @@ async function migrateOldFormats() {
chrome.storage.sync.remove("autoUpvote"); chrome.storage.sync.remove("autoUpvote");
} }
// mobileUpdateShowCount removal
if (Config.config["mobileUpdateShowCount"] !== undefined) {
chrome.storage.sync.remove("mobileUpdateShowCount");
}
// Channel URLS // Channel URLS
if (Config.config.whitelistedChannels.length > 0 && if (Config.config.whitelistedChannels.length > 0 &&
(Config.config.whitelistedChannels[0] == null || Config.config.whitelistedChannels[0].includes("/"))) { (Config.config.whitelistedChannels[0] == null || Config.config.whitelistedChannels[0].includes("/"))) {

View File

@@ -955,7 +955,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) {
let skipNotice = new SkipNotice(skippingSegments, autoSkip, skipNoticeContentContainer); new SkipNotice(skippingSegments, autoSkip, skipNoticeContentContainer);
} }
} }

View File

@@ -12,6 +12,8 @@ class SkipNotice {
noticeElement: HTMLDivElement; noticeElement: HTMLDivElement;
skipNoticeRef: React.MutableRefObject<SkipNoticeComponent>;
constructor(segments: SponsorTime[], autoSkip: boolean = false, contentContainer) { constructor(segments: SponsorTime[], autoSkip: boolean = false, contentContainer) {
this.segments = segments; this.segments = segments;
this.autoSkip = autoSkip; this.autoSkip = autoSkip;
@@ -51,6 +53,7 @@ class SkipNotice {
<SkipNoticeComponent segments={segments} <SkipNoticeComponent segments={segments}
autoSkip={autoSkip} autoSkip={autoSkip}
contentContainer={contentContainer} contentContainer={contentContainer}
ref={this.skipNoticeRef}
closeListener={() => this.close()} />, closeListener={() => this.close()} />,
this.noticeElement this.noticeElement
); );