diff --git a/src/components/LandingPage.vue b/src/components/LandingPage.vue index cefab69c8..480378975 100644 --- a/src/components/LandingPage.vue +++ b/src/components/LandingPage.vue @@ -427,9 +427,8 @@ export default defineComponent({ headers: { "Identifier": this.accountHash, "api-key": this.config.wagoApiKey || "", - "User-Agent": `WeakAuras Companion ${__APP_VERSION__})`, + "User-Agent": `WeakAuras Companion ${__APP_VERSION__}`, }, - crossdomain: true, timeout: { request: 30000, }, diff --git a/src/libs/compare-sv-with-wago.ts b/src/libs/compare-sv-with-wago.ts index 082b3fb51..cb593b9c2 100644 --- a/src/libs/compare-sv-with-wago.ts +++ b/src/libs/compare-sv-with-wago.ts @@ -8,7 +8,7 @@ import type { Version, } from "@/stores/config"; import type { Response } from "got"; -import got from "got"; +import got, { Options } from "got"; import luaparse from "luaparse"; import hash from "./hash"; @@ -47,12 +47,12 @@ export async function compareSVwithWago( let fetching = fetchingState; - const getAccountHash = () => { + const getAccountHash = (): string => { if (versionSelected) { const { account } = versionSelected; - return hash.hashFnv32a(account, true); + return hash.hashFnv32a(account, true).toString(); } - return null; + return ""; }; const setFirstAddonInstalledSelected = ( @@ -74,14 +74,13 @@ export async function compareSVwithWago( schedule.id = setTimeout(refreshWago, timeout); }; - const getGotOptions = () => ({ + const gotOptions = new Options({ http2: true, headers: { "Identifier": getAccountHash(), "api-key": config.wagoApiKey || "", - "User-Agent": `WeakAuras Companion ${__APP_VERSION__})`, + "User-Agent": `WeakAuras Companion ${__APP_VERSION__}`, }, - crossdomain: true, timeout: { request: 30000, }, @@ -247,7 +246,7 @@ export async function compareSVwithWago( promisesWagoCallsComplete.push( got .post(config.wagoAPI, { - ...getGotOptions, + ...gotOptions, responseType: "json", json: { ids: fetchAuras, @@ -288,7 +287,7 @@ export async function compareSVwithWago( got( `https://data.wago.io/api/raw/encoded?id=${wagoData._id}`, { - ...getGotOptions, + ...gotOptions, responseType: "text", }, ), @@ -356,10 +355,7 @@ export async function compareSVwithWago( fetching = false; fetchingUpdateCallback(fetching); - const delay = - error.code === "ERR_NON_2XX_3XX_RESPONSE" // Server said nope - ? 1000 * 10 // 10 seconds - : MINUTES_30; + const delay = MINUTES_30; scheduleRefreshWago(delay); return; } diff --git a/src/libs/wago-push-handler.ts b/src/libs/wago-push-handler.ts index e11a66f34..332cd0d37 100644 --- a/src/libs/wago-push-handler.ts +++ b/src/libs/wago-push-handler.ts @@ -1,7 +1,7 @@ import type { StashStore } from "@/stores/auras"; import type { ConfigState, Version } from "@/stores/config"; import type { Response } from "got"; -import got from "got"; +import got, { Options } from "got"; import hash from "./hash"; @@ -19,22 +19,21 @@ export async function wagoPushHandler( ) { const existingAuraIndex = stash.auras.findIndex((aura) => aura.slug === slug); - const getAccountHash = () => { + const getAccountHash = (): string => { if (versionSelected) { const { account } = versionSelected; - return hash.hashFnv32a(account, true); + return hash.hashFnv32a(account, true).toString(); } - return null; + return ""; }; - const getGotOptions = () => ({ + const gotOptions = new Options({ http2: true, headers: { "Identifier": getAccountHash(), "api-key": config.wagoApiKey || "", - "User-Agent": `WeakAuras Companion ${__APP_VERSION__})`, + "User-Agent": `WeakAuras Companion ${__APP_VERSION__}`, }, - crossdomain: true, timeout: { request: 30000, }, @@ -45,7 +44,7 @@ export async function wagoPushHandler( const response: Response = await got( `https://data.wago.io/api/check/?ids=${slug}`, { - ...getGotOptions, + ...gotOptions, responseType: "json", }, ); @@ -73,7 +72,7 @@ export async function wagoPushHandler( const response2 = await got( `https://data.wago.io/api/raw/encoded?id=${wagoData._id}`, { - ...getGotOptions, + ...gotOptions, responseType: "text", }, );