mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 17:15:48 +00:00
fix(StreamingServerWarning): align server state warning checks across app
This commit is contained in:
parent
67ce665801
commit
2b253003b0
3 changed files with 24 additions and 19 deletions
|
|
@ -23,12 +23,15 @@ const NavMenuContent = ({ onClick }) => {
|
|||
const { createTorrentFromMagnet } = useTorrent();
|
||||
const [fullscreen, requestFullscreen, exitFullscreen] = useFullscreen();
|
||||
const [isIOSPWA, isAndroidPWA] = usePWA();
|
||||
const streamingServerWarningDismissed = React.useMemo(() => {
|
||||
return (streamingServer.state !== null && streamingServer.state.type === 'Ready' && streamingServer.state.content === 'running')
|
||||
|| (
|
||||
const showStreamingServerWarning = React.useMemo(() => {
|
||||
return streamingServer.state === null ||
|
||||
streamingServer.state.type === 'Err' ||
|
||||
(streamingServer.state.type === 'Ready' && streamingServer.state.content === 'notRunning') ?
|
||||
(
|
||||
isNaN(profile.settings.streamingServerWarningDismissed.getTime()) ||
|
||||
profile.settings.streamingServerWarningDismissed.getTime() > Date.now()
|
||||
);
|
||||
profile.settings.streamingServerWarningDismissed.getTime() < Date.now()
|
||||
)
|
||||
: false;
|
||||
}, [profile.settings, streamingServer.state]);
|
||||
const logoutButtonOnClick = React.useCallback(() => {
|
||||
core.transport.dispatch({
|
||||
|
|
@ -47,7 +50,7 @@ const NavMenuContent = ({ onClick }) => {
|
|||
}
|
||||
}, []);
|
||||
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['avatar-container']}
|
||||
|
|
|
|||
|
|
@ -22,15 +22,15 @@ const Board = () => {
|
|||
const profile = useProfile();
|
||||
const boardCatalogsOffset = continueWatchingPreview.items.length > 0 ? 1 : 0;
|
||||
const scrollContainerRef = React.useRef();
|
||||
|
||||
const [showStreamingServerWarning, setStreamingServerWarning] = React.useState(true);
|
||||
|
||||
React.useEffect(() => {
|
||||
setStreamingServerWarning(streamingServer.state === null || streamingServer.state.type === 'Err' || (streamingServer.state.type === 'Ready' && streamingServer.state.content === 'notRunning')
|
||||
? (
|
||||
const showStreamingServerWarning = React.useMemo(() => {
|
||||
return streamingServer.state === null ||
|
||||
streamingServer.state.type === 'Err' ||
|
||||
(streamingServer.state.type === 'Ready' && streamingServer.state.content === 'notRunning') ?
|
||||
(
|
||||
isNaN(profile.settings.streamingServerWarningDismissed.getTime()) ||
|
||||
profile.settings.streamingServerWarningDismissed.getTime() > Date.now())
|
||||
: false);
|
||||
profile.settings.streamingServerWarningDismissed.getTime() < Date.now()
|
||||
)
|
||||
: false;
|
||||
}, [profile.settings, streamingServer.state]);
|
||||
|
||||
const onVisibleRangeChange = React.useCallback(() => {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ const Item = ({ url }: Props) => {
|
|||
|
||||
const selected = useMemo(() => profile.settings.streamingServerUrl === url, [url, profile.settings]);
|
||||
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(() => {
|
||||
deleteServerUrl(url);
|
||||
|
|
@ -43,19 +45,19 @@ const Item = ({ url }: Props) => {
|
|||
{
|
||||
selected ?
|
||||
<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']}>
|
||||
{
|
||||
streamingServer.settings === null ?
|
||||
streamingServer.state === null ?
|
||||
'NotLoaded'
|
||||
:
|
||||
streamingServer.settings.type === 'Ready' ?
|
||||
serverReady ?
|
||||
t('SETTINGS_SERVER_STATUS_ONLINE')
|
||||
:
|
||||
streamingServer.settings.type === 'Err' ?
|
||||
serverError ?
|
||||
t('SETTINGS_SERVER_STATUS_ERROR')
|
||||
:
|
||||
streamingServer.settings.type
|
||||
streamingServer.state.type
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue