cleanup unnecessary logic and complexity

This commit is contained in:
Arjun Patel
2026-06-13 11:33:12 -07:00
parent 368922a2c1
commit 3175b04d3c
2 changed files with 5 additions and 21 deletions
@@ -213,10 +213,7 @@ function StreamViewInner({ path, streamParticle }: StreamViewProps) {
}); });
const userId = useAuthStore((s) => s.user?.id); const userId = useAuthStore((s) => s.user?.id);
const { mode, toggle: toggleViewMode } = useStreamViewMode( const { mode, toggle: toggleViewMode } = useStreamViewMode();
streamParticle,
userId,
);
const { const {
children, children,
+4 -17
View File
@@ -1,24 +1,11 @@
import { useCallback, useState } from 'react'; import { useCallback, useState } from 'react';
import type { Particle } from '@/api/types';
export type StreamViewMode = 'player' | 'list'; export type StreamViewMode = 'player' | 'list';
// Deprecated: now we always start with player mode export function useStreamViewMode(): {
function decideMode( mode: StreamViewMode;
streamParticle: Particle & { type: 'stream' }, toggle: () => void;
userId: string | undefined, } {
): StreamViewMode {
const marker = userId ? streamParticle.playback_markers?.[userId] : undefined;
const lastChildAt = streamParticle.last_child_created_at;
const caughtUp =
!!marker && !!lastChildAt && lastChildAt.getTime() <= marker.getTime();
return caughtUp ? 'list' : 'player';
}
export function useStreamViewMode(
streamParticle: Particle & { type: 'stream' },
userId: string | undefined,
): { mode: StreamViewMode; toggle: () => void } {
const [mode, setMode] = useState<StreamViewMode>('player'); const [mode, setMode] = useState<StreamViewMode>('player');
const toggle = useCallback(() => { const toggle = useCallback(() => {
setMode((prev) => (prev === 'player' ? 'list' : 'player')); setMode((prev) => (prev === 'player' ? 'list' : 'player'));