mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 09:07:45 +01:00
Wait for vip info to be fetched
This commit is contained in:
parent
2bdfd3f39b
commit
45274f5c72
1 changed files with 22 additions and 20 deletions
|
@ -760,13 +760,12 @@ async function sponsorsLookup(id: string, keepOldSubmissions = true) {
|
|||
}
|
||||
|
||||
function lookupVipInformation(id: string): void {
|
||||
updateVipInfo();
|
||||
|
||||
const isVip = Config.config.isVip;
|
||||
if (isVip) {
|
||||
lockedCategoriesLookup(id);
|
||||
lockedSegmentsLookup()
|
||||
}
|
||||
updateVipInfo().then((isVip) => {
|
||||
if (isVip) {
|
||||
lockedCategoriesLookup(id);
|
||||
lockedSegmentsLookup()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function updateVipInfo() {
|
||||
|
@ -775,20 +774,23 @@ async function updateVipInfo() {
|
|||
if (currentTime - lastUpdate > 1000 * 60 * 60 * 72) { // 72 hours
|
||||
Config.config.lastIsVipUpdate = currentTime;
|
||||
|
||||
utils.sendRequestToServer("GET", "/api/isUserVIP?userID=" + Config.config.userID, (response) => {
|
||||
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
|
||||
const response = await utils.asyncRequestToServer("GET", "/api/isUserVIP", { userID: Config.config.userID});
|
||||
|
||||
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() {
|
||||
|
@ -805,7 +807,7 @@ async function lockedSegmentsLookup() {
|
|||
}
|
||||
|
||||
async function lockedCategoriesLookup(id: string) {
|
||||
utils.asyncRequestToServer("GET", "/api/lockCategories?videoID=" + id)
|
||||
utils.asyncRequestToServer("GET", "/api/lockCategories", { videoID: id })
|
||||
.then((response) => {
|
||||
if (response.status === 200 && response.ok) {
|
||||
for (const category of JSON.parse(response.responseText).categories) {
|
||||
|
|
Loading…
Reference in a new issue