fix(plex): disable library sync if Plex not configured, and disable scan if no libraries (#1764)

pull/1769/head
TheCatLady 4 years ago committed by GitHub
parent dedf95e574
commit 22238fe4f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -94,11 +94,9 @@ const SettingsPlex: React.FC<SettingsPlexProps> = ({ onComplete }) => {
const [isRefreshingPresets, setIsRefreshingPresets] = useState(false); const [isRefreshingPresets, setIsRefreshingPresets] = useState(false);
const [availableServers, setAvailableServers] = const [availableServers, setAvailableServers] =
useState<PlexDevice[] | null>(null); useState<PlexDevice[] | null>(null);
const { const { data, error, revalidate } = useSWR<PlexSettings>(
data: data, '/api/v1/settings/plex'
error: error, );
revalidate: revalidate,
} = useSWR<PlexSettings>('/api/v1/settings/plex');
const { data: dataSync, revalidate: revalidateSync } = useSWR<SyncStatus>( const { data: dataSync, revalidate: revalidateSync } = useSWR<SyncStatus>(
'/api/v1/settings/plex/sync', '/api/v1/settings/plex/sync',
{ {
@ -540,7 +538,10 @@ const SettingsPlex: React.FC<SettingsPlexProps> = ({ onComplete }) => {
</p> </p>
</div> </div>
<div className="section"> <div className="section">
<Button onClick={() => syncLibraries()} disabled={isSyncing}> <Button
onClick={() => syncLibraries()}
disabled={isSyncing || !data?.ip || !data?.port}
>
<RefreshIcon <RefreshIcon
className={isSyncing ? 'animate-spin' : ''} className={isSyncing ? 'animate-spin' : ''}
style={{ animationDirection: 'reverse' }} style={{ animationDirection: 'reverse' }}
@ -619,7 +620,11 @@ const SettingsPlex: React.FC<SettingsPlexProps> = ({ onComplete }) => {
)} )}
<div className="flex-1 text-right"> <div className="flex-1 text-right">
{!dataSync?.running ? ( {!dataSync?.running ? (
<Button buttonType="warning" onClick={() => startScan()}> <Button
buttonType="warning"
onClick={() => startScan()}
disabled={isSyncing || !activeLibraries.length}
>
<SearchIcon /> <SearchIcon />
<span>{intl.formatMessage(messages.startscan)}</span> <span>{intl.formatMessage(messages.startscan)}</span>
</Button> </Button>

Loading…
Cancel
Save