Files
Blink/src/utils/store/realtime.ts
T
1xDed 5746bf35a5
Continuous Integration / build_web (push) Failing after 0s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
feat: add cross-device playback and remote control
- native SyncPlay groups with shared queues, ready/buffering and local pause/seek reporting
- follow-me prompt that transfers another session's playback to this device
- auto-skip intros/recaps and skip-credits for final items
- blink:// deep links with timestamped scene sharing via QR
- Quick Connect approval and QR onboarding from a phone
- Rust WebSocket client with Authorization header for Jellyfin 12, capabilities advertising, live sessions and remote commands
2026-11-29 08:03:21 +03:00

49 lines
1.3 KiB
TypeScript

import type {
GroupUpdate,
SendCommand,
SessionInfoDto,
} from "@jellyfin/sdk/lib/generated-client";
import { create } from "zustand";
type Timed<T> = {
value: T;
at: number;
};
type RealtimeState = {
/** Latest session snapshot pushed by the server. */
sessions: SessionInfoDto[];
connected: boolean;
lastMessageAt: number;
lastGroupUpdate: Timed<GroupUpdate> | null;
lastSyncCommand: Timed<SendCommand> | null;
setConnected: (connected: boolean) => void;
setSessions: (sessions: SessionInfoDto[]) => void;
markMessage: () => void;
setGroupUpdate: (update: GroupUpdate) => void;
setSyncCommand: (command: SendCommand) => void;
reset: () => void;
};
const initialState = {
sessions: [] as SessionInfoDto[],
connected: false,
lastMessageAt: 0,
lastGroupUpdate: null as Timed<GroupUpdate> | null,
lastSyncCommand: null as Timed<SendCommand> | null,
};
export const useRealtimeStore = create<RealtimeState>((set) => ({
...initialState,
setConnected: (connected) => set({ connected }),
setSessions: (sessions) => set({ sessions, lastMessageAt: Date.now() }),
markMessage: () => set({ lastMessageAt: Date.now() }),
setGroupUpdate: (value) =>
set({ lastGroupUpdate: { value, at: Date.now() } }),
setSyncCommand: (value) =>
set({ lastSyncCommand: { value, at: Date.now() } }),
reset: () => set(initialState),
}));
export default useRealtimeStore;