feat: fallback for gps error
This commit is contained in:
parent
5632209ace
commit
795a5a3a19
2 changed files with 7 additions and 11 deletions
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue