mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-01 03:28:27 +01:00
feat(sync-play): squash feature/sync-play
This commit is contained in:
@@ -2,6 +2,7 @@ import { useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Alert } from "react-native";
|
||||
import useRouter from "@/hooks/useAppRouter";
|
||||
import { useSyncPlay } from "@/providers/SyncPlay/SyncPlayProvider";
|
||||
import { useWebSocketContext } from "@/providers/WebSocketProvider";
|
||||
|
||||
interface UseWebSocketProps {
|
||||
@@ -80,9 +81,9 @@ export const useWebSocket = ({
|
||||
playTrailers,
|
||||
}: UseWebSocketProps) => {
|
||||
const router = useRouter();
|
||||
const { lastMessage } = useWebSocketContext();
|
||||
const { lastMessage, clearLastMessage } = useWebSocketContext();
|
||||
const { t } = useTranslation();
|
||||
const { clearLastMessage } = useWebSocketContext();
|
||||
const { isEnabled: isSyncPlayEnabled } = useSyncPlay();
|
||||
|
||||
useEffect(() => {
|
||||
if (!lastMessage) return;
|
||||
@@ -96,6 +97,25 @@ export const useWebSocket = ({
|
||||
| Record<string, string>
|
||||
| undefined; // Arguments are Dictionary<string, string>
|
||||
|
||||
// Skip playback commands when SyncPlay is enabled - SyncPlay handles these
|
||||
const isSyncPlayCommand =
|
||||
lastMessage.MessageType === "SyncPlayCommand" ||
|
||||
lastMessage.MessageType === "SyncPlayGroupUpdate";
|
||||
const isPlaybackCommand = [
|
||||
"PlayPause",
|
||||
"Pause",
|
||||
"Unpause",
|
||||
"Stop",
|
||||
"Seek",
|
||||
"NextTrack",
|
||||
"PreviousTrack",
|
||||
].includes(command ?? "");
|
||||
|
||||
if (isSyncPlayEnabled && (isSyncPlayCommand || isPlaybackCommand)) {
|
||||
console.log(`Command ~ ${command} - skipping, SyncPlay handles playback`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (command === "PlayPause") {
|
||||
console.log("Command ~ PlayPause");
|
||||
togglePlay();
|
||||
|
||||
Reference in New Issue
Block a user