diff --git a/lumen/i18n-keys.json b/lumen/i18n-keys.json index bda5e4c..c3bb311 100644 --- a/lumen/i18n-keys.json +++ b/lumen/i18n-keys.json @@ -2299,6 +2299,38 @@ "lumen.browse.browseGenres", "lumen.browse.checkedPopular", "lumen.browse.clearFilters", + "lumen.browse.filters", + "lumen.browse.filtersDone", + "lumen.browse.removeFilter", + "lumen.browse.notFilter", + "lumen.browse.activeFilters", + "lumen.filters.clearAll", + "lumen.search.someSourcesFailed", + "lumen.search.source.books", + "lumen.search.source.comics", + "lumen.search.source.titles", + "lumen.search.source.some", + "lumen.detail.moreActions", + "lumen.detail.more", + "lumen.detail.close", + "lumen.detail.showMore", + "lumen.detail.showLess", + "lumen.account.jumpTo", + "lumen.account.importLists", + "lumen.me.importLists", + "lumen.me.importListsHelp", + "lumen.music.player.hearth", + "lumen.music.player.hearthHelp", + "lumen.music.backToDiscover", + "lumen.adminSettings.musicAppsTitle", + "lumen.adminSettings.musicAppsHelp", + "lumen.adminSettings.musicDefaultApp", + "lumen.podcasts.followingFilter", + "lumen.podcasts.filterAll", + "lumen.podcasts.filterFollowing", + "lumen.podcasts.filterNotFollowing", + "lumen.podcasts.noneFollowed", + "lumen.podcasts.allFollowed", "lumen.browse.clearNetwork", "lumen.browse.clearStudio", "lumen.browse.clearSubjectTags", @@ -6916,5 +6948,21 @@ "i18n.loading", "i18n.saving", "library.episodes", - "library.library" + "library.library", + "lumen.music.allSongs", + "lumen.detail.discoverNavigation", + "lumen.videoRating.showAll", + "lumen.status.hdAnd4k", + "lumen.detail.showAllCount", + "lumen.detail.castCrew", + "lumen.detail.details", + "lumen.music.creditsDetails", + "lumen.me.libraryTools", + "lumen.admin.home.mediaServices", + "lumen.detail.allEditions", + "lumen.detail.showFewer", + "lumen.bookDetail.allNarrations", + "lumen.bookDetail.edition", + "lumen.bookDetail.ebookEpub", + "lumen.bookDetail.pageCount" ] diff --git a/lumen/i18n-overrides.json b/lumen/i18n-overrides.json index eb171df..8e7eb06 100644 --- a/lumen/i18n-overrides.json +++ b/lumen/i18n-overrides.json @@ -1853,6 +1853,38 @@ "lumen.browse.countries": "countries", "lumen.browse.originalLanguages": "original languages", "lumen.browse.clearFilters": "Clear Discovery Filters", + "lumen.browse.filters": "Filters", + "lumen.browse.filtersDone": "Show results", + "lumen.browse.removeFilter": "Remove {name}", + "lumen.browse.notFilter": "Not {name}", + "lumen.browse.activeFilters": "Active filters", + "lumen.filters.clearAll": "Clear all", + "lumen.search.someSourcesFailed": "Some sources didn’t answer ({sources}).", + "lumen.search.source.books": "Books", + "lumen.search.source.comics": "Comics", + "lumen.search.source.titles": "Movies, series and music", + "lumen.search.source.some": "some providers", + "lumen.detail.moreActions": "More actions", + "lumen.detail.more": "More", + "lumen.detail.close": "Close", + "lumen.detail.showMore": "Show more", + "lumen.detail.showLess": "Show less", + "lumen.account.jumpTo": "Jump to", + "lumen.account.importLists": "Import lists", + "lumen.me.importLists": "Import lists", + "lumen.me.importListsHelp": "IMDb watchlists, Goodreads and Hardcover shelves", + "lumen.music.player.hearth": "Hearth app", + "lumen.music.player.hearthHelp": "Opens it in the Hearth app on this phone.", + "lumen.music.backToDiscover": "Back to Discover", + "lumen.adminSettings.musicAppsTitle": "Music apps", + "lumen.adminSettings.musicAppsHelp": "The apps people can pick for Play on music. Aurral is offered only when an Aurral service is set up, and Hearth only on Android phones. With none on, Play is off and songs keep their previews.", + "lumen.adminSettings.musicDefaultApp": "Default app", + "lumen.podcasts.followingFilter": "Following", + "lumen.podcasts.filterAll": "All", + "lumen.podcasts.filterFollowing": "Following", + "lumen.podcasts.filterNotFollowing": "Not following", + "lumen.podcasts.noneFollowed": "You don’t follow any of these shows yet.", + "lumen.podcasts.allFollowed": "You already follow every show here.", "lumen.browse.availability": "Availability", "lumen.browse.all": "All", "lumen.browse.onServer": "On {server}", @@ -4920,9 +4952,9 @@ "lumen.mediaServerCollections.loading": "Loading collections…", "lumen.mediaServerCollections.loadFailed": "Collections could not be loaded or confirmed.", "lumen.mediaServerCollections.retry": "Reload collections", - "lumen.tv.episodeQueue.off": "Episode Queue · off · managed by admin", - "lumen.tv.episodeQueue.one": "Episode Queue · 1 episode set by admin", - "lumen.tv.episodeQueue.many": "Episode Queue · {count} episodes set by admin", + "lumen.tv.episodeQueue.off": "Episode Queue: off", + "lumen.tv.episodeQueue.one": "Episode Queue: 1 episode", + "lumen.tv.episodeQueue.many": "Episode Queue: {count} episodes", "lumen.videoPlayback.open": "Playback Options", "lumen.videoPlayback.title": "Play Movie", "lumen.videoPlayback.quality4k": "Playback quality: 4K", @@ -5495,7 +5527,23 @@ "lumen.readerDelivery.comics": "Comics", "lumen.readerDelivery.magazinePdfs": "Magazine PDFs", "lumen.category.disabledForServer": "{category} is turned off on this server.", - "lumen.settings.confirmFailed": "The server accepted the change, but Lumen could not confirm the saved state. Keep this form open and retry." + "lumen.settings.confirmFailed": "The server accepted the change, but Lumen could not confirm the saved state. Keep this form open and retry.", + "lumen.music.allSongs": "All {count} songs", + "lumen.videoRating.showAll": "Show all {count} ratings", + "lumen.detail.discoverNavigation": "Other titles from Discover", + "lumen.status.hdAnd4k": "HD + 4K", + "lumen.detail.showAllCount": "Show all ({count})", + "lumen.detail.castCrew": "Cast & Crew", + "lumen.detail.details": "Details", + "lumen.music.creditsDetails": "Credits & Details", + "lumen.me.libraryTools": "Library & Tools", + "lumen.admin.home.mediaServices": "Media Services", + "lumen.detail.allEditions": "All {count} editions", + "lumen.detail.showFewer": "Show fewer", + "lumen.bookDetail.allNarrations": "All {count} narrations", + "lumen.bookDetail.edition": "Edition", + "lumen.bookDetail.ebookEpub": "Ebook · EPUB", + "lumen.bookDetail.pageCount": "{count} pages" }, "fr": { "components.IssueDetails.allepisodes": "Tous les épisodes", @@ -7511,6 +7559,38 @@ "lumen.browse.countries": "pays", "lumen.browse.originalLanguages": "langues d’origine", "lumen.browse.clearFilters": "Effacer les filtres de découverte", + "lumen.browse.filters": "Filtres", + "lumen.browse.filtersDone": "Voir les résultats", + "lumen.browse.removeFilter": "Retirer {name}", + "lumen.browse.notFilter": "Sauf {name}", + "lumen.browse.activeFilters": "Filtres actifs", + "lumen.filters.clearAll": "Tout effacer", + "lumen.search.someSourcesFailed": "Certaines sources n’ont pas répondu ({sources}).", + "lumen.search.source.books": "Livres", + "lumen.search.source.comics": "BD", + "lumen.search.source.titles": "Films, séries et musique", + "lumen.search.source.some": "certains fournisseurs", + "lumen.detail.moreActions": "Autres actions", + "lumen.detail.more": "Plus", + "lumen.detail.close": "Fermer", + "lumen.detail.showMore": "Afficher plus", + "lumen.detail.showLess": "Afficher moins", + "lumen.account.jumpTo": "Aller à", + "lumen.account.importLists": "Importer des listes", + "lumen.me.importLists": "Importer des listes", + "lumen.me.importListsHelp": "Listes IMDb, étagères Goodreads et Hardcover", + "lumen.music.player.hearth": "Appli Hearth", + "lumen.music.player.hearthHelp": "L’ouvre dans l’appli Hearth sur ce téléphone.", + "lumen.music.backToDiscover": "Retour à Découvrir", + "lumen.adminSettings.musicAppsTitle": "Applis de musique", + "lumen.adminSettings.musicAppsHelp": "Les applis que chacun peut choisir pour Lire la musique. Aurral n’apparaît que si un service Aurral est configuré, et Hearth seulement sur les téléphones Android. Sans aucune appli, Lire est désactivé et les extraits restent.", + "lumen.adminSettings.musicDefaultApp": "Appli par défaut", + "lumen.podcasts.followingFilter": "Abonnements", + "lumen.podcasts.filterAll": "Tous", + "lumen.podcasts.filterFollowing": "Suivis", + "lumen.podcasts.filterNotFollowing": "Non suivis", + "lumen.podcasts.noneFollowed": "Vous ne suivez encore aucune de ces émissions.", + "lumen.podcasts.allFollowed": "Vous suivez déjà toutes ces émissions.", "lumen.browse.availability": "Disponibilité", "lumen.browse.all": "Tout", "lumen.browse.onServer": "Sur {server}", @@ -10538,9 +10618,9 @@ "lumen.mediaServerCollections.loading": "Chargement des collections…", "lumen.mediaServerCollections.loadFailed": "Impossible de charger ou de confirmer les collections.", "lumen.mediaServerCollections.retry": "Recharger les collections", - "lumen.tv.episodeQueue.off": "File d’attente des épisodes · désactivée · gérée par l’administrateur", - "lumen.tv.episodeQueue.one": "File d’attente des épisodes · 1 épisode défini par l’administrateur", - "lumen.tv.episodeQueue.many": "File d’attente des épisodes · {count} épisodes définis par l’administrateur", + "lumen.tv.episodeQueue.off": "File d’attente des épisodes : désactivée", + "lumen.tv.episodeQueue.one": "File d’attente des épisodes : 1 épisode", + "lumen.tv.episodeQueue.many": "File d’attente des épisodes : {count} épisodes", "lumen.videoPlayback.open": "Options de lecture", "lumen.videoPlayback.title": "Lire le film", "lumen.videoPlayback.quality4k": "Qualité de lecture : 4K", @@ -11285,7 +11365,23 @@ "components.Discover.DiscoverComics.indexing": "Créer l’index des bandes dessinées", "components.Discover.DiscoverComics.indexingRetry": "L’indexation reprend après la réponse du fournisseur. Les volumes déjà indexés sont conservés.", "components.Discover.DiscoverComics.noComicVineKey": "L’exploration des bandes dessinées nécessite une clé API ComicVine configurée dans les paramètres.", - "components.Discover.DiscoverComics.searchComics": "Rechercher des BD" + "components.Discover.DiscoverComics.searchComics": "Rechercher des BD", + "lumen.music.allSongs": "Les {count} titres", + "lumen.videoRating.showAll": "Afficher les {count} notes", + "lumen.detail.discoverNavigation": "Autres titres de Découvrir", + "lumen.status.hdAnd4k": "HD + 4K", + "lumen.detail.showAllCount": "Tout afficher ({count})", + "lumen.detail.castCrew": "Distribution et équipe", + "lumen.detail.details": "Détails", + "lumen.music.creditsDetails": "Crédits et détails", + "lumen.me.libraryTools": "Bibliothèque et outils", + "lumen.admin.home.mediaServices": "Services multimédias", + "lumen.detail.allEditions": "Les {count} éditions", + "lumen.detail.showFewer": "Afficher moins", + "lumen.bookDetail.allNarrations": "Les {count} narrations", + "lumen.bookDetail.edition": "Édition", + "lumen.bookDetail.ebookEpub": "Livre numérique · EPUB", + "lumen.bookDetail.pageCount": "{count} pages" }, "ar": { "components.IssueDetails.allepisodes": "جميع الحلقات", @@ -13313,6 +13409,38 @@ "lumen.browse.countries": "البلدان", "lumen.browse.originalLanguages": "اللغات الأصلية", "lumen.browse.clearFilters": "مسح عوامل تصفية الاستكشاف", + "lumen.browse.filters": "عوامل التصفية", + "lumen.browse.filtersDone": "عرض النتائج", + "lumen.browse.removeFilter": "إزالة {name}", + "lumen.browse.notFilter": "باستثناء {name}", + "lumen.browse.activeFilters": "عوامل التصفية النشطة", + "lumen.filters.clearAll": "مسح الكل", + "lumen.search.someSourcesFailed": "لم تستجب بعض المصادر ({sources}).", + "lumen.search.source.books": "الكتب", + "lumen.search.source.comics": "القصص المصورة", + "lumen.search.source.titles": "الأفلام والمسلسلات والموسيقى", + "lumen.search.source.some": "بعض المزوّدين", + "lumen.detail.moreActions": "إجراءات أخرى", + "lumen.detail.more": "المزيد", + "lumen.detail.close": "إغلاق", + "lumen.detail.showMore": "عرض المزيد", + "lumen.detail.showLess": "عرض أقل", + "lumen.account.jumpTo": "انتقل إلى", + "lumen.account.importLists": "استيراد القوائم", + "lumen.me.importLists": "استيراد القوائم", + "lumen.me.importListsHelp": "قوائم IMDb ورفوف Goodreads وHardcover", + "lumen.music.player.hearth": "تطبيق Hearth", + "lumen.music.player.hearthHelp": "يفتحه في تطبيق Hearth على هذا الهاتف.", + "lumen.music.backToDiscover": "العودة إلى الاستكشاف", + "lumen.adminSettings.musicAppsTitle": "تطبيقات الموسيقى", + "lumen.adminSettings.musicAppsHelp": "التطبيقات التي يمكن للأشخاص اختيارها للتشغيل. يظهر Aurral فقط عند إعداد خدمة Aurral، ويظهر Hearth فقط على هواتف Android. إذا لم يُفعَّل أي تطبيق يتوقف التشغيل وتبقى المقتطفات.", + "lumen.adminSettings.musicDefaultApp": "التطبيق الافتراضي", + "lumen.podcasts.followingFilter": "المتابَعة", + "lumen.podcasts.filterAll": "الكل", + "lumen.podcasts.filterFollowing": "المتابَعة", + "lumen.podcasts.filterNotFollowing": "غير المتابَعة", + "lumen.podcasts.noneFollowed": "لا تتابع أيًا من هذه البرامج بعد.", + "lumen.podcasts.allFollowed": "أنت تتابع كل البرامج هنا بالفعل.", "lumen.browse.availability": "التوفر", "lumen.browse.all": "الكل", "lumen.browse.onServer": "على {server}", @@ -16344,9 +16472,9 @@ "lumen.mediaServerCollections.loading": "جارٍ تحميل المجموعات…", "lumen.mediaServerCollections.loadFailed": "تعذر تحميل المجموعات أو تأكيد التغيير.", "lumen.mediaServerCollections.retry": "إعادة تحميل المجموعات", - "lumen.tv.episodeQueue.off": "قائمة انتظار الحلقات · متوقفة · يديرها المسؤول", - "lumen.tv.episodeQueue.one": "قائمة انتظار الحلقات · حلقة واحدة يحددها المسؤول", - "lumen.tv.episodeQueue.many": "قائمة انتظار الحلقات · {count} حلقات يحددها المسؤول", + "lumen.tv.episodeQueue.off": "قائمة انتظار الحلقات: متوقفة", + "lumen.tv.episodeQueue.one": "قائمة انتظار الحلقات: حلقة واحدة", + "lumen.tv.episodeQueue.many": "قائمة انتظار الحلقات: {count} حلقات", "lumen.videoPlayback.open": "خيارات التشغيل", "lumen.videoPlayback.title": "تشغيل الفيلم", "lumen.videoPlayback.quality4k": "جودة التشغيل: 4K", @@ -17092,6 +17220,22 @@ "components.Discover.DiscoverComics.indexing": "جارٍ إنشاء فهرس القصص المصوّرة", "components.Discover.DiscoverComics.indexingRetry": "تُعاد محاولة الفهرسة بعد استجابة المزوّد. تم حفظ المجلدات المفهرسة بالفعل.", "components.Discover.DiscoverComics.noComicVineKey": "يتطلب استكشاف القصص المصوّرة إعداد مفتاح ComicVine API في الإعدادات.", - "components.Discover.DiscoverComics.searchComics": "البحث عن القصص المصوّرة" + "components.Discover.DiscoverComics.searchComics": "البحث عن القصص المصوّرة", + "lumen.music.allSongs": "كل الأغاني ({count})", + "lumen.videoRating.showAll": "عرض كل التقييمات ({count})", + "lumen.detail.discoverNavigation": "عناوين أخرى من الاستكشاف", + "lumen.status.hdAnd4k": "HD + 4K", + "lumen.detail.showAllCount": "عرض الكل ({count})", + "lumen.detail.castCrew": "طاقم التمثيل والعمل", + "lumen.detail.details": "التفاصيل", + "lumen.music.creditsDetails": "الاعتمادات والتفاصيل", + "lumen.me.libraryTools": "المكتبة والأدوات", + "lumen.admin.home.mediaServices": "خدمات الوسائط", + "lumen.detail.allEditions": "كل الإصدارات ({count})", + "lumen.detail.showFewer": "عرض عدد أقل", + "lumen.bookDetail.allNarrations": "كل التسجيلات ({count})", + "lumen.bookDetail.edition": "الإصدار", + "lumen.bookDetail.ebookEpub": "كتاب إلكتروني · EPUB", + "lumen.bookDetail.pageCount": "{count} صفحة" } } diff --git a/lumen/src/components/BookRequestOptions.tsx b/lumen/src/components/BookRequestOptions.tsx index c857b9b..4edfec8 100644 --- a/lumen/src/components/BookRequestOptions.tsx +++ b/lumen/src/components/BookRequestOptions.tsx @@ -4,6 +4,7 @@ import { useAuth } from '../auth'; import { friendlyError } from '../errors'; import { useApi } from '../hooks'; import { useLumenLocale } from '../i18n'; +import { Icon } from '../icons'; import { canChooseRequestOptions, canRequestAs } from './detail'; type Format = 'ebook' | 'audiobook'; @@ -110,6 +111,7 @@ export default function BookRequestOptions({ onToggle={(event) => setOpen(event.currentTarget.open)} > + {t('lumen.bulkBooks.advancedOptions', 'Advanced Request Options')}
diff --git a/lumen/src/components/ClampText.tsx b/lumen/src/components/ClampText.tsx new file mode 100644 index 0000000..6bc94ce --- /dev/null +++ b/lumen/src/components/ClampText.tsx @@ -0,0 +1,50 @@ +import { useLayoutEffect, useRef, useState, type ReactNode } from 'react'; +import { useLumenLocale } from '../i18n'; +import { usePhone } from './PhoneFilters'; + +// Long descriptions on phones show about four lines, with Show more for the rest. +export function ClampText({ + children, + className = 'ov', + lines, +}: { + children: ReactNode; + className?: string; + // a fixed number of lines on every screen size (default: four, phones only) + lines?: number; +}) { + const { t } = useLumenLocale(); + const phone = usePhone() || lines !== undefined; + const box = useRef(null); + const [overflows, setOverflows] = useState(false); + const [open, setOpen] = useState(false); + useLayoutEffect(() => { + const node = box.current; + if (!node || !phone || open) return; + setOverflows(node.scrollHeight > node.clientHeight + 2); + }, [phone, open, children]); + return ( +
+

+ {children} +

+ {phone && (overflows || open) && ( + + )} +
+ ); +} diff --git a/lumen/src/components/EditionPreview.tsx b/lumen/src/components/EditionPreview.tsx new file mode 100644 index 0000000..1cce60a --- /dev/null +++ b/lumen/src/components/EditionPreview.tsx @@ -0,0 +1,39 @@ +import { useLumenLocale } from '../i18n'; + +// Edition and narration pickers show the first few rows; the rest open with "All N editions". +export const EDITION_PREVIEW = 4; + +// Only folds when it hides at least two rows. A row kept by `keep` (the selection) always shows. +export const foldsEditions = (count: number) => count > EDITION_PREVIEW + 1; + +export function previewRows( + rows: T[], + open: boolean, + keep: (row: T) => boolean +): T[] { + if (open || !foldsEditions(rows.length)) return rows; + return rows.filter((row, i) => i < EDITION_PREVIEW || keep(row)); +} + +export function MoreEditions({ + open, + onToggle, + label, +}: { + open: boolean; + onToggle: () => void; + // the closed label, e.g. "All 12 editions" + label: string; +}) { + const { t } = useLumenLocale(); + return ( + + ); +} diff --git a/lumen/src/components/ExternalRequestLists.tsx b/lumen/src/components/ExternalRequestLists.tsx index be9cc69..23577da 100644 --- a/lumen/src/components/ExternalRequestLists.tsx +++ b/lumen/src/components/ExternalRequestLists.tsx @@ -174,6 +174,7 @@ export function ExternalRequestLists() { return (

