fix missing station id on connect & server api call

This commit is contained in:
nocnico
2025-05-13 17:18:46 +02:00
parent 20382994fa
commit 265f7618de
2 changed files with 10 additions and 12 deletions

View File

@@ -1,3 +1,4 @@
import { serverApi } from "helpers/axios";
import {
handleActiveSpeakerChange,
handleDisconnect,
@@ -23,8 +24,8 @@ type TalkState = {
room: Room | null;
};
const getToken = async (roomName: string) => {
const response = await fetch(`/api/livekit/token?roomName=${roomName}`);
const data = await response.json();
const response = await serverApi.get(`/livekit/token?roomName=${roomName}`);
const data = response.data;
return data.token;
};

View File

@@ -22,16 +22,13 @@ export const ConnectionBtn = () => {
});
useEffect(() => {
/* getStations().then((data) => {
setStations(data);
if (data[0]) {
setForm({
...form,
selectedStationId: data[0].id,
});
}
}); */
}, [connection.status, form]);
if (stations && stations.length > 0 && form.selectedStationId === null) {
setForm((prevForm) => ({
...prevForm,
selectedStationId: stations[0]?.id ?? null,
}));
}
}, [stations, form.selectedStationId]);
const session = useSession();
const uid = session.data?.user?.id;