Merge branch 'react' into react

This commit is contained in:
Joe Dowd
2020-04-04 18:44:05 +01:00
committed by GitHub
4 changed files with 48 additions and 15 deletions

View File

@@ -510,5 +510,8 @@
}, },
"manualSkip": { "manualSkip": {
"message": "Manual Skip" "message": "Manual Skip"
},
"showOverlay": {
"message": "Show Overlay On Player"
} }
} }

View File

@@ -1,6 +1,7 @@
import * as React from "react"; import * as React from "react";
import Config from "../config" import Config from "../config"
import { CategorySkipOption } from "../types";
export interface CategorySkipOptionsProps { export interface CategorySkipOptionsProps {
category: string; category: string;
@@ -27,7 +28,17 @@ class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsPr
// Set the default opton properly // Set the default opton properly
for (const categorySelection of Config.config.categorySelections) { for (const categorySelection of Config.config.categorySelections) {
if (categorySelection.name === this.props.category) { if (categorySelection.name === this.props.category) {
defaultOption = categorySelection.autoSkip ? "autoSkip" : "manualSkip"; switch (categorySelection.option) {
case CategorySkipOption.ShowOverlay:
defaultOption = "showOverlay";
break;
case CategorySkipOption.ManualSkip:
defaultOption = "manualSkip";
break;
case CategorySkipOption.AutoSkip:
defaultOption = "autoSkip";
break;
}
} }
} }
@@ -54,23 +65,35 @@ class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsPr
} }
skipOptionSelected(event: React.ChangeEvent<HTMLSelectElement>): void { skipOptionSelected(event: React.ChangeEvent<HTMLSelectElement>): void {
switch (event.target.value) { let option: CategorySkipOption;
case "disable":
this.removeCurrentCategorySelection(); this.removeCurrentCategorySelection();
switch (event.target.value) {
case "disable":
return;
case "showOverlay":
option = CategorySkipOption.ShowOverlay;
break; break;
default: case "manualSkip":
this.removeCurrentCategorySelection(); option = CategorySkipOption.ManualSkip;
break;
case "autoSkip":
option = CategorySkipOption.AutoSkip;
break;
}
Config.config.categorySelections.push({ Config.config.categorySelections.push({
name: this.props.category, name: this.props.category,
autoSkip: event.target.value === "autoSkip" option: option
}); });
// Forces the Proxy to send this to the chrome storage API // Forces the Proxy to send this to the chrome storage API
Config.config.categorySelections = Config.config.categorySelections; Config.config.categorySelections = Config.config.categorySelections;
} }
}
/** Removes this category from the config list of category selections */ /** Removes this category from the config list of category selections */
removeCurrentCategorySelection(): void { removeCurrentCategorySelection(): void {
@@ -89,8 +112,8 @@ class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsPr
getCategorySkipOptions(): JSX.Element[] { getCategorySkipOptions(): JSX.Element[] {
let elements: JSX.Element[] = []; let elements: JSX.Element[] = [];
""
let optionNames = ["disable", "manualSkip", "autoSkip"]; let optionNames = ["disable", "showOverlay", "manualSkip", "autoSkip"];
for (const optionName of optionNames) { for (const optionName of optionNames) {
elements.push( elements.push(

View File

@@ -1,5 +1,5 @@
import * as CompileConfig from "../config.json"; import * as CompileConfig from "../config.json";
import { CategorySelection } from "./types"; import { CategorySelection, CategorySkipOption } from "./types";
interface SBConfig { interface SBConfig {
userID: string, userID: string,
@@ -129,7 +129,7 @@ var Config: SBObject = {
mobileUpdateShowCount: 0, mobileUpdateShowCount: 0,
categorySelections: [{ categorySelections: [{
name: "sponsor", name: "sponsor",
autoSkip: true option: CategorySkipOption.AutoSkip
}] }]
}, },
localConfig: null, localConfig: null,

View File

@@ -26,13 +26,20 @@ interface VideoDurationResponse {
duration: number; duration: number;
} }
enum CategorySkipOption {
ShowOverlay,
ManualSkip,
AutoSkip
}
interface CategorySelection { interface CategorySelection {
name: string; name: string;
autoSkip: boolean; option: CategorySkipOption
} }
export { export {
VideoDurationResponse, VideoDurationResponse,
ContentContainer, ContentContainer,
CategorySkipOption,
CategorySelection CategorySelection
}; };