Limit chapter in UI to those who can submit

This commit is contained in:
Ajay 2022-07-05 13:34:30 -04:00
parent 8114e0dcf7
commit 969b303c59
3 changed files with 7 additions and 1 deletions

View file

@ -406,6 +406,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)) {
if (category === "chapter" && !Config.config.canSubmitChapter) break;
elements.push( elements.push(
<option value={category} <option value={category}
key={category} key={category}

View file

@ -6,6 +6,7 @@ import { keybindEquals } from "./utils/configUtils";
interface SBConfig { interface SBConfig {
userID: string, userID: string,
isVip: boolean, isVip: boolean,
canSubmitChapter: boolean,
/* Contains unsubmitted segments that the user has created. */ /* Contains unsubmitted segments that the user has created. */
unsubmittedSegments: Record<string, SponsorTime[]>, unsubmittedSegments: Record<string, SponsorTime[]>,
defaultCategory: Category, defaultCategory: Category,
@ -130,6 +131,7 @@ const Config: SBObject = {
syncDefaults: { syncDefaults: {
userID: null, userID: null,
isVip: false, isVip: false,
canSubmitChapter: false,
unsubmittedSegments: {}, unsubmittedSegments: {},
defaultCategory: "chooseACategory" as Category, defaultCategory: "chooseACategory" as Category,
renderSegmentsAsChapters: true, renderSegmentsAsChapters: true,

View file

@ -255,7 +255,8 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
PageElements.showNoticeAgain.style.display = "unset"; PageElements.showNoticeAgain.style.display = "unset";
} }
utils.sendRequestToServer("GET", "/api/userInfo?value=userName&value=viewCount&value=minutesSaved&value=vip&userID=" + Config.config.userID, (res) => { utils.sendRequestToServer("GET", "/api/userInfo?value=userName&value=viewCount&value=minutesSaved&value=vip&value=canSubmitChapter&userID="
+ Config.config.userID, (res) => {
if (res.status === 200) { if (res.status === 200) {
const userInfo = JSON.parse(res.responseText); const userInfo = JSON.parse(res.responseText);
PageElements.usernameValue.innerText = userInfo.userName; PageElements.usernameValue.innerText = userInfo.userName;
@ -284,6 +285,7 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
} }
Config.config.isVip = userInfo.vip; Config.config.isVip = userInfo.vip;
Config.config.canSubmitChapter = userInfo.canSubmitChapter;
} }
}); });