feat: filter to ephemeral streams and particles

This commit is contained in:
talksik
2026-03-21 18:55:03 -07:00
parent 356a166c7e
commit 97b2e7914e
5 changed files with 41 additions and 3 deletions
+2
View File
@@ -0,0 +1,2 @@
/** How far back to look when filtering particles by recency. */
export const RECENCY_WINDOW_HOURS = 24;
+5
View File
@@ -16,6 +16,7 @@ import {
type QueryDocumentSnapshot,
type SnapshotOptions,
type Unsubscribe,
QueryFieldFilterConstraint,
} from "firebase/firestore";
import { firestoreDb } from "@/firebase";
import { isContainerType, ParticleSchema } from "@/api/types";
@@ -134,6 +135,7 @@ export function subscribeToParticleChildren(
orderDirection: "asc" | "desc" = "desc",
onAdded?: (child: Particle) => void,
onRemoved?: (child: Particle, updatedChildren: Particle[]) => void,
whereFilter?: QueryFieldFilterConstraint,
): Unsubscribe {
let q = query(typedCollection(collectionPath), orderBy(orderByField, orderDirection));
if (visibilityScopes.length > 0) {
@@ -142,6 +144,9 @@ export function subscribeToParticleChildren(
where("visible_to", "array-contains-any", visibilityScopes),
);
}
if (whereFilter) {
q = query(q, whereFilter);
}
return onSnapshot(
q,
(snap) => {