mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Backport pull request #5898 from jellyfin-web/release-10.9.z
Fix autoCast race condition
Original-merge: 7f575d724e
Merged-by: thornbill <thornbill@users.noreply.github.com>
Backported-by: thornbill <thornbill@users.noreply.github.com>
This commit is contained in:
parent
75d78a96b8
commit
37fbfb3772
4 changed files with 26 additions and 39 deletions
|
@ -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}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue