feat: autoplay inbound clips

This commit is contained in:
talksik
2026-03-21 17:59:41 -07:00
parent 18f587864f
commit 4a4d213eb6
6 changed files with 122 additions and 7 deletions
+3 -2
View File
@@ -1,9 +1,10 @@
import { useQuery } from "@tanstack/react-query";
import { apiClient } from "@/api/client";
export function useDownloadUrl(objectId: string) {
export function useDownloadUrl(objectId?: string) {
return useQuery({
queryKey: ["download-url", objectId],
queryFn: () => apiClient.getParticleDownloadUrl(objectId),
queryFn: () => apiClient.getParticleDownloadUrl(objectId!),
enabled: !!objectId,
});
}
+2 -4
View File
@@ -106,14 +106,12 @@ export function useLiveLatestChild(path: ParticlePath): UseLiveLatestChildResult
const [latestChild, setLatestChild] = useState<Particle | null>(null);
const [isLoading, setIsLoading] = useState(true);
const collectionPath = useMemo(() => toFirestoreChildrenPath(path), [path]);
useEffect(() => {
setIsLoading(true);
setLatestChild(null);
const unsubscribe = subscribeToLatestChild(
collectionPath,
toFirestoreChildrenPath(path),
(data) => {
setLatestChild(data);
setIsLoading(false);
@@ -124,7 +122,7 @@ export function useLiveLatestChild(path: ParticlePath): UseLiveLatestChildResult
);
return unsubscribe;
}, [collectionPath]);
}, [path]);
return { latestChild, isLoading };
}