From 5560abf459b0350ff30b5e71d4208418fc8f3b3e Mon Sep 17 00:00:00 2001 From: TheCatLady <52870424+TheCatLady@users.noreply.github.com> Date: Wed, 24 Feb 2021 23:14:32 -0500 Subject: [PATCH 01/12] fix(notif): escape application title in Telegram notifications (#1012) --- server/lib/notifications/agents/telegram.ts | 3 ++- .../Settings/Notifications/NotificationsTelegram.tsx | 8 ++++---- src/i18n/locale/en.json | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/server/lib/notifications/agents/telegram.ts b/server/lib/notifications/agents/telegram.ts index 9913d35e6..fd3b4dd9f 100644 --- a/server/lib/notifications/agents/telegram.ts +++ b/server/lib/notifications/agents/telegram.ts @@ -53,6 +53,7 @@ class TelegramAgent const title = this.escapeText(payload.subject); const plot = this.escapeText(payload.message); const user = this.escapeText(payload.notifyUser.displayName); + const applicationTitle = this.escapeText(settings.main.applicationTitle); /* eslint-disable no-useless-escape */ switch (type) { @@ -109,7 +110,7 @@ class TelegramAgent if (settings.main.applicationUrl && payload.media) { const actionUrl = `${settings.main.applicationUrl}/${payload.media.mediaType}/${payload.media.tmdbId}`; - message += `\n\n\[Open in ${settings.main.applicationTitle}\]\(${actionUrl}\)`; + message += `\n\n\[Open in ${applicationTitle}\]\(${actionUrl}\)`; } /* eslint-enable */ diff --git a/src/components/Settings/Notifications/NotificationsTelegram.tsx b/src/components/Settings/Notifications/NotificationsTelegram.tsx index bc626fd55..abfd8b0af 100644 --- a/src/components/Settings/Notifications/NotificationsTelegram.tsx +++ b/src/components/Settings/Notifications/NotificationsTelegram.tsx @@ -17,7 +17,7 @@ const messages = defineMessages({ botAPI: 'Bot Authentication Token', chatId: 'Chat ID', validationBotAPIRequired: 'You must provide a bot authentication token', - validationChatIdRequired: 'You must provide a valid chat ID', + validationChatIdRequired: 'You must provide a chat ID', telegramsettingssaved: 'Telegram notification settings saved successfully!', telegramsettingsfailed: 'Telegram notification settings failed to save.', testsent: 'Test notification sent!', @@ -43,9 +43,9 @@ const NotificationsTelegram: React.FC = () => { botAPI: Yup.string().required( intl.formatMessage(messages.validationBotAPIRequired) ), - chatId: Yup.string() - .required(intl.formatMessage(messages.validationChatIdRequired)) - .matches(/^\d+$/, intl.formatMessage(messages.validationChatIdRequired)), + chatId: Yup.string().required( + intl.formatMessage(messages.validationChatIdRequired) + ), }); if (!data && !error) { diff --git a/src/i18n/locale/en.json b/src/i18n/locale/en.json index 082836caa..2c4e6b5bb 100644 --- a/src/i18n/locale/en.json +++ b/src/i18n/locale/en.json @@ -326,7 +326,7 @@ "components.Settings.Notifications.test": "Test", "components.Settings.Notifications.testsent": "Test notification sent!", "components.Settings.Notifications.validationBotAPIRequired": "You must provide a bot authentication token", - "components.Settings.Notifications.validationChatIdRequired": "You must provide a valid chat ID", + "components.Settings.Notifications.validationChatIdRequired": "You must provide a chat ID", "components.Settings.Notifications.validationEmail": "You must provide a valid email address", "components.Settings.Notifications.validationSmtpHostRequired": "You must provide an SMTP host", "components.Settings.Notifications.validationSmtpPortRequired": "You must provide an SMTP port", From e9f2fe910d72fa41bc27673ed43291211c3cac65 Mon Sep 17 00:00:00 2001 From: Danshil Mungur Date: Fri, 26 Feb 2021 09:20:29 +0400 Subject: [PATCH 02/12] fix(notif): fixed typo in pushover hint (#1029) --- .../Settings/Notifications/NotificationsPushover/index.tsx | 4 ++-- src/i18n/locale/en.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Settings/Notifications/NotificationsPushover/index.tsx b/src/components/Settings/Notifications/NotificationsPushover/index.tsx index f86746d0b..d264023a5 100644 --- a/src/components/Settings/Notifications/NotificationsPushover/index.tsx +++ b/src/components/Settings/Notifications/NotificationsPushover/index.tsx @@ -24,9 +24,9 @@ const messages = defineMessages({ test: 'Test', settinguppushover: 'Setting Up Pushover Notifications', settinguppushoverDescription: - 'To configure Pushover notifications, you will need to register an application and enter the API key below.\ + 'To configure Pushover notifications, you will need to register an application and enter the API token below.\ (You can use one of our official icons on GitHub.)\ - You will need also need your user key.', + You will also need your user key.', notificationtypes: 'Notification Types', }); diff --git a/src/i18n/locale/en.json b/src/i18n/locale/en.json index 2c4e6b5bb..02ce91d29 100644 --- a/src/i18n/locale/en.json +++ b/src/i18n/locale/en.json @@ -262,7 +262,7 @@ "components.Settings.Notifications.NotificationsPushover.save": "Save Changes", "components.Settings.Notifications.NotificationsPushover.saving": "Saving…", "components.Settings.Notifications.NotificationsPushover.settinguppushover": "Setting Up Pushover Notifications", - "components.Settings.Notifications.NotificationsPushover.settinguppushoverDescription": "To configure Pushover notifications, you will need to register an application and enter the API key below. (You can use one of our official icons on GitHub.) You will need also need your user key.", + "components.Settings.Notifications.NotificationsPushover.settinguppushoverDescription": "To configure Pushover notifications, you will need to register an application and enter the API token below. (You can use one of our official icons on GitHub.) You will also need your user key.", "components.Settings.Notifications.NotificationsPushover.test": "Test", "components.Settings.Notifications.NotificationsPushover.testsent": "Test notification sent!", "components.Settings.Notifications.NotificationsPushover.userToken": "User Key", From 537850f414a88df24c78794a2fd68e1e24ff73d1 Mon Sep 17 00:00:00 2001 From: sct Date: Sat, 27 Feb 2021 10:00:58 +0000 Subject: [PATCH 03/12] fix(notifications): correctly send tv auto approval notifications fixes #1041 --- server/routes/request.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/server/routes/request.ts b/server/routes/request.ts index ec89a9831..afec0d258 100644 --- a/server/routes/request.ts +++ b/server/routes/request.ts @@ -283,9 +283,7 @@ requestRoutes.post( const request = new MediaRequest({ type: MediaType.TV, - media: { - id: media.id, - } as Media, + media, requestedBy: requestUser, // If the user is an admin or has the "auto approve" permission, automatically approve the request status: From 69294a7c4c5bbe55c5cd276786cdfd48ddbff889 Mon Sep 17 00:00:00 2001 From: sct Date: Sat, 27 Feb 2021 12:37:18 +0000 Subject: [PATCH 04/12] fix: allow users to override language/region settings fixes #1013 --- server/interfaces/api/settingsInterfaces.ts | 1 + server/lib/settings.ts | 2 + server/routes/discover.ts | 59 ++++++----- src/components/RegionSelector/index.tsx | 99 +++++++++++++++++-- .../UserGeneralSettings/index.tsx | 17 ++++ src/i18n/locale/en.json | 2 + 6 files changed, 141 insertions(+), 39 deletions(-) diff --git a/server/interfaces/api/settingsInterfaces.ts b/server/interfaces/api/settingsInterfaces.ts index 5136f17dc..122df7bd1 100644 --- a/server/interfaces/api/settingsInterfaces.ts +++ b/server/interfaces/api/settingsInterfaces.ts @@ -13,6 +13,7 @@ export interface PublicSettingsResponse { movie4kEnabled: boolean; series4kEnabled: boolean; region: string; + originalLanguage: string; } export interface CacheItem { diff --git a/server/lib/settings.ts b/server/lib/settings.ts index 02320e00f..a65c5ffb0 100644 --- a/server/lib/settings.ts +++ b/server/lib/settings.ts @@ -85,6 +85,7 @@ interface FullPublicSettings extends PublicSettings { movie4kEnabled: boolean; series4kEnabled: boolean; region: string; + originalLanguage: string; } export interface NotificationAgentConfig { @@ -337,6 +338,7 @@ class Settings { (sonarr) => sonarr.is4k && sonarr.isDefault ), region: this.data.main.region, + originalLanguage: this.data.main.originalLanguage, }; } diff --git a/server/routes/discover.ts b/server/routes/discover.ts index 5b9d1afce..e248870ae 100644 --- a/server/routes/discover.ts +++ b/server/routes/discover.ts @@ -5,16 +5,35 @@ import Media from '../entity/Media'; import { isMovie, isPerson } from '../utils/typeHelpers'; import { MediaType } from '../constants/media'; import { getSettings } from '../lib/settings'; +import { User } from '../entity/User'; + +const createTmdbWithRegionLanaguage = (user?: User): TheMovieDb => { + const settings = getSettings(); + + const region = + user?.settings?.region === 'all' + ? '' + : user?.settings?.region + ? user?.settings?.region + : settings.main.region; + + const originalLanguage = + user?.settings?.originalLanguage === 'all' + ? '' + : user?.settings?.originalLanguage + ? user?.settings?.originalLanguage + : settings.main.originalLanguage; + + return new TheMovieDb({ + region, + originalLanguage, + }); +}; const discoverRoutes = Router(); discoverRoutes.get('/movies', async (req, res) => { - const settings = getSettings(); - const tmdb = new TheMovieDb({ - region: req.user?.settings?.region ?? settings.main.region, - originalLanguage: - req.user?.settings?.originalLanguage ?? settings.main.originalLanguage, - }); + const tmdb = createTmdbWithRegionLanaguage(req.user); const data = await tmdb.getDiscoverMovies({ page: Number(req.query.page), @@ -41,12 +60,7 @@ discoverRoutes.get('/movies', async (req, res) => { }); discoverRoutes.get('/movies/upcoming', async (req, res) => { - const settings = getSettings(); - const tmdb = new TheMovieDb({ - region: req.user?.settings?.region ?? settings.main.region, - originalLanguage: - req.user?.settings?.originalLanguage ?? settings.main.originalLanguage, - }); + const tmdb = createTmdbWithRegionLanaguage(req.user); const now = new Date(); const offset = now.getTimezoneOffset(); @@ -80,12 +94,7 @@ discoverRoutes.get('/movies/upcoming', async (req, res) => { }); discoverRoutes.get('/tv', async (req, res) => { - const settings = getSettings(); - const tmdb = new TheMovieDb({ - region: req.user?.settings?.region ?? settings.main.region, - originalLanguage: - req.user?.settings?.originalLanguage ?? settings.main.originalLanguage, - }); + const tmdb = createTmdbWithRegionLanaguage(req.user); const data = await tmdb.getDiscoverTv({ page: Number(req.query.page), @@ -112,12 +121,7 @@ discoverRoutes.get('/tv', async (req, res) => { }); discoverRoutes.get('/tv/upcoming', async (req, res) => { - const settings = getSettings(); - const tmdb = new TheMovieDb({ - region: req.user?.settings?.region ?? settings.main.region, - originalLanguage: - req.user?.settings?.originalLanguage ?? settings.main.originalLanguage, - }); + const tmdb = createTmdbWithRegionLanaguage(req.user); const now = new Date(); const offset = now.getTimezoneOffset(); @@ -151,12 +155,7 @@ discoverRoutes.get('/tv/upcoming', async (req, res) => { }); discoverRoutes.get('/trending', async (req, res) => { - const settings = getSettings(); - const tmdb = new TheMovieDb({ - region: req.user?.settings?.region ?? settings.main.region, - originalLanguage: - req.user?.settings?.originalLanguage ?? settings.main.originalLanguage, - }); + const tmdb = createTmdbWithRegionLanaguage(req.user); const data = await tmdb.getAllTrending({ page: Number(req.query.page), diff --git a/src/components/RegionSelector/index.tsx b/src/components/RegionSelector/index.tsx index 881174946..5d717c18b 100644 --- a/src/components/RegionSelector/index.tsx +++ b/src/components/RegionSelector/index.tsx @@ -1,37 +1,54 @@ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useMemo, useState } from 'react'; import { Listbox, Transition } from '@headlessui/react'; import { countryCodeEmoji } from 'country-code-emoji'; import useSWR from 'swr'; import type { Region } from '../../../server/lib/settings'; import { defineMessages, useIntl } from 'react-intl'; +import useSettings from '../../hooks/useSettings'; const messages = defineMessages({ regionDefault: 'All Regions', + regionServerDefault: '{applicationTitle} Default ({region})', }); interface RegionSelectorProps { value: string; name: string; + isUserSetting?: boolean; onChange?: (fieldName: string, region: string) => void; } const RegionSelector: React.FC = ({ name, value, + isUserSetting = false, onChange, }) => { + const { currentSettings } = useSettings(); const intl = useIntl(); const { data: regions } = useSWR('/api/v1/regions'); const [selectedRegion, setSelectedRegion] = useState(null); + const allRegion: Region = useMemo( + () => ({ + iso_3166_1: 'all', + english_name: 'All', + }), + [] + ); + useEffect(() => { if (regions && value) { - const matchedRegion = regions.find( - (region) => region.iso_3166_1 === value - ); - setSelectedRegion(matchedRegion ?? null); + if (value === 'all') { + setSelectedRegion(allRegion); + } else { + const matchedRegion = regions.find( + (region) => region.iso_3166_1 === value + ); + setSelectedRegion(matchedRegion ?? null); + } } - }, [value, regions]); + }, [value, regions, allRegion]); useEffect(() => { if (onChange && regions) { @@ -47,15 +64,26 @@ const RegionSelector: React.FC = ({
- {selectedRegion && ( + {selectedRegion && selectedRegion.iso_3166_1 !== 'all' && ( {countryCodeEmoji(selectedRegion.iso_3166_1)} )} - {selectedRegion + {selectedRegion && selectedRegion.iso_3166_1 !== 'all' ? intl.formatDisplayName(selectedRegion.iso_3166_1, { type: 'region', + fallback: 'none', + }) ?? selectedRegion.english_name + : isUserSetting && selectedRegion?.iso_3166_1 !== 'all' + ? intl.formatMessage(messages.regionServerDefault, { + applicationTitle: currentSettings.applicationTitle, + region: currentSettings.region + ? intl.formatDisplayName(currentSettings.region, { + type: 'region', + fallback: 'none', + }) ?? currentSettings.region + : intl.formatMessage(messages.regionDefault), }) : intl.formatMessage(messages.regionDefault)} @@ -89,7 +117,60 @@ const RegionSelector: React.FC = ({ static className="py-1 overflow-auto text-base leading-6 rounded-md shadow-xs max-h-60 focus:outline-none sm:text-sm sm:leading-5" > - + {isUserSetting && ( + + {({ selected, active }) => ( +
+ + {intl.formatMessage(messages.regionServerDefault, { + applicationTitle: + currentSettings.applicationTitle, + region: currentSettings.region + ? intl.formatDisplayName( + currentSettings.region, + { + type: 'region', + fallback: 'none', + } + ) ?? currentSettings.region + : intl.formatMessage(messages.regionDefault), + })} + + {selected && ( + + + + + + )} +
+ )} +
+ )} + {({ selected, active }) => (
{ @@ -36,6 +38,7 @@ const UserGeneralSettings: React.FC = () => { const { addToast } = useToasts(); const router = useRouter(); const { user, mutate } = useUser({ id: Number(router.query.userId) }); + const { currentSettings } = useSettings(); const { data, error, revalidate } = useSWR<{ username?: string; region?: string; @@ -143,6 +146,7 @@ const UserGeneralSettings: React.FC = () => {
@@ -162,6 +166,19 @@ const UserGeneralSettings: React.FC = () => { name="originalLanguage" > + {languages?.map((language) => ( diff --git a/src/i18n/locale/en.json b/src/i18n/locale/en.json index 02ce91d29..677b1aa66 100644 --- a/src/i18n/locale/en.json +++ b/src/i18n/locale/en.json @@ -139,6 +139,7 @@ "components.PlexLoginButton.signingin": "Signing in…", "components.PlexLoginButton.signinwithplex": "Sign In", "components.RegionSelector.regionDefault": "All Regions", + "components.RegionSelector.regionServerDefault": "{applicationTitle} Default ({region})", "components.RequestBlock.profilechanged": "Quality Profile", "components.RequestBlock.requestoverrides": "Request Overrides", "components.RequestBlock.rootfolder": "Root Folder", @@ -679,6 +680,7 @@ "components.UserProfile.ProfileHeader.settings": "Edit Settings", "components.UserProfile.UserSettings.UserGeneralSettings.displayName": "Display Name", "components.UserProfile.UserSettings.UserGeneralSettings.generalsettings": "General Settings", + "components.UserProfile.UserSettings.UserGeneralSettings.languageServerDefault": "{applicationTitle} Default ({language})", "components.UserProfile.UserSettings.UserGeneralSettings.localuser": "Local User", "components.UserProfile.UserSettings.UserGeneralSettings.originalLanguageDefault": "All Languages", "components.UserProfile.UserSettings.UserGeneralSettings.originallanguage": "Discover Language", From 084917f02d399e2d29bb9927e033c2e6533f586c Mon Sep 17 00:00:00 2001 From: sct Date: Sat, 27 Feb 2021 12:41:52 +0000 Subject: [PATCH 05/12] fix: add missing default value for settings context --- src/context/SettingsContext.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/context/SettingsContext.tsx b/src/context/SettingsContext.tsx index 7e709f77a..121543474 100644 --- a/src/context/SettingsContext.tsx +++ b/src/context/SettingsContext.tsx @@ -14,6 +14,7 @@ const defaultSettings = { movie4kEnabled: false, series4kEnabled: false, region: '', + originalLanguage: '', }; export const SettingsContext = React.createContext({ From 9ce88abcc85d744d77172cd2357fdb4ff60dc5e4 Mon Sep 17 00:00:00 2001 From: sct Date: Sat, 27 Feb 2021 12:46:30 +0000 Subject: [PATCH 06/12] fix: added missing language default for ssr context defaults --- src/pages/_app.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 81aa6efde..a088ded47 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -145,6 +145,7 @@ CoreApp.getInitialProps = async (initialProps) => { series4kEnabled: false, localLogin: true, region: '', + originalLanguage: '', }; let locale = 'en'; From abcd7c997584c1310bd8b313ac38f30e335af8d7 Mon Sep 17 00:00:00 2001 From: TheCatLady <52870424+TheCatLady@users.noreply.github.com> Date: Sat, 27 Feb 2021 20:42:09 -0500 Subject: [PATCH 07/12] fix(ui): use country-flag-icons instead of country-flag-emoji for RegionSelector (#1011) --- package.json | 3 ++- src/components/RegionSelector/index.tsx | 29 +++++++++++++++++-------- yarn.lock | 13 +++++++---- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 5d8f25926..867f01c21 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "bowser": "^2.11.0", "connect-typeorm": "^1.1.4", "cookie-parser": "^1.4.5", - "country-code-emoji": "^2.2.0", + "country-flag-icons": "^1.2.9", "csurf": "^1.11.0", "email-templates": "^8.0.3", "express": "^4.17.1", @@ -83,6 +83,7 @@ "@types/bcrypt": "^3.0.0", "@types/body-parser": "^1.19.0", "@types/cookie-parser": "^1.4.2", + "@types/country-flag-icons": "^1.2.0", "@types/csurf": "^1.11.0", "@types/email-templates": "^8.0.2", "@types/express": "^4.17.11", diff --git a/src/components/RegionSelector/index.tsx b/src/components/RegionSelector/index.tsx index 5d717c18b..a254eaf16 100644 --- a/src/components/RegionSelector/index.tsx +++ b/src/components/RegionSelector/index.tsx @@ -1,10 +1,11 @@ import React, { useEffect, useMemo, useState } from 'react'; import { Listbox, Transition } from '@headlessui/react'; -import { countryCodeEmoji } from 'country-code-emoji'; import useSWR from 'swr'; import type { Region } from '../../../server/lib/settings'; import { defineMessages, useIntl } from 'react-intl'; import useSettings from '../../hooks/useSettings'; +import { hasFlag } from 'country-flag-icons'; +import 'country-flag-icons/3x2/flags.css'; const messages = defineMessages({ regionDefault: 'All Regions', @@ -64,11 +65,15 @@ const RegionSelector: React.FC = ({
- {selectedRegion && selectedRegion.iso_3166_1 !== 'all' && ( - - {countryCodeEmoji(selectedRegion.iso_3166_1)} - - )} + {selectedRegion && + selectedRegion.iso_3166_1 !== 'all' && + hasFlag(selectedRegion?.iso_3166_1) && ( + + + + )} {selectedRegion && selectedRegion.iso_3166_1 !== 'all' ? intl.formatDisplayName(selectedRegion.iso_3166_1, { @@ -180,7 +185,7 @@ const RegionSelector: React.FC = ({ {intl.formatMessage(messages.regionDefault)} @@ -217,8 +222,14 @@ const RegionSelector: React.FC = ({ : 'text-gray-300' } cursor-default select-none relative py-2 pl-8 pr-4 flex items-center`} > - - {countryCodeEmoji(region.iso_3166_1)} + + Date: Sat, 27 Feb 2021 21:22:45 -0500 Subject: [PATCH 08/12] chore(github): lock closed support issues (#1045) [skip ci] --- .github/workflows/support.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/support.yml b/.github/workflows/support.yml index 4e9311ec1..9c4bf49e2 100644 --- a/.github/workflows/support.yml +++ b/.github/workflows/support.yml @@ -19,7 +19,8 @@ jobs: to get help with Overseerr. - [Discord](https://discord.gg/PkCWJSeCk7) + - [GitHub Discussions](https://github.com/sct/overseerr/discussions) close-issue: true - lock-issue: false + lock-issue: true issue-lock-reason: 'off-topic' From 3f9a116b17d78eeb04f0f125a4f3af6f907c83dd Mon Sep 17 00:00:00 2001 From: sct Date: Sun, 28 Feb 2021 03:18:22 +0000 Subject: [PATCH 09/12] fix(plex-sync): no longer incorrectly sets 4k availability when there isnt any fixes #990 --- server/job/plexsync/index.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/server/job/plexsync/index.ts b/server/job/plexsync/index.ts index 486fbf908..f4a57c621 100644 --- a/server/job/plexsync/index.ts +++ b/server/job/plexsync/index.ts @@ -666,7 +666,9 @@ class JobPlexSync { isAllStandardSeasons || shouldStayAvailable ? MediaStatus.AVAILABLE : media.seasons.some( - (season) => season.status !== MediaStatus.UNKNOWN + (season) => + season.status === MediaStatus.PARTIALLY_AVAILABLE || + season.status === MediaStatus.AVAILABLE ) ? MediaStatus.PARTIALLY_AVAILABLE : MediaStatus.UNKNOWN; @@ -675,7 +677,9 @@ class JobPlexSync { ? MediaStatus.AVAILABLE : this.enable4kShow && media.seasons.some( - (season) => season.status4k !== MediaStatus.UNKNOWN + (season) => + season.status4k === MediaStatus.PARTIALLY_AVAILABLE || + season.status4k === MediaStatus.AVAILABLE ) ? MediaStatus.PARTIALLY_AVAILABLE : MediaStatus.UNKNOWN; @@ -691,7 +695,9 @@ class JobPlexSync { status: isAllStandardSeasons ? MediaStatus.AVAILABLE : newSeasons.some( - (season) => season.status !== MediaStatus.UNKNOWN + (season) => + season.status === MediaStatus.PARTIALLY_AVAILABLE || + season.status === MediaStatus.AVAILABLE ) ? MediaStatus.PARTIALLY_AVAILABLE : MediaStatus.UNKNOWN, @@ -700,7 +706,9 @@ class JobPlexSync { ? MediaStatus.AVAILABLE : this.enable4kShow && newSeasons.some( - (season) => season.status4k !== MediaStatus.UNKNOWN + (season) => + season.status4k === MediaStatus.PARTIALLY_AVAILABLE || + season.status4k === MediaStatus.AVAILABLE ) ? MediaStatus.PARTIALLY_AVAILABLE : MediaStatus.UNKNOWN, From 3fed26cfbe74cb662ca531fd37b69f159a051ac1 Mon Sep 17 00:00:00 2001 From: TheCatLady <52870424+TheCatLady@users.noreply.github.com> Date: Sat, 27 Feb 2021 22:34:56 -0500 Subject: [PATCH 10/12] fix(ui): for server default options, display "All" region/language option instead of empty string (#1042) --- src/components/RegionSelector/index.tsx | 48 ++++++++++++------- .../UserGeneralSettings/index.tsx | 27 +++++++---- src/i18n/locale/en.json | 4 +- 3 files changed, 51 insertions(+), 28 deletions(-) diff --git a/src/components/RegionSelector/index.tsx b/src/components/RegionSelector/index.tsx index a254eaf16..4537d5547 100644 --- a/src/components/RegionSelector/index.tsx +++ b/src/components/RegionSelector/index.tsx @@ -9,7 +9,7 @@ import 'country-flag-icons/3x2/flags.css'; const messages = defineMessages({ regionDefault: 'All Regions', - regionServerDefault: '{applicationTitle} Default ({region})', + regionServerDefault: 'Default ({region})', }); interface RegionSelectorProps { @@ -38,6 +38,10 @@ const RegionSelector: React.FC = ({ [] ); + const defaultRegionNameFallback = + regions?.find((region) => region.iso_3166_1 === currentSettings.region) + ?.english_name ?? currentSettings.region; + useEffect(() => { if (regions && value) { if (value === 'all') { @@ -65,15 +69,21 @@ const RegionSelector: React.FC = ({
- {selectedRegion && - selectedRegion.iso_3166_1 !== 'all' && - hasFlag(selectedRegion?.iso_3166_1) && ( - - - - )} + {((selectedRegion && hasFlag(selectedRegion?.iso_3166_1)) || + (isUserSetting && + !selectedRegion && + currentSettings.region && + hasFlag(currentSettings.region))) && ( + + + + )} {selectedRegion && selectedRegion.iso_3166_1 !== 'all' ? intl.formatDisplayName(selectedRegion.iso_3166_1, { @@ -82,12 +92,11 @@ const RegionSelector: React.FC = ({ }) ?? selectedRegion.english_name : isUserSetting && selectedRegion?.iso_3166_1 !== 'all' ? intl.formatMessage(messages.regionServerDefault, { - applicationTitle: currentSettings.applicationTitle, region: currentSettings.region ? intl.formatDisplayName(currentSettings.region, { type: 'region', fallback: 'none', - }) ?? currentSettings.region + }) ?? defaultRegionNameFallback : intl.formatMessage(messages.regionDefault), }) : intl.formatMessage(messages.regionDefault)} @@ -130,16 +139,23 @@ const RegionSelector: React.FC = ({ active ? 'text-white bg-indigo-600' : 'text-gray-300' - } cursor-default select-none relative py-2 pl-8 pr-4`} + } cursor-default select-none relative py-2 pl-8 pr-4 flex items-center`} > + + + {intl.formatMessage(messages.regionServerDefault, { - applicationTitle: - currentSettings.applicationTitle, region: currentSettings.region ? intl.formatDisplayName( currentSettings.region, @@ -147,7 +163,7 @@ const RegionSelector: React.FC = ({ type: 'region', fallback: 'none', } - ) ?? currentSettings.region + ) ?? defaultRegionNameFallback : intl.formatMessage(messages.regionDefault), })} diff --git a/src/components/UserProfile/UserSettings/UserGeneralSettings/index.tsx b/src/components/UserProfile/UserSettings/UserGeneralSettings/index.tsx index 8e0a07655..d426f87cf 100644 --- a/src/components/UserProfile/UserSettings/UserGeneralSettings/index.tsx +++ b/src/components/UserProfile/UserSettings/UserGeneralSettings/index.tsx @@ -30,7 +30,7 @@ const messages = defineMessages({ originallanguageTip: 'Filter content by original language (only applies to the "Popular" and "Upcoming" categories)', originalLanguageDefault: 'All Languages', - languageServerDefault: '{applicationTitle} Default ({language})', + languageServerDefault: 'Default ({language})', }); const UserGeneralSettings: React.FC = () => { @@ -61,6 +61,11 @@ const UserGeneralSettings: React.FC = () => { return ; } + const defaultLanguageNameFallback = + languages.find( + (language) => language.iso_639_1 === currentSettings.originalLanguage + )?.english_name ?? currentSettings.originalLanguage; + return ( <>
@@ -167,15 +172,17 @@ const UserGeneralSettings: React.FC = () => { >