Backport pull request #5898 from jellyfin-web/release-10.9.z
Fix autoCast race condition Original-merge: 7f575d724ed04d3409c104cee59de9c1be86feda Merged-by: thornbill <thornbill@users.noreply.github.com> Backported-by: thornbill <thornbill@users.noreply.github.com>
This commit is contained in:
@@ -12,7 +12,7 @@ import { playbackManager } from 'components/playback/playbackmanager';
|
||||
import React, { FC, useCallback, useState } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import { enable, isEnabled, supported } from 'scripts/autocast';
|
||||
import { enable, isEnabled } from 'scripts/autocast';
|
||||
import globalize from 'scripts/globalize';
|
||||
|
||||
interface RemotePlayActiveMenuProps extends MenuProps {
|
||||
@@ -43,11 +43,10 @@ const RemotePlayActiveMenu: FC<RemotePlayActiveMenuProps> = ({
|
||||
}, [ isDisplayMirrorEnabled, setIsDisplayMirrorEnabled ]);
|
||||
|
||||
const [ isAutoCastEnabled, setIsAutoCastEnabled ] = useState(isEnabled());
|
||||
const isAutoCastSupported = supported();
|
||||
const toggleAutoCast = useCallback(() => {
|
||||
enable(!isAutoCastEnabled);
|
||||
setIsAutoCastEnabled(!isAutoCastEnabled);
|
||||
}, [ isAutoCastEnabled, setIsAutoCastEnabled ]);
|
||||
}, [ isAutoCastEnabled ]);
|
||||
|
||||
const remotePlayerName = playerInfo?.deviceName || playerInfo?.name;
|
||||
|
||||
@@ -117,20 +116,18 @@ const RemotePlayActiveMenu: FC<RemotePlayActiveMenuProps> = ({
|
||||
</MenuItem>
|
||||
)}
|
||||
|
||||
{isAutoCastSupported && (
|
||||
<MenuItem onClick={toggleAutoCast}>
|
||||
{isAutoCastEnabled && (
|
||||
<ListItemIcon>
|
||||
<Check />
|
||||
</ListItemIcon>
|
||||
)}
|
||||
<ListItemText inset={!isAutoCastEnabled}>
|
||||
{globalize.translate('EnableAutoCast')}
|
||||
</ListItemText>
|
||||
</MenuItem>
|
||||
)}
|
||||
<MenuItem onClick={toggleAutoCast}>
|
||||
{isAutoCastEnabled && (
|
||||
<ListItemIcon>
|
||||
<Check />
|
||||
</ListItemIcon>
|
||||
)}
|
||||
<ListItemText inset={!isAutoCastEnabled}>
|
||||
{globalize.translate('EnableAutoCast')}
|
||||
</ListItemText>
|
||||
</MenuItem>
|
||||
|
||||
{(isDisplayMirrorSupported || isAutoCastSupported) && <Divider />}
|
||||
<Divider />
|
||||
|
||||
<MenuItem
|
||||
component={Link}
|
||||
|
||||
Reference in New Issue
Block a user