fix: hide plex guid cache settings from ui when running in jellyfin/emby mode

This commit is contained in:
notfakie
2022-06-02 18:47:27 +12:00
parent 4b7bdd3d7d
commit 7450138ac1

View File

@@ -10,9 +10,11 @@ import {
} from 'react-intl'; } from 'react-intl';
import { useToasts } from 'react-toast-notifications'; import { useToasts } from 'react-toast-notifications';
import useSWR from 'swr'; import useSWR from 'swr';
import { MediaServerType } from '../../../../server/constants/server';
import { CacheItem } from '../../../../server/interfaces/api/settingsInterfaces'; import { CacheItem } from '../../../../server/interfaces/api/settingsInterfaces';
import { JobId } from '../../../../server/lib/settings'; import { JobId } from '../../../../server/lib/settings';
import Spinner from '../../../assets/spinner.svg'; import Spinner from '../../../assets/spinner.svg';
import useSettings from '../../../hooks/useSettings';
import globalMessages from '../../../i18n/globalMessages'; import globalMessages from '../../../i18n/globalMessages';
import { formatBytes } from '../../../utils/numberHelpers'; import { formatBytes } from '../../../utils/numberHelpers';
import Badge from '../../Common/Badge'; import Badge from '../../Common/Badge';
@@ -102,6 +104,7 @@ const SettingsJobs: React.FC = () => {
const [isSaving, setIsSaving] = useState(false); const [isSaving, setIsSaving] = useState(false);
const [jobScheduleMinutes, setJobScheduleMinutes] = useState(5); const [jobScheduleMinutes, setJobScheduleMinutes] = useState(5);
const [jobScheduleHours, setJobScheduleHours] = useState(1); const [jobScheduleHours, setJobScheduleHours] = useState(1);
const settings = useSettings();
if (!data && !error) { if (!data && !error) {
return <LoadingSpinner />; return <LoadingSpinner />;
@@ -369,7 +372,15 @@ const SettingsJobs: React.FC = () => {
</tr> </tr>
</thead> </thead>
<Table.TBody> <Table.TBody>
{cacheData?.map((cache) => ( {cacheData
?.filter(
(cache) =>
!(
settings.currentSettings.mediaServerType !==
MediaServerType.PLEX && cache.id === 'plexguid'
)
)
.map((cache) => (
<tr key={`cache-list-${cache.id}`}> <tr key={`cache-list-${cache.id}`}>
<Table.TD>{cache.name}</Table.TD> <Table.TD>{cache.name}</Table.TD>
<Table.TD>{intl.formatNumber(cache.stats.hits)}</Table.TD> <Table.TD>{intl.formatNumber(cache.stats.hits)}</Table.TD>
@@ -378,7 +389,10 @@ const SettingsJobs: React.FC = () => {
<Table.TD>{formatBytes(cache.stats.ksize)}</Table.TD> <Table.TD>{formatBytes(cache.stats.ksize)}</Table.TD>
<Table.TD>{formatBytes(cache.stats.vsize)}</Table.TD> <Table.TD>{formatBytes(cache.stats.vsize)}</Table.TD>
<Table.TD alignText="right"> <Table.TD alignText="right">
<Button buttonType="danger" onClick={() => flushCache(cache)}> <Button
buttonType="danger"
onClick={() => flushCache(cache)}
>
<TrashIcon /> <TrashIcon />
<span>{intl.formatMessage(messages.flushcache)}</span> <span>{intl.formatMessage(messages.flushcache)}</span>
</Button> </Button>