diff --git a/lumen/src/components/MoreActions.tsx b/lumen/src/components/MoreActions.tsx new file mode 100644 index 0000000..eac31f4 --- /dev/null +++ b/lumen/src/components/MoreActions.tsx @@ -0,0 +1,136 @@ +import { + createContext, + useContext, + useLayoutEffect, + useRef, + useState, + type ReactNode, +} from 'react'; +import { useLumenLocale } from '../i18n'; +import { Icon } from '../icons'; +import { Section } from './cards'; +import { FilterSheet, usePhone } from './PhoneFilters'; + +// Phones keep a detail page's main actions in view and fold the occasional ones (indexer +// search, blocklist, issue reports, associations and the like) into one More sheet; wider +// screens show them inline as before. Each action keeps its own permission check: More only +// shows when two or more of them have something to offer; a single one shows in place. +export function MoreActions({ children }: { children: ReactNode }) { + const { t } = useLumenLocale(); + const phone = usePhone(); + const probe = useRef(null); + const [count, setCount] = useState(0); + const [open, setOpen] = useState(false); + useLayoutEffect(() => { + const node = probe.current; + if (!node) return; + const check = () => setCount(node.childElementCount); + check(); + const watcher = new MutationObserver(check); + watcher.observe(node, { childList: true }); + return () => watcher.disconnect(); + }, [phone]); + if (!phone) return {children}; + const label = t('lumen.detail.moreActions', 'More actions'); + return ( + <> + {/* one action needs no sheet: it shows in place */} + + {count > 1 && ( + + )} + {open && ( + setOpen(false)} + done={t('lumen.detail.close', 'Close')} + > +

