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
@@ -1,4 +1,4 @@
import { useEffect, useMemo, useRef } from "react";
import { useEffect, useMemo, useRef, useState } from "react";
import { useNavigate } from "react-router-dom";
import beepSound from "../../../assets/sound.wav";
import {
@@ -28,6 +28,8 @@ import { Progress } from "@/components/ui/progress";
import { Small } from "@/components/ui/typography";
import type { Particle, StreamProperties } from "@/api/types";
import { useAutoplayStore } from "@/stores/autoplay-store";
import { where, Timestamp } from "firebase/firestore";
import { RECENCY_WINDOW_HOURS } from "@/lib/constants";
function getParticleTypeIcon(particle: Particle): LucideIcon {
switch (particle.type) {
@@ -257,7 +259,23 @@ export function ParticleListView({ path }: ParticleListViewProps) {
const user = useAuthStore((s) => s.user);
const visibilityScopes = useVisibilityScopes(user?.email, networkId);
const { children, isLoading } = useLiveParticleChildren(path, "last_child_created_at", "desc", visibilityScopes);
const [recencyCutoff, setRecencyCutoff] = useState(() => {
const d = new Date();
d.setHours(d.getHours() - RECENCY_WINDOW_HOURS);
return Timestamp.fromDate(d);
});
// Refresh the cutoff every hour so streams don't vanish/appear stale
useEffect(() => {
const interval = setInterval(() => {
const d = new Date();
d.setHours(d.getHours() - RECENCY_WINDOW_HOURS);
setRecencyCutoff(Timestamp.fromDate(d));
}, 60 * 60 * 1000);
return () => clearInterval(interval);
}, []);
const { children, isLoading } = useLiveParticleChildren(path, "last_child_created_at", "desc", visibilityScopes, undefined, undefined, where("last_child_created_at", ">=", recencyCutoff));
const navigate = useNavigate();
const streams = useMemo(