From 3dc7b8e04e5fb0c00697165960beec5f24d0c4f8 Mon Sep 17 00:00:00 2001 From: sct Date: Mon, 31 Mar 2025 16:06:05 +0900 Subject: [PATCH] fix: dont show play on plex buttons when plex is disabled --- server/lib/availabilitySync.ts | 2 +- server/lib/watchlistsync.ts | 12 ++++++++++++ src/components/IssueDetails/index.tsx | 6 ++++-- src/components/MovieDetails/index.tsx | 2 ++ src/components/TvDetails/index.tsx | 3 ++- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/server/lib/availabilitySync.ts b/server/lib/availabilitySync.ts index 38f3fa38..f5bb3aff 100644 --- a/server/lib/availabilitySync.ts +++ b/server/lib/availabilitySync.ts @@ -45,7 +45,7 @@ class AvailabilitySync { if (admin?.plexToken) { this.plexClient = new PlexAPI({ plexToken: admin.plexToken }); } else { - logger.error('An admin is not configured.'); + logger.warn('Plex is not configured. Skipping availability sync.'); } for await (const media of this.loadAvailableMediaPaginated(pageSize)) { diff --git a/server/lib/watchlistsync.ts b/server/lib/watchlistsync.ts index 0fd90f64..9fdbcdcd 100644 --- a/server/lib/watchlistsync.ts +++ b/server/lib/watchlistsync.ts @@ -17,6 +17,18 @@ class WatchlistSync { public async syncWatchlist() { const userRepository = getRepository(User); + const admin = await userRepository.findOne({ + select: { id: true, plexToken: true }, + where: { id: 1 }, + }); + + if (!admin?.plexToken) { + logger.warn('Skipping watchlist sync for admin without plex token', { + label: 'Plex Watchlist Sync', + }); + return; + } + // Get users who actually have plex tokens const users = await userRepository .createQueryBuilder('user') diff --git a/src/components/IssueDetails/index.tsx b/src/components/IssueDetails/index.tsx index 171f90a8..da5e58cb 100644 --- a/src/components/IssueDetails/index.tsx +++ b/src/components/IssueDetails/index.tsx @@ -8,6 +8,7 @@ import IssueComment from '@app/components/IssueDetails/IssueComment'; import IssueDescription from '@app/components/IssueDetails/IssueDescription'; import { issueOptions } from '@app/components/IssueModal/constants'; import useDeepLinks from '@app/hooks/useDeepLinks'; +import useSettings from '@app/hooks/useSettings'; import { Permission, useUser } from '@app/hooks/useUser'; import globalMessages from '@app/i18n/globalMessages'; import Error from '@app/pages/_error'; @@ -76,6 +77,7 @@ const isMovie = (movie: MovieDetails | TvDetails): movie is MovieDetails => { const IssueDetails = () => { const { addToast } = useToasts(); + const { currentSettings } = useSettings(); const router = useRouter(); const intl = useIntl(); const [showDeleteModal, setShowDeleteModal] = useState(false); @@ -361,7 +363,7 @@ const IssueDetails = () => {
- {issueData?.media.plexUrl && ( + {currentSettings.plexLoginEnabled && issueData?.media.plexUrl && (
- {issueData?.media.plexUrl && ( + {currentSettings.plexLoginEnabled && issueData?.media.plexUrl && (