Add return types to vip fetching functions

This commit is contained in:
Ajay Ramachandran
2021-10-13 23:34:25 -04:00
parent 45274f5c72
commit 27f5997e5a

View File

@@ -768,7 +768,7 @@ function lookupVipInformation(id: string): void {
}) })
} }
async function updateVipInfo() { async function updateVipInfo(): Promise<boolean> {
const currentTime = Date.now(); const currentTime = Date.now();
const lastUpdate = Config.config.lastIsVipUpdate; const lastUpdate = Config.config.lastIsVipUpdate;
if (currentTime - lastUpdate > 1000 * 60 * 60 * 72) { // 72 hours if (currentTime - lastUpdate > 1000 * 60 * 60 * 72) { // 72 hours
@@ -793,9 +793,9 @@ async function updateVipInfo() {
return Config.config.isVip; return Config.config.isVip;
} }
async function lockedSegmentsLookup() { async function lockedSegmentsLookup(): Promise<void> {
utils.asyncRequestToServer("GET", "/api/segmentInfo", { UUIDs: sponsorTimes?.map((segment) => segment.UUID) }) const response = await utils.asyncRequestToServer("GET", "/api/segmentInfo", { UUIDs: sponsorTimes?.map((segment) => segment.UUID) });
.then((response) => {
if (response.status === 200) { if (response.status === 200) {
for (let i = 0; i < sponsorTimes.length && i < 10; i++) { // Because the api only return 10 segments maximum for (let i = 0; i < sponsorTimes.length && i < 10; i++) { // Because the api only return 10 segments maximum
try { try {
@@ -803,18 +803,16 @@ async function lockedSegmentsLookup() {
} catch (e) { } //eslint-disable-line no-empty } catch (e) { } //eslint-disable-line no-empty
} }
} }
});
} }
async function lockedCategoriesLookup(id: string) { async function lockedCategoriesLookup(id: string): Promise<void> {
utils.asyncRequestToServer("GET", "/api/lockCategories", { videoID: id }) const response = await utils.asyncRequestToServer("GET", "/api/lockCategories", { videoID: id });
.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) {
lockedCategories.push(category); lockedCategories.push(category);
} }
} }
});
} }
function retryFetch(): void { function retryFetch(): void {