Wait for vip info to be fetched

This commit is contained in:
Ajay Ramachandran
2021-10-13 23:32:52 -04:00
parent 2bdfd3f39b
commit 45274f5c72

View File

@@ -760,13 +760,12 @@ async function sponsorsLookup(id: string, keepOldSubmissions = true) {
} }
function lookupVipInformation(id: string): void { function lookupVipInformation(id: string): void {
updateVipInfo(); updateVipInfo().then((isVip) => {
if (isVip) {
const isVip = Config.config.isVip; lockedCategoriesLookup(id);
if (isVip) { lockedSegmentsLookup()
lockedCategoriesLookup(id); }
lockedSegmentsLookup() })
}
} }
async function updateVipInfo() { async function updateVipInfo() {
@@ -775,20 +774,23 @@ async function updateVipInfo() {
if (currentTime - lastUpdate > 1000 * 60 * 60 * 72) { // 72 hours if (currentTime - lastUpdate > 1000 * 60 * 60 * 72) { // 72 hours
Config.config.lastIsVipUpdate = currentTime; Config.config.lastIsVipUpdate = currentTime;
utils.sendRequestToServer("GET", "/api/isUserVIP?userID=" + Config.config.userID, (response) => { const response = await utils.asyncRequestToServer("GET", "/api/isUserVIP", { userID: Config.config.userID});
if (response.status === 200) {
let isVip = false;
try {
const vipResponse = JSON.parse(response.responseText)?.vip;
if (typeof(vipResponse) === "boolean") {
isVip = vipResponse;
}
} catch (e) { } //eslint-disable-line no-empty
Config.config.isVip = isVip; if (response.ok) {
} let isVip = false;
}); try {
const vipResponse = JSON.parse(response.responseText)?.vip;
if (typeof(vipResponse) === "boolean") {
isVip = vipResponse;
}
} catch (e) { } //eslint-disable-line no-empty
Config.config.isVip = isVip;
return isVip;
}
} }
return Config.config.isVip;
} }
async function lockedSegmentsLookup() { async function lockedSegmentsLookup() {
@@ -805,7 +807,7 @@ async function lockedSegmentsLookup() {
} }
async function lockedCategoriesLookup(id: string) { async function lockedCategoriesLookup(id: string) {
utils.asyncRequestToServer("GET", "/api/lockCategories?videoID=" + id) utils.asyncRequestToServer("GET", "/api/lockCategories", { videoID: id })
.then((response) => { .then((response) => {
if (response.status === 200 && response.ok) { if (response.status === 200 && response.ok) {
for (const category of JSON.parse(response.responseText).categories) { for (const category of JSON.parse(response.responseText).categories) {