feat: filter to ephemeral streams and particles
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
/** How far back to look when filtering particles by recency. */
|
||||
export const RECENCY_WINDOW_HOURS = 24;
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user