feat: stream list view and tasks (#279)
* first attempt at stream sidebar, tasks, and events * fix folder from root * cleanup folders and events, and condense changes * cleanup and add toggle for sidebar * cleanup * fix nits
This commit was merged in pull request #279.
This commit is contained in:
@@ -98,12 +98,26 @@ interface UseStreamPlaybackResult {
|
||||
goToParticle: (particleId: string) => void;
|
||||
}
|
||||
|
||||
interface UseStreamPlaybackOptions {
|
||||
/**
|
||||
* When false, newly arriving particles don't pull playback forward after
|
||||
* it has ended (list mode browses; selection must stay put). Default true.
|
||||
*/
|
||||
autoAdvanceOnNew?: boolean;
|
||||
}
|
||||
|
||||
export function useStreamPlayback(
|
||||
streamParticle: Particle & { type: 'stream' },
|
||||
path: ParticlePath,
|
||||
{ autoAdvanceOnNew = true }: UseStreamPlaybackOptions = {},
|
||||
): UseStreamPlaybackResult {
|
||||
const userId = useAuthStore((s) => s.user?.id);
|
||||
const [state, dispatch] = useReducer(playbackReducer, initialState);
|
||||
// Read via ref so the onAdded subscription callback stays stable.
|
||||
const autoAdvanceOnNewRef = useRef(autoAdvanceOnNew);
|
||||
useEffect(() => {
|
||||
autoAdvanceOnNewRef.current = autoAdvanceOnNew;
|
||||
}, [autoAdvanceOnNew]);
|
||||
// Track the stream ID we've initialized for, to reset when navigating between streams
|
||||
const initializedForRef = useRef<string | null>(null);
|
||||
// Latest currentIndex for onParticleRemoved, which is passed into
|
||||
@@ -115,6 +129,7 @@ export function useStreamPlayback(
|
||||
|
||||
// --- Firestore change callbacks ---
|
||||
const onParticleAdded = useCallback((particle: Particle) => {
|
||||
if (!autoAdvanceOnNewRef.current) return;
|
||||
dispatch({ type: 'PARTICLE_ADDED', particleId: particle.id });
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user