fix: text message not showing attachments upon sending
Closes #154 The sender of the message wouldn't see the children particle since we only fetch the children once. And perhaps the firestore local cache doesn't have the children particles or some other race condition. But now, we fetch the live children. This should anyways use the same number of reads as before since attachments do not change.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import type { Particle } from "@/api/types";
|
import type { Particle } from "@/api/types";
|
||||||
import { useParticleChildren } from "@/hooks/use-particle";
|
import { useLiveParticleChildren } from "@/hooks/use-particle";
|
||||||
import { particlePath, type ParticlePath, parseParticlePath } from "@/lib/particle-path";
|
import { particlePath, type ParticlePath, parseParticlePath } from "@/lib/particle-path";
|
||||||
|
|
||||||
type FileParticle = Extract<Particle, { type: "file" }>;
|
type FileParticle = Extract<Particle, { type: "file" }>;
|
||||||
@@ -18,7 +18,7 @@ export function useParticleAttachments(
|
|||||||
return particlePath(networkId, [...segments, particleId]);
|
return particlePath(networkId, [...segments, particleId]);
|
||||||
}, [streamPath, particleId]);
|
}, [streamPath, particleId]);
|
||||||
|
|
||||||
const { data: children, isLoading } = useParticleChildren(childrenPath);
|
const { children, isLoading } = useLiveParticleChildren(childrenPath);
|
||||||
|
|
||||||
const attachments = useMemo(
|
const attachments = useMemo(
|
||||||
() => (children ?? []).filter((c): c is FileParticle => c.type === "file"),
|
() => (children ?? []).filter((c): c is FileParticle => c.type === "file"),
|
||||||
|
|||||||
Reference in New Issue
Block a user