feat: fallback for gps error

This commit is contained in:
Mat12143 2025-08-02 10:32:51 +02:00
parent 5632209ace
commit 795a5a3a19
2 changed files with 7 additions and 11 deletions

View file

@ -1,11 +1,7 @@
import { get_coords } from "./gps"
import { get_coords, type Coordinates } from "./gps"
import { parseSong, parseSuggestion, type FetchError, type Song, type Suggestion } from "./types"
export const joinRoom = async function(roomId: string): Promise<[FetchError | null, string]> {
let { coords, error } = await get_coords()
if (error != null) return [{ code: 400, message: "Cannot join the room due to GPS error" }, ""]
if (coords == null) return [{ code: 400, message: "Cannot join the room due to GPS error" }, ""]
export const joinRoom = async function (roomId: string, coords: Coordinates): Promise<[FetchError | null, string]> {
let res = await fetch(`/api/join?room=${roomId}&lat=${coords.latitude}&lon=${coords.longitude}`)
if (res.status != 200) {

View file

@ -32,7 +32,7 @@
}
let sugg, queue, index
;[returnError] = await joinRoom(data.roomId, coords.latitude, coords.longitude)
;[returnError] = await joinRoom(data.roomId, coords)
if (returnError) {
return
}