This commit is contained in:
Logan
2026-04-06 00:22:03 -04:00
parent 2f0597c81b
commit 636a847ee1
9 changed files with 133 additions and 21 deletions
+12 -2
View File
@@ -28,8 +28,13 @@ export function useCalls(limitCount = 50) {
orderBy("started_at", "desc"),
limit(limitCount)
);
const toISO = (v: any): string | null =>
v?.toDate?.()?.toISOString?.() ?? (typeof v === "string" ? v : null);
unsubFirestore = onSnapshot(q, (snap) => {
setCalls(snap.docs.map((d) => d.data() as CallRecord));
setCalls(snap.docs.map((d) => {
const data = d.data();
return { ...data, started_at: toISO(data.started_at) ?? "", ended_at: toISO(data.ended_at) } as CallRecord;
}));
setLoading(false);
}, (err: FirestoreError) => { console.error("useCalls:", err); setError(err.message); setLoading(false); });
});
@@ -58,8 +63,13 @@ export function useActiveCalls() {
}
const q = query(collection(db, "calls"), where("status", "==", "active"));
const toISO = (v: any): string | null =>
v?.toDate?.()?.toISOString?.() ?? (typeof v === "string" ? v : null);
unsubFirestore = onSnapshot(q, (snap) => {
setCalls(snap.docs.map((d) => d.data() as CallRecord));
setCalls(snap.docs.map((d) => {
const data = d.data();
return { ...data, started_at: toISO(data.started_at) ?? "", ended_at: toISO(data.ended_at) } as CallRecord;
}));
}, (err: FirestoreError) => { console.error("useActiveCalls:", err); });
});