{children}
+ + )} + + ); +} + +// Inside a folded phone group, PhoneSubsection shows a small heading instead of a section. +const PhoneGroupContext = createContext(false); + +// A settings group that phones fold behind its title; wider screens keep the open section. +// With splitOnWide, wider screens show each PhoneSubsection inside as its own section (as +// before), while phones fold them together under one title. +export function PhoneSection({ + title, + id, + splitOnWide = false, + children, +}: { + title: string; + id?: string; + splitOnWide?: boolean; + children: ReactNode; +}) { + const phone = usePhone(); + if (!phone) + return splitOnWide ? ( + <>{children} + ) : ( +
+ {children} +
+ ); + return ( +
+ {/* still a heading for screen readers and page outlines while folded */} + + +

{title}

+
+
+ + {children} + +
+
+ ); +} + +// One group inside a combined PhoneSection: its own section on wider screens, a small +// heading inside the shared fold on phones. +export function PhoneSubsection({ + title, + id, + children, +}: { + title: string; + id?: string; + children: ReactNode; +}) { + const grouped = useContext(PhoneGroupContext); + if (!grouped) + return ( +
+ {children} +
+ ); + return ( +
+

{title}

+ {children} +
+ ); +} diff --git a/lumen/src/components/MusicPlayback.tsx b/lumen/src/components/MusicPlayback.tsx index 5b0f021..d9461d6 100644 --- a/lumen/src/components/MusicPlayback.tsx +++ b/lumen/src/components/MusicPlayback.tsx @@ -1,18 +1,19 @@ -import { useRef, useState } from 'react'; -import { createPortal } from 'react-dom'; import type { MusicServiceSummary } from '../api'; import { useAuth } from '../auth'; import { useApi } from '../hooks'; import { useLumenLocale } from '../i18n'; import { Icon } from '../icons'; import { + allowedMusicPlayers, + asMusicPlayer, aurralBaseUrl, AVAILABLE_MUSIC_PLAYERS, - MUSIC_PLAYERS, + isAndroid, openPlayer, playLink, previewKey, stopPreview, + storedMusicPlayer, togglePreview, usePreview, usePreviewStatus, @@ -22,27 +23,38 @@ import { } from '../musicPlayback'; import { usePrefs } from '../settings'; import { Cover } from './cards'; -import { useDialog } from './useDialog'; -// Where Play goes for this person, and whether that app is reachable. +// Where Play goes for this person. The picker offers the apps the admin allows (Lumen +// settings), Aurral only with an Aurral service and Hearth only on Android phones; a saved +// choice that is no longer offered falls back to the admin's default, then the first app. +// With no app offered, Play has nowhere to go and songs keep their previews. export function useMusicPlayer() { const { user } = useAuth(); - const { prefs, set } = usePrefs(); + const { prefs, set, adminConfig, locked } = usePrefs(); const services = useApi( user ? '/service/music' : null ); const aurralBase = aurralBaseUrl(services.data); - const chosen: MusicPlayer = AVAILABLE_MUSIC_PLAYERS.includes( - prefs.musicPlayer - ) - ? prefs.musicPlayer - : 'aurral'; - // no Aurral to open (a Lidarr setup): Play searches Plex instead - const player: MusicPlayer = - chosen === 'aurral' && services.data && !aurralBase ? 'plex' : chosen; - const linkFor = (target: PlayTarget) => playLink(player, target, aurralBase); + const offered = allowedMusicPlayers(adminConfig.musicPlayers).filter( + (value) => + AVAILABLE_MUSIC_PLAYERS.includes(value) && + (value !== 'aurral' || !services.data || Boolean(aurralBase)) && + (value !== 'hearth' || isAndroid()) + ); + const chosen = asMusicPlayer(prefs.musicPlayer); + const adminDefault = asMusicPlayer(adminConfig.defaults?.musicPlayer); + const player: MusicPlayer | null = + chosen && offered.includes(chosen) + ? chosen + : adminDefault && offered.includes(adminDefault) + ? adminDefault + : (offered[0] ?? null); + const linkFor = (target: PlayTarget) => + player ? playLink(player, target, aurralBase) : null; return { player, + offered, + locked: locked.has('musicPlayer'), previews: prefs.musicPreviews, aurralBase, linkFor, @@ -50,49 +62,34 @@ export function useMusicPlayer() { const url = linkFor(target); if (url) openPlayer(url); }, - setPlayer: (value: MusicPlayer) => set('musicPlayer', value), + setPlayer: (value: MusicPlayer) => + set('musicPlayer', storedMusicPlayer(value)), setPreviews: (value: boolean) => set('musicPreviews', value), }; } -const playerName = ( +export const playerName = ( player: MusicPlayer, t: ReturnType['t'] ) => player === 'plex' ? 'Plex' - : player === 'shelf' - ? t('lumen.music.player.shelf', 'Shelf app') + : player === 'hearth' + ? t('lumen.music.player.hearth', 'Hearth app') : 'Aurral'; -export function PlayOpensIn() { - const { t } = useLumenLocale(); - const { player } = useMusicPlayer(); - const [open, setOpen] = useState(false); - return ( - <> - - {open && setOpen(false)} />} - - ); -} - -function PlayOpensInSheet({ onClose }: { onClose: () => void }) { +// "When you press Play" on the You page: the music app and the 30-second previews. +export function MusicPlayerSettings() { const { t } = useLumenLocale(); - const box = useRef(null); - useDialog(box, onClose); - const { player, previews, setPlayer, setPreviews, aurralBase } = - useMusicPlayer(); + const { + player, + offered, + locked, + previews, + setPlayer, + setPreviews, + aurralBase, + } = useMusicPlayer(); const help: Record = { aurral: aurralBase ? t( @@ -107,106 +104,71 @@ function PlayOpensInSheet({ onClose }: { onClose: () => void }) { 'lumen.music.player.plexHelp', 'Searches for it in Plex, in the same reused tab.' ), - shelf: t( - 'lumen.music.player.shelfHelp', - 'The Shelf phone app. Coming once the app can open links.' + hearth: t( + 'lumen.music.player.hearthHelp', + 'Opens it in the Hearth app on this phone.' ), }; - return createPortal( -
-
-
-
- {(Object.keys(DISCOVER_ROWS) as DiscoverRow[]).map((r) => ( - - ))} -
-
+
+

+ {admin( + 'musicAppsHelp', + 'The apps people can pick for Play on music. Aurral is offered only when an Aurral service is set up, and Hearth only on Android phones. With none on, Play is off and songs keep their previews.' + )} +

+
+ {MUSIC_PLAYERS.map((app) => ( + + ))} + {musicApps.length > 0 && ( +
+ + {admin('musicDefaultApp', 'Default app')} + + +
+ )} + {musicApps.length > 0 && ( +
+ setLock('musicPlayer', lock)} + /> +
+ )} +
+
-
-
- - - - {embedded && ( - - )} -
-