feat: jump to my newly created particle once created
This commit is contained in:
@@ -86,6 +86,7 @@ interface UseStreamPlaybackResult {
|
||||
next: () => void;
|
||||
prev: () => void;
|
||||
goTo: (index: number) => void;
|
||||
goToParticle: (particleId: string) => void;
|
||||
pause: () => void;
|
||||
resume: () => void;
|
||||
}
|
||||
@@ -212,6 +213,14 @@ export function useStreamPlayback(
|
||||
[children],
|
||||
);
|
||||
|
||||
// NOTE: if particle doesn't exist in children, this will lead to a brief moment where currentParticle is null
|
||||
const goToParticle = useCallback(
|
||||
(particleId: string) => {
|
||||
// Dispatch directly by ID — if the particle isn't in children yet
|
||||
// (e.g. just created), it will resolve once the live query delivers it.
|
||||
dispatch({ type: "SET_PARTICLE", particleId });
|
||||
}, []);
|
||||
|
||||
const pause = useCallback(() => dispatch({ type: "PAUSE" }), []);
|
||||
const resume = useCallback(() => dispatch({ type: "RESUME" }), []);
|
||||
|
||||
@@ -225,6 +234,7 @@ export function useStreamPlayback(
|
||||
next,
|
||||
prev,
|
||||
goTo,
|
||||
goToParticle,
|
||||
pause,
|
||||
resume,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user