refactor: rename playback suspender
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
|||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useDownloadUrl } from "@/hooks/use-download-url";
|
import { useDownloadUrl } from "@/hooks/use-download-url";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { usePlaybackStore } from "@/stores/playback-store";
|
import { usePlaybackSuspenderStore } from "@/stores/playback-suspender-store";
|
||||||
|
|
||||||
export interface AttachmentItem {
|
export interface AttachmentItem {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -114,7 +114,7 @@ export function AttachmentLightbox({
|
|||||||
// Suspend stream playback while the lightbox is open.
|
// Suspend stream playback while the lightbox is open.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isOpen) return;
|
if (!isOpen) return;
|
||||||
const { suspend, release } = usePlaybackStore.getState();
|
const { suspend, release } = usePlaybackSuspenderStore.getState();
|
||||||
suspend();
|
suspend();
|
||||||
return release;
|
return release;
|
||||||
}, [isOpen]);
|
}, [isOpen]);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import { StreamPresenceProvider, useStreamPresence, useStreamComposing, useStrea
|
|||||||
import { ComposingIndicator } from "@/components/composing-indicator";
|
import { ComposingIndicator } from "@/components/composing-indicator";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { useMount } from "react-use";
|
import { useMount } from "react-use";
|
||||||
import { usePlaybackStore } from "@/stores/playback-store";
|
import { usePlaybackSuspenderStore } from "@/stores/playback-suspender-store";
|
||||||
|
|
||||||
function getReactions(particle: Particle): Record<string, string[]> | undefined {
|
function getReactions(particle: Particle): Record<string, string[]> | undefined {
|
||||||
if (isParticleDeleted(particle)) return undefined;
|
if (isParticleDeleted(particle)) return undefined;
|
||||||
@@ -193,7 +193,7 @@ function StreamViewInner({ path, streamParticle }: StreamViewProps) {
|
|||||||
|
|
||||||
const [composeActive, setComposeActive] = useState(false);
|
const [composeActive, setComposeActive] = useState(false);
|
||||||
const [composeStep, setComposeStep] = useState<ComposeStep>("idle");
|
const [composeStep, setComposeStep] = useState<ComposeStep>("idle");
|
||||||
const playbackSuspended = usePlaybackStore((s) => s.suspendCount > 0);
|
const playbackSuspended = usePlaybackSuspenderStore((s) => s.suspendCount > 0);
|
||||||
const playbackBlocked = composeActive || playbackSuspended;
|
const playbackBlocked = composeActive || playbackSuspended;
|
||||||
const [progress, setProgress] = useState(0);
|
const [progress, setProgress] = useState(0);
|
||||||
const [fastPlayback, setFastPlayback] = useState(false);
|
const [fastPlayback, setFastPlayback] = useState(false);
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ import { create } from "zustand";
|
|||||||
* `suspend()` on mount and `release()` on unmount. Stream playback is suspended
|
* `suspend()` on mount and `release()` on unmount. Stream playback is suspended
|
||||||
* whenever `suspendCount > 0`.
|
* whenever `suspendCount > 0`.
|
||||||
*/
|
*/
|
||||||
interface PlaybackState {
|
interface PlaybackSuspenderState {
|
||||||
suspendCount: number;
|
suspendCount: number;
|
||||||
suspend: () => void;
|
suspend: () => void;
|
||||||
release: () => void;
|
release: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const usePlaybackStore = create<PlaybackState>((set) => ({
|
export const usePlaybackSuspenderStore = create<PlaybackSuspenderState>((set) => ({
|
||||||
suspendCount: 0,
|
suspendCount: 0,
|
||||||
suspend: () => set((s) => ({ suspendCount: s.suspendCount + 1 })),
|
suspend: () => set((s) => ({ suspendCount: s.suspendCount + 1 })),
|
||||||
release: () => set((s) => ({ suspendCount: Math.max(0, s.suspendCount - 1) })),
|
release: () => set((s) => ({ suspendCount: Math.max(0, s.suspendCount - 1) })),
|
||||||
Reference in New Issue
Block a user