diff --git a/src/config/Endpoints.ts b/src/config/Endpoints.ts index 92ec65a..f8033d0 100644 --- a/src/config/Endpoints.ts +++ b/src/config/Endpoints.ts @@ -1,29 +1,22 @@ import { getClient, ResponseType } from '@tauri-apps/api/http' -import { DomainTypes } from './Domain' import type { GamedataEndpoints } from '../tools/rusty' +import { useLocalStorage } from '../hooks/useLocalStorage' + +const { lang } = useLocalStorage() +export const client = await getClient() const PROD_VERSION_REGEX = /(production-[^/]+)/im const STABLE_PROD_VERSION = 'PRODUCTION-202304181630-471782382' - export let PROD_VERSION: string | undefined -const HABBO_URL = (domain: DomainTypes): string => { +const HABBO_URL = (domain: string): string => { return `https://www.habbo.${domain}` } export const HABBO_GORDON_URL = `https://images.habbo.com/gordon/${PROD_VERSION ?? STABLE_PROD_VERSION}` -export const client = await getClient() -await client - .get(`${HABBO_URL(DomainTypes.English)}/gamedata/external_variables/0`, { - responseType: ResponseType.Text - }) - .then(({ data }) => { - return (PROD_VERSION = (data as string).match(PROD_VERSION_REGEX)?.[0]) - }) - -export const GAMEDATA_ENDPOINTS = async (domain: DomainTypes): Promise => { +export const GAMEDATA_ENDPOINTS = async (domain: string): Promise => { return [ { src: `${HABBO_URL(domain)}/gamedata/furnidata_json/0`, @@ -33,6 +26,14 @@ export const GAMEDATA_ENDPOINTS = async (domain: DomainTypes): Promise { +export const ASSETS_ENDPOINTS = (domain: string): string[] => { return [`${HABBO_URL(domain)}/`] } + +await client + .get(`${HABBO_URL(lang())}/gamedata/external_variables/0`, { + responseType: ResponseType.Text + }) + .then(({ data }) => { + return (PROD_VERSION = (data as string).match(PROD_VERSION_REGEX)?.[0]) + })