Added colored text if a category is locked for submitting and changing category

This commit is contained in:
FlorianZahn
2021-10-11 03:49:14 +02:00
parent b927ebbbf7
commit aa8ee02277
4 changed files with 24 additions and 7 deletions

View File

@@ -559,4 +559,8 @@ input::-webkit-inner-spin-button {
border-width: 15px; border-width: 15px;
border-style: solid; border-style: solid;
border-color: rgba(28, 28, 28, 0.7) transparent transparent transparent; border-color: rgba(28, 28, 28, 0.7) transparent transparent transparent;
}
.SponsorBlockLockedColor {
color: #ffc83d;
} }

View File

@@ -557,16 +557,17 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
for (const category of categories) { for (const category of categories) {
elements.push( elements.push(
<option value={category} <option value={category}
key={category}> key={category}
{this.categoryVoteButtonLockIcon(category) + chrome.i18n.getMessage("category_" + category)} className={this.categoryLockedClass(category)}>
{chrome.i18n.getMessage("category_" + category)}
</option> </option>
); );
} }
return elements; return elements;
} }
categoryVoteButtonLockIcon(category: Category): string { categoryLockedClass(category: string): string {
return (this.contentContainer().lockedCategories.includes(category)) ? "🔒" : " "; return(this.props.contentContainer().lockedCategories.includes(category)) ? "SponsorBlockLockedColor" : ""
} }
unskip(index: number): void { unskip(index: number): void {

View File

@@ -23,6 +23,7 @@ export interface SponsorTimeEditProps {
export interface SponsorTimeEditState { export interface SponsorTimeEditState {
editing: boolean; editing: boolean;
sponsorTimeEdits: [string, string]; sponsorTimeEdits: [string, string];
selectedCategory: Category;
} }
const DEFAULT_CATEGORY = "chooseACategory"; const DEFAULT_CATEGORY = "chooseACategory";
@@ -46,7 +47,8 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
this.state = { this.state = {
editing: false, editing: false,
sponsorTimeEdits: [null, null] sponsorTimeEdits: [null, null],
selectedCategory: DEFAULT_CATEGORY as Category
}; };
} }
@@ -251,7 +253,8 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
for (const category of (this.props.categoryList ?? CompileConfig.categoryList)) { for (const category of (this.props.categoryList ?? CompileConfig.categoryList)) {
elements.push( elements.push(
<option value={category} <option value={category}
key={category}> key={category}
className={this.categoryLockedClass(category)}>
{chrome.i18n.getMessage("category_" + category)} {chrome.i18n.getMessage("category_" + category)}
</option> </option>
); );
@@ -260,6 +263,10 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
return elements; return elements;
} }
categoryLockedClass(category: string): string {
return(this.props.contentContainer().lockedCategories.includes(category)) ? "SponsorBlockLockedColor" : ""
}
categorySelectionChange(event: React.ChangeEvent<HTMLSelectElement>): void { categorySelectionChange(event: React.ChangeEvent<HTMLSelectElement>): void {
// See if show more categories was pressed // See if show more categories was pressed
if (event.target.value !== DEFAULT_CATEGORY && !Config.config.categorySelections.some((category) => category.name === event.target.value)) { if (event.target.value !== DEFAULT_CATEGORY && !Config.config.categorySelections.some((category) => category.name === event.target.value)) {

View File

@@ -755,6 +755,11 @@ async function sponsorsLookup(id: string, keepOldSubmissions = true) {
sponsorLookupRetries++; sponsorLookupRetries++;
} }
getVipSegmentsWarnings(id);
}
function getVipSegmentsWarnings(id: string): void {
// Look up locked status if the user is a vip // Look up locked status if the user is a vip
isVipLookup(); isVipLookup();
const isVip = Config.config.isVip; const isVip = Config.config.isVip;
@@ -767,7 +772,7 @@ async function sponsorsLookup(id: string, keepOldSubmissions = true) {
async function isVipLookup() { async function isVipLookup() {
const currentTime = Date.now(); const currentTime = Date.now();
const lastUpdate = Config.config.lastIsVipUpdate; const lastUpdate = Config.config.lastIsVipUpdate;
if (currentTime - lastUpdate > 1000*60*60*24) { //max every 24 hours 1000*60*60*24 if (currentTime - lastUpdate > 1) { //max every 24 hours 1000*60*60*24
Config.config.lastIsVipUpdate = currentTime; Config.config.lastIsVipUpdate = currentTime;
utils.sendRequestToServer("GET", "/api/isUserVIP?userID=" + Config.config.userID, utils.sendRequestToServer("GET", "/api/isUserVIP?userID=" + Config.config.userID,
(response) => { (response) => {