nits
This commit is contained in:
@@ -260,12 +260,17 @@ function StreamViewInner({ path, streamParticle }: StreamViewProps) {
|
|||||||
|
|
||||||
const { fastPlayback } = usePlaybackKeys({ mediaRef });
|
const { fastPlayback } = usePlaybackKeys({ mediaRef });
|
||||||
|
|
||||||
|
const handleExitNavigate = useCallback(() => {
|
||||||
|
navigate(`/${networkId}`);
|
||||||
|
}, [navigate, networkId]);
|
||||||
|
|
||||||
useStreamNavigationKeys({
|
useStreamNavigationKeys({
|
||||||
next,
|
next,
|
||||||
prev,
|
prev,
|
||||||
currentIndex,
|
currentIndex,
|
||||||
childrenLength: children.length,
|
childrenLength: children.length,
|
||||||
mediaRef,
|
mediaRef,
|
||||||
|
onExit: handleExitNavigate,
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleOpenHuddle = useCallback(() => {
|
const handleOpenHuddle = useCallback(() => {
|
||||||
@@ -326,10 +331,6 @@ function StreamViewInner({ path, streamParticle }: StreamViewProps) {
|
|||||||
// Always show controls when compose is active or exit countdown is visible
|
// Always show controls when compose is active or exit countdown is visible
|
||||||
const controlsVisible = showControls || composeActive || status === 'ended';
|
const controlsVisible = showControls || composeActive || status === 'ended';
|
||||||
|
|
||||||
const handleExitNavigate = useCallback(() => {
|
|
||||||
navigate(`/${networkId}`);
|
|
||||||
}, [navigate, networkId]);
|
|
||||||
|
|
||||||
const exitRemainingMs = useExitCountdown(status, paused, handleExitNavigate);
|
const exitRemainingMs = useExitCountdown(status, paused, handleExitNavigate);
|
||||||
|
|
||||||
// Reset progress when the particle changes.
|
// Reset progress when the particle changes.
|
||||||
@@ -364,6 +365,7 @@ function StreamViewInner({ path, streamParticle }: StreamViewProps) {
|
|||||||
showEscape
|
showEscape
|
||||||
onOpenKeybindings={() => setShowKeybindings(true)}
|
onOpenKeybindings={() => setShowKeybindings(true)}
|
||||||
onOpenHuddle={handleOpenHuddle}
|
onOpenHuddle={handleOpenHuddle}
|
||||||
|
onExit={handleExitNavigate}
|
||||||
/>
|
/>
|
||||||
<ComposeOverlay
|
<ComposeOverlay
|
||||||
networkId={networkId}
|
networkId={networkId}
|
||||||
@@ -508,6 +510,7 @@ function StreamViewInner({ path, streamParticle }: StreamViewProps) {
|
|||||||
exitRemainingMs={exitRemainingMs}
|
exitRemainingMs={exitRemainingMs}
|
||||||
onOpenKeybindings={() => setShowKeybindings(true)}
|
onOpenKeybindings={() => setShowKeybindings(true)}
|
||||||
onOpenHuddle={handleOpenHuddle}
|
onOpenHuddle={handleOpenHuddle}
|
||||||
|
onExit={handleExitNavigate}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<KeybindingsOverlay
|
<KeybindingsOverlay
|
||||||
@@ -531,6 +534,7 @@ function BottomBar({
|
|||||||
exitRemainingMs,
|
exitRemainingMs,
|
||||||
onOpenKeybindings,
|
onOpenKeybindings,
|
||||||
onOpenHuddle,
|
onOpenHuddle,
|
||||||
|
onExit,
|
||||||
}: {
|
}: {
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
total: number;
|
total: number;
|
||||||
@@ -545,6 +549,7 @@ function BottomBar({
|
|||||||
exitRemainingMs: number | null;
|
exitRemainingMs: number | null;
|
||||||
onOpenKeybindings: () => void;
|
onOpenKeybindings: () => void;
|
||||||
onOpenHuddle: () => void;
|
onOpenHuddle: () => void;
|
||||||
|
onExit: () => void;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -586,6 +591,7 @@ function BottomBar({
|
|||||||
showEscape
|
showEscape
|
||||||
onOpenKeybindings={onOpenKeybindings}
|
onOpenKeybindings={onOpenKeybindings}
|
||||||
onOpenHuddle={onOpenHuddle}
|
onOpenHuddle={onOpenHuddle}
|
||||||
|
onExit={onExit}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -597,19 +603,20 @@ function StreamViewControls({
|
|||||||
showEscape,
|
showEscape,
|
||||||
onOpenKeybindings,
|
onOpenKeybindings,
|
||||||
onOpenHuddle,
|
onOpenHuddle,
|
||||||
|
onExit,
|
||||||
}: {
|
}: {
|
||||||
showEscape?: boolean;
|
showEscape?: boolean;
|
||||||
onOpenKeybindings: () => void;
|
onOpenKeybindings: () => void;
|
||||||
onOpenHuddle: () => void;
|
onOpenHuddle: () => void;
|
||||||
|
onExit: () => void;
|
||||||
}) {
|
}) {
|
||||||
const navigate = useNavigate();
|
|
||||||
const requestIntent = useComposeIntentStore((s) => s.request);
|
const requestIntent = useComposeIntentStore((s) => s.request);
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-4 text-sm text-white/50">
|
<div className="flex items-center gap-4 text-sm text-white/50">
|
||||||
{showEscape && (
|
{showEscape && (
|
||||||
<KeyHint
|
<KeyHint
|
||||||
keys="Esc"
|
keys="Esc"
|
||||||
onClick={() => navigate(-1)}
|
onClick={onExit}
|
||||||
title="Back to network (or press Esc)"
|
title="Back to network (or press Esc)"
|
||||||
>
|
>
|
||||||
back
|
back
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { useEffect, type RefObject } from 'react';
|
import { useEffect, type RefObject } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import type { MediaParticleHandle } from '@/features/particles/media-particle-view';
|
import type { MediaParticleHandle } from '@/features/particles/media-particle-view';
|
||||||
import { isTypingTarget } from '@/lib/keyboard';
|
import { isTypingTarget } from '@/lib/keyboard';
|
||||||
|
|
||||||
@@ -11,6 +10,7 @@ interface UseStreamNavigationKeysOptions {
|
|||||||
currentIndex: number;
|
currentIndex: number;
|
||||||
childrenLength: number;
|
childrenLength: number;
|
||||||
mediaRef: RefObject<MediaParticleHandle | null>;
|
mediaRef: RefObject<MediaParticleHandle | null>;
|
||||||
|
onExit: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,9 +23,8 @@ export function useStreamNavigationKeys({
|
|||||||
currentIndex,
|
currentIndex,
|
||||||
childrenLength,
|
childrenLength,
|
||||||
mediaRef,
|
mediaRef,
|
||||||
|
onExit,
|
||||||
}: UseStreamNavigationKeysOptions) {
|
}: UseStreamNavigationKeysOptions) {
|
||||||
const navigate = useNavigate();
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const onKeyDown = (e: KeyboardEvent) => {
|
const onKeyDown = (e: KeyboardEvent) => {
|
||||||
if (isTypingTarget(e)) return;
|
if (isTypingTarget(e)) return;
|
||||||
@@ -53,12 +52,12 @@ export function useStreamNavigationKeys({
|
|||||||
break;
|
break;
|
||||||
case 'Escape':
|
case 'Escape':
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
navigate(-1);
|
onExit();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener('keydown', onKeyDown);
|
window.addEventListener('keydown', onKeyDown);
|
||||||
return () => window.removeEventListener('keydown', onKeyDown);
|
return () => window.removeEventListener('keydown', onKeyDown);
|
||||||
}, [next, prev, currentIndex, childrenLength, mediaRef, navigate]);
|
}, [next, prev, currentIndex, childrenLength, mediaRef, onExit]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user