Also check license status for submitting chapter

This commit is contained in:
Ajay
2022-09-01 16:44:02 -04:00
parent 212fbb83fe
commit 6631dfdea3
2 changed files with 9 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ import SubmissionNoticeComponent from "./SubmissionNoticeComponent";
import { RectangleTooltip } from "../render/RectangleTooltip";
import SelectorComponent, { SelectorOption } from "./SelectorComponent";
import { GenericUtils } from "../utils/genericUtils";
import { noRefreshFetchingChaptersAllowed } from "../utils/licenseKey";
const utils = new Utils();
@@ -402,7 +403,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
for (const category of (this.props.categoryList ?? CompileConfig.categoryList)) {
// If permission not loaded, treat it like we have permission except chapter
const defaultBlockCategories = ["chapter"];
const permission = Config.config.permissions[category as Category];
const permission = Config.config.permissions[category as Category] && (category !== "chapter" || noRefreshFetchingChaptersAllowed());
if ((defaultBlockCategories.includes(category) || permission !== undefined) && !permission) continue;
elements.push(

View File

@@ -22,6 +22,13 @@ export async function checkLicenseKey(licenseKey: string): Promise<boolean> {
return false
}
/**
* The other one also tried refreshing, so returns a promise
*/
export function noRefreshFetchingChaptersAllowed(): boolean {
return Config.config.payments.chaptersAllowed || CompileConfig["freeChapterAccess"];
}
export async function fetchingChaptersAllowed(): Promise<boolean> {
if (Config.config.payments.freeAccess || CompileConfig["freeChapterAccess"]) {
return true;