mirror of
https://github.com/p-stream/p-stream.git
synced 2026-05-10 20:00:54 +00:00
add backup loc checker
This commit is contained in:
parent
18c9e65711
commit
19daeda170
1 changed files with 16 additions and 0 deletions
|
|
@ -108,6 +108,22 @@ export async function detectRegion(): Promise<Region> {
|
||||||
typeof data.latitude !== "number" ||
|
typeof data.latitude !== "number" ||
|
||||||
typeof data.longitude !== "number"
|
typeof data.longitude !== "number"
|
||||||
) {
|
) {
|
||||||
|
const backupResponse = await fetch("https://ipinfo.io/json");
|
||||||
|
const backupData = await backupResponse.json();
|
||||||
|
|
||||||
|
if (backupData.loc) {
|
||||||
|
const [latitude, longitude] = backupData.loc.split(",").map(Number);
|
||||||
|
const detectedRegion = determineRegion({
|
||||||
|
latitude,
|
||||||
|
longitude,
|
||||||
|
country_code: backupData.country,
|
||||||
|
});
|
||||||
|
if (!store.userPicked) {
|
||||||
|
store.setRegion(detectedRegion);
|
||||||
|
}
|
||||||
|
return detectedRegion;
|
||||||
|
}
|
||||||
|
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue