From bc733ddf0e40a854339ee9b1d922008473db4360 Mon Sep 17 00:00:00 2001 From: Ben Beauchamp Date: Thu, 6 Feb 2025 18:36:22 -0600 Subject: [PATCH] refactor(blacklist): swap out some != and == for !s and _s --- server/job/blacklistedTagsProcessor.ts | 36 +++++++------- src/components/Blacklist/index.tsx | 49 +++++++++---------- src/components/BlacklistBlock/index.tsx | 4 +- src/components/BlacklistedTagsBadge/index.tsx | 2 +- 4 files changed, 44 insertions(+), 47 deletions(-) diff --git a/server/job/blacklistedTagsProcessor.ts b/server/job/blacklistedTagsProcessor.ts index 720120e4..eab46a1e 100644 --- a/server/job/blacklistedTagsProcessor.ts +++ b/server/job/blacklistedTagsProcessor.ts @@ -83,7 +83,7 @@ class BlacklistedTagProcessor implements RunnableScanner { for (const type of [MediaType.MOVIE, MediaType.TV]) { const getDiscover = - type == MediaType.MOVIE ? tmdb.getDiscoverMovies : tmdb.getDiscoverTv; + type === MediaType.MOVIE ? tmdb.getDiscoverMovies : tmdb.getDiscoverTv; // Iterate for each tag for (const tag of blacklistedTagsArr) { @@ -111,7 +111,7 @@ class BlacklistedTagProcessor implements RunnableScanner { await new Promise((res) => setTimeout(res, TMDB_API_DELAY_MS)); this.progress++; - if (page == 1 && response.total_pages <= queryMax) { + if (page === 1 && response.total_pages <= queryMax) { // We will finish the tag with less queries than expected, move progress accordingly this.progress += queryMax - response.total_pages; fixedSortMode = true; @@ -135,33 +135,31 @@ class BlacklistedTagProcessor implements RunnableScanner { where: { tmdbId: entry.id }, }); - if (blacklistEntry != null) { + if (blacklistEntry) { // Don't mark manual blacklists with tags // If media wasn't previously blacklisted for this tag, add the tag to the media's blacklist if ( - blacklistEntry.blacklistedTags != null && + blacklistEntry.blacklistedTags && !blacklistEntry.blacklistedTags.includes(`,${keywordId},`) ) { await blacklistRepository.update(blacklistEntry.id, { blacklistedTags: `${blacklistEntry.blacklistedTags}${keywordId},`, }); } - - continue; - } - - // Media wasn't previously blacklisted, add it to the blacklist - await Blacklist.addToBlacklist( - { - blacklistRequest: { - mediaType, - title: 'title' in entry ? entry.title : entry.name, - tmdbId: entry.id, - blacklistedTags: `,${keywordId},`, + } else { + // Media wasn't previously blacklisted, add it to the blacklist + await Blacklist.addToBlacklist( + { + blacklistRequest: { + mediaType, + title: 'title' in entry ? entry.title : entry.name, + tmdbId: entry.id, + blacklistedTags: `,${keywordId},`, + }, }, - }, - em - ); + em + ); + } } } diff --git a/src/components/Blacklist/index.tsx b/src/components/Blacklist/index.tsx index e1dc8e01..ced5d15d 100644 --- a/src/components/Blacklist/index.tsx +++ b/src/components/Blacklist/index.tsx @@ -410,33 +410,32 @@ const BlacklistedItem = ({ item, revalidateList }: BlacklistedItemProps) => { numeric="auto" /> ), - user: - item.user != null ? ( - - - - - {item.user.displayName} - + user: item.user ? ( + + + + + {item.user.displayName} - - ) : item.blacklistedTags ? ( - - - ) : ( - - ??? - - ), + + ) : item.blacklistedTags ? ( + + + + ) : ( + + ??? + + ), })} diff --git a/src/components/BlacklistBlock/index.tsx b/src/components/BlacklistBlock/index.tsx index cabf3227..7b86faa4 100644 --- a/src/components/BlacklistBlock/index.tsx +++ b/src/components/BlacklistBlock/index.tsx @@ -79,7 +79,7 @@ const BlacklistBlock = ({
- {data.user != null ? ( + {data.user ? ( <> @@ -98,7 +98,7 @@ const BlacklistBlock = ({ - ) : data.blacklistedTags != null && data.blacklistedTags != '' ? ( + ) : data.blacklistedTags ? ( <> {intl.formatMessage(messages.blacklistedby)}:  diff --git a/src/components/BlacklistedTagsBadge/index.tsx b/src/components/BlacklistedTagsBadge/index.tsx index 2c949154..df15af4d 100644 --- a/src/components/BlacklistedTagsBadge/index.tsx +++ b/src/components/BlacklistedTagsBadge/index.tsx @@ -21,7 +21,7 @@ const BlacklistedTagsBadge = ({ data }: BlacklistedTagsBadgeProps) => { const intl = useIntl(); useEffect(() => { - if (data.blacklistedTags == null) { + if (!data.blacklistedTags) { return; }