Skip to content

Commit

Permalink
fix(plex): disable library sync if Plex not configured, and disable s…
Browse files Browse the repository at this point in the history
…can if no libraries (#1764)
  • Loading branch information
TheCatLady committed Jun 10, 2021
1 parent dedf95e commit 22238fe
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/components/Settings/SettingsPlex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,9 @@ const SettingsPlex: React.FC<SettingsPlexProps> = ({ onComplete }) => {
const [isRefreshingPresets, setIsRefreshingPresets] = useState(false);
const [availableServers, setAvailableServers] =
useState<PlexDevice[] | null>(null);
const {
data: data,
error: error,
revalidate: revalidate,
} = useSWR<PlexSettings>('/api/v1/settings/plex');
const { data, error, revalidate } = useSWR<PlexSettings>(
'/api/v1/settings/plex'
);
const { data: dataSync, revalidate: revalidateSync } = useSWR<SyncStatus>(
'/api/v1/settings/plex/sync',
{
Expand Down Expand Up @@ -540,7 +538,10 @@ const SettingsPlex: React.FC<SettingsPlexProps> = ({ onComplete }) => {
</p>
</div>
<div className="section">
<Button onClick={() => syncLibraries()} disabled={isSyncing}>
<Button
onClick={() => syncLibraries()}
disabled={isSyncing || !data?.ip || !data?.port}
>
<RefreshIcon
className={isSyncing ? 'animate-spin' : ''}
style={{ animationDirection: 'reverse' }}
Expand Down Expand Up @@ -619,7 +620,11 @@ const SettingsPlex: React.FC<SettingsPlexProps> = ({ onComplete }) => {
)}
<div className="flex-1 text-right">
{!dataSync?.running ? (
<Button buttonType="warning" onClick={() => startScan()}>
<Button
buttonType="warning"
onClick={() => startScan()}
disabled={isSyncing || !activeLibraries.length}
>
<SearchIcon />
<span>{intl.formatMessage(messages.startscan)}</span>
</Button>
Expand Down

0 comments on commit 22238fe

Please sign in to comment.