fix(StreamingServerWarning): align server state warning checks across app

This commit is contained in:
Botzy 2025-12-22 15:29:31 +02:00
parent 67ce665801
commit 2b253003b0
3 changed files with 24 additions and 19 deletions

View file

@ -23,12 +23,15 @@ const NavMenuContent = ({ onClick }) => {
const { createTorrentFromMagnet } = useTorrent(); const { createTorrentFromMagnet } = useTorrent();
const [fullscreen, requestFullscreen, exitFullscreen] = useFullscreen(); const [fullscreen, requestFullscreen, exitFullscreen] = useFullscreen();
const [isIOSPWA, isAndroidPWA] = usePWA(); const [isIOSPWA, isAndroidPWA] = usePWA();
const streamingServerWarningDismissed = React.useMemo(() => { const showStreamingServerWarning = React.useMemo(() => {
return (streamingServer.state !== null && streamingServer.state.type === 'Ready' && streamingServer.state.content === 'running') return streamingServer.state === null ||
|| ( streamingServer.state.type === 'Err' ||
(streamingServer.state.type === 'Ready' && streamingServer.state.content === 'notRunning') ?
(
isNaN(profile.settings.streamingServerWarningDismissed.getTime()) || isNaN(profile.settings.streamingServerWarningDismissed.getTime()) ||
profile.settings.streamingServerWarningDismissed.getTime() > Date.now() profile.settings.streamingServerWarningDismissed.getTime() < Date.now()
); )
: false;
}, [profile.settings, streamingServer.state]); }, [profile.settings, streamingServer.state]);
const logoutButtonOnClick = React.useCallback(() => { const logoutButtonOnClick = React.useCallback(() => {
core.transport.dispatch({ core.transport.dispatch({
@ -47,7 +50,7 @@ const NavMenuContent = ({ onClick }) => {
} }
}, []); }, []);
return ( return (
<div className={classnames(styles['nav-menu-container'], 'animation-fade-in', { [styles['with-warning']]: !streamingServerWarningDismissed })} onClick={onClick}> <div className={classnames(styles['nav-menu-container'], 'animation-fade-in', { [styles['with-warning']]: showStreamingServerWarning })} onClick={onClick}>
<div className={styles['user-info-container']}> <div className={styles['user-info-container']}>
<div <div
className={styles['avatar-container']} className={styles['avatar-container']}

View file

@ -22,15 +22,15 @@ const Board = () => {
const profile = useProfile(); const profile = useProfile();
const boardCatalogsOffset = continueWatchingPreview.items.length > 0 ? 1 : 0; const boardCatalogsOffset = continueWatchingPreview.items.length > 0 ? 1 : 0;
const scrollContainerRef = React.useRef(); const scrollContainerRef = React.useRef();
const showStreamingServerWarning = React.useMemo(() => {
const [showStreamingServerWarning, setStreamingServerWarning] = React.useState(true); return streamingServer.state === null ||
streamingServer.state.type === 'Err' ||
React.useEffect(() => { (streamingServer.state.type === 'Ready' && streamingServer.state.content === 'notRunning') ?
setStreamingServerWarning(streamingServer.state === null || streamingServer.state.type === 'Err' || (streamingServer.state.type === 'Ready' && streamingServer.state.content === 'notRunning') (
? (
isNaN(profile.settings.streamingServerWarningDismissed.getTime()) || isNaN(profile.settings.streamingServerWarningDismissed.getTime()) ||
profile.settings.streamingServerWarningDismissed.getTime() > Date.now()) profile.settings.streamingServerWarningDismissed.getTime() < Date.now()
: false); )
: false;
}, [profile.settings, streamingServer.state]); }, [profile.settings, streamingServer.state]);
const onVisibleRangeChange = React.useCallback(() => { const onVisibleRangeChange = React.useCallback(() => {

View file

@ -23,6 +23,8 @@ const Item = ({ url }: Props) => {
const selected = useMemo(() => profile.settings.streamingServerUrl === url, [url, profile.settings]); const selected = useMemo(() => profile.settings.streamingServerUrl === url, [url, profile.settings]);
const defaultUrl = useMemo(() => url === DEFAULT_STREAMING_SERVER_URL, [url]); const defaultUrl = useMemo(() => url === DEFAULT_STREAMING_SERVER_URL, [url]);
const serverReady = useMemo(() => streamingServer.state?.type === 'Ready' && streamingServer.state.content === 'running', [streamingServer.state]);
const serverError = useMemo(() => streamingServer.state?.type === 'Err' || (streamingServer.state?.type === 'Ready' && streamingServer.state.content === 'notRunning'), [streamingServer.state]);
const handleDelete = useCallback(() => { const handleDelete = useCallback(() => {
deleteServerUrl(url); deleteServerUrl(url);
@ -43,19 +45,19 @@ const Item = ({ url }: Props) => {
{ {
selected ? selected ?
<div className={styles['status']}> <div className={styles['status']}>
<div className={classNames(styles['icon'], { [styles['ready']]: streamingServer.settings?.type === 'Ready' }, { [styles['error']]: streamingServer.settings?.type === 'Err' })} /> <div className={classNames(styles['icon'], { [styles['ready']]: serverReady }, { [styles['error']]: serverError })} />
<div className={styles['label']}> <div className={styles['label']}>
{ {
streamingServer.settings === null ? streamingServer.state === null ?
'NotLoaded' 'NotLoaded'
: :
streamingServer.settings.type === 'Ready' ? serverReady ?
t('SETTINGS_SERVER_STATUS_ONLINE') t('SETTINGS_SERVER_STATUS_ONLINE')
: :
streamingServer.settings.type === 'Err' ? serverError ?
t('SETTINGS_SERVER_STATUS_ERROR') t('SETTINGS_SERVER_STATUS_ERROR')
: :
streamingServer.settings.type streamingServer.state.type
} }
</div> </div>
</div> </div>