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
+10 -1
View File
@@ -1,9 +1,11 @@
import { useCallback, useEffect, useEffectEvent, useMemo, useReducer, useRef } from "react";
import { useCallback, useEffect, useEffectEvent, useMemo, useReducer, useRef, useState } from "react";
import { useAuthStore } from "@/stores/auth-store";
import type { Particle } from "@/api/types";
import { useLiveParticleChildren } from "@/hooks/use-particle";
import { toFirestoreDocPath, type ParticlePath } from "@/lib/particle-path";
import { updateStreamPlaybackMarker } from "@/lib/firestore-particles";
import { where, Timestamp } from "firebase/firestore";
import { RECENCY_WINDOW_HOURS } from "@/lib/constants";
// --- Playback reducer (ID-based) ---
@@ -112,8 +114,15 @@ export function useStreamPlayback(
});
});
const [recencyCutoff] = useState(() => {
const d = new Date();
d.setHours(d.getHours() - RECENCY_WINDOW_HOURS);
return Timestamp.fromDate(d);
});
const { children } = useLiveParticleChildren(
path, "created_at", "asc", undefined, onParticleAdded, onParticleRemoved,
where("created_at", ">=", recencyCutoff),
);
// Derive current index and particle from ID