diff --git a/src/components/Setup/SetupLogin.tsx b/src/components/Setup/SetupLogin.tsx index c042b3449..2dde96dcf 100644 --- a/src/components/Setup/SetupLogin.tsx +++ b/src/components/Setup/SetupLogin.tsx @@ -15,12 +15,12 @@ const messages = defineMessages({ }); interface LoginWithMediaServerProps { - onComplete: () => void; + onComplete: (onComplete: MediaServerType) => void; } const SetupLogin: React.FC = ({ onComplete }) => { const [authToken, setAuthToken] = useState(undefined); - const [mediaServerType, setMediaServerType] = useState( + const [mediaServerType, setMediaServerType] = useState( MediaServerType.NOT_CONFIGURED ); const { user, revalidate } = useUser(); @@ -46,9 +46,9 @@ const SetupLogin: React.FC = ({ onComplete }) => { useEffect(() => { if (user) { - onComplete(); + onComplete(mediaServerType); } - }, [user, onComplete]); + }, [user, mediaServerType, onComplete]); return (
diff --git a/src/components/Setup/index.tsx b/src/components/Setup/index.tsx index 6acdc4d49..a8724b02f 100644 --- a/src/components/Setup/index.tsx +++ b/src/components/Setup/index.tsx @@ -3,6 +3,7 @@ import { useRouter } from 'next/router'; import React, { useState } from 'react'; import { defineMessages, useIntl } from 'react-intl'; import useSWR, { mutate } from 'swr'; +import { MediaServerType } from '../../../server/constants/server'; import useLocale from '../../hooks/useLocale'; import AppDataWarning from '../AppDataWarning'; import Badge from '../Common/Badge'; @@ -35,7 +36,9 @@ const Setup: React.FC = () => { const [currentStep, setCurrentStep] = useState(1); const [mediaServerSettingsComplete, setMediaServerSettingsComplete] = useState(false); - const [mediaServerType, setMediaServerType] = useState(''); + const [mediaServerType, setMediaServerType] = useState( + MediaServerType.NOT_CONFIGURED + ); const router = useRouter(); const { locale } = useLocale(); @@ -54,11 +57,6 @@ const Setup: React.FC = () => { } }; - const getMediaServerType = async () => { - const MainSettings = await axios.get('/api/v1/settings/main'); - setMediaServerType(MainSettings.data.mediaServerType); - return; - }; const { data: backdrops } = useSWR('/api/v1/backdrops', { refreshInterval: 0, refreshWhenHidden: false, @@ -113,16 +111,15 @@ const Setup: React.FC = () => {
{currentStep === 1 && ( { - getMediaServerType().then(() => { - setCurrentStep(2); - }); + onComplete={(mServerType) => { + setMediaServerType(mServerType); + setCurrentStep(2); }} /> )} {currentStep === 2 && (
- {mediaServerType == 'PLEX' ? ( + {mediaServerType === MediaServerType.PLEX ? ( setMediaServerSettingsComplete(true)} />