Compare commits
No files matched your search
+1
-18
@@ -44,24 +44,7 @@
|
||||
[
|
||||
"expo-splash-screen",
|
||||
{
|
||||
"ios": {
|
||||
"backgroundColor": "#ffffff",
|
||||
"image": "./assets/ios-icon.png",
|
||||
"dark": {
|
||||
"image": "./assets/ios-icon-dark.png",
|
||||
"backgroundColor": "#000000"
|
||||
},
|
||||
"imageWidth": 200
|
||||
},
|
||||
"android": {
|
||||
"backgroundColor": "#ffffff",
|
||||
"image": "./assets/icon.png",
|
||||
"dark": {
|
||||
"image": "./assets/icon-dark.png",
|
||||
"backgroundColor": "#000000"
|
||||
},
|
||||
"imageWidth": 200
|
||||
}
|
||||
"backgroundColor": "#000000"
|
||||
}
|
||||
],
|
||||
"expo-image",
|
||||
|
||||
@@ -7,6 +7,8 @@ import { TabBottomAccessory } from "@/components/mini-player"
|
||||
import { usePlaybackQueue } from "@/contexts/playback"
|
||||
import { appleMusic, colors } from "@/lib/theme"
|
||||
|
||||
export const unstable_settings = { anchor: "library" }
|
||||
|
||||
function useRouterTheme() {
|
||||
const isDark = useColorScheme() === "dark"
|
||||
|
||||
|
||||
@@ -149,6 +149,7 @@ export default function AlbumScreen() {
|
||||
headerTintColor: palette.foreground,
|
||||
headerRight: () => (
|
||||
<MediaActionMenu
|
||||
stationArtistId={album.artist.id}
|
||||
selectedCount={album.tracks.length}
|
||||
favorited={isAlbumFav(album.id)}
|
||||
share={{ type: "album", albumId: album.id }}
|
||||
@@ -156,7 +157,8 @@ export default function AlbumScreen() {
|
||||
void handleAlbumDetailAction(
|
||||
album.id as Id<"albums">,
|
||||
songIds,
|
||||
action
|
||||
action,
|
||||
album.artist.id as Id<"artists">
|
||||
)
|
||||
}
|
||||
>
|
||||
@@ -321,6 +323,7 @@ const AlbumTrackRow = memo(function AlbumTrackRow({
|
||||
}) {
|
||||
return (
|
||||
<MediaContextMenu
|
||||
stationArtistId={album.artist.id}
|
||||
favorited={favorited}
|
||||
navigation={{
|
||||
artist: { id: album.artist.id },
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Ionicons } from "@expo/vector-icons"
|
||||
import { useAction, useMutation, useQuery } from "convex/react"
|
||||
import { Image } from "expo-image"
|
||||
import * as ImagePicker from "expo-image-picker"
|
||||
import { useRouter } from "expo-router"
|
||||
import { useState } from "react"
|
||||
import {
|
||||
Pressable,
|
||||
@@ -20,7 +19,7 @@ import { useInvalidateAuthSession } from "@/contexts/convex-auth-session"
|
||||
import { useServerConfig } from "@/contexts/server-config"
|
||||
import { initialsFromName } from "@/lib/format"
|
||||
import { useCachedQuery } from "@/hooks/use-cached-query"
|
||||
import { clearLocalData, signOutToSignIn } from "@/lib/session"
|
||||
import { changeServer, signOut } from "@/lib/session"
|
||||
import { radius, spacing, useThemeColors } from "@/lib/theme"
|
||||
import { showError } from "@/lib/toast"
|
||||
import type { PlaybackQuality } from "@/lib/urls"
|
||||
@@ -73,7 +72,6 @@ const SECTIONS: SectionConfig[] = [
|
||||
|
||||
export default function SettingsScreen() {
|
||||
const colors = useThemeColors()
|
||||
const router = useRouter()
|
||||
const user = useCachedQuery(api.auth.currentUser)
|
||||
const { invalidateSession } = useInvalidateAuthSession()
|
||||
const { clearServer } = useServerConfig()
|
||||
@@ -91,14 +89,19 @@ export default function SettingsScreen() {
|
||||
const visibleSections = SECTIONS.filter((item) => !item.admin || isAdmin)
|
||||
|
||||
async function handleSignOut() {
|
||||
await signOutToSignIn(router, invalidateSession)
|
||||
try {
|
||||
await signOut(invalidateSession)
|
||||
} catch {
|
||||
showError("Could not clear all local data.")
|
||||
}
|
||||
}
|
||||
|
||||
async function handleChangeServer() {
|
||||
await invalidateSession()
|
||||
await clearLocalData()
|
||||
await clearServer()
|
||||
router.replace("/server")
|
||||
try {
|
||||
await changeServer(invalidateSession, clearServer)
|
||||
} catch {
|
||||
showError("Could not clear all local data.")
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -61,12 +61,14 @@ export default function LibraryScreen() {
|
||||
{links.map((link) => (
|
||||
<Pressable
|
||||
key={link.href}
|
||||
style={[styles.row, { borderBottomColor: colors.border }]}
|
||||
style={styles.row}
|
||||
onPress={() => push(link.href)}
|
||||
>
|
||||
<LibraryIcon name={link.icon} />
|
||||
<Text style={[styles.rowTitle, { color: colors.foreground }]}>{link.title}</Text>
|
||||
<Ionicons name="chevron-forward" size={16} color={colors.mutedForeground} />
|
||||
<View style={[styles.rowContent, { borderBottomColor: colors.border }]}>
|
||||
<Text style={[styles.rowTitle, { color: colors.foreground }]}>{link.title}</Text>
|
||||
<Ionicons name="chevron-forward" size={16} color={colors.mutedForeground} />
|
||||
</View>
|
||||
</Pressable>
|
||||
))}
|
||||
|
||||
@@ -111,6 +113,12 @@ const styles = StyleSheet.create({
|
||||
alignItems: "center",
|
||||
gap: spacing.md,
|
||||
paddingHorizontal: spacing.lg,
|
||||
},
|
||||
rowContent: {
|
||||
flex: 1,
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: spacing.md,
|
||||
paddingVertical: 14,
|
||||
borderBottomWidth: StyleSheet.hairlineWidth,
|
||||
},
|
||||
|
||||
@@ -3,25 +3,22 @@ import {
|
||||
useConvexAuth as useServerConvexAuth,
|
||||
useConvexConnectionState,
|
||||
} from "convex/react"
|
||||
import { Redirect, Stack } from "expo-router"
|
||||
import { Stack } from "expo-router"
|
||||
import { Platform } from "react-native"
|
||||
import { useEffect } from "react"
|
||||
|
||||
import { AppIntentBridge } from "@/components/app-intent-bridge"
|
||||
import { ConvexAuthRecovery } from "@/components/convex-auth-recovery"
|
||||
import { LoadingView } from "@/components/ui/primitives"
|
||||
import { AddToPlaylistProvider } from "@/contexts/add-to-playlist"
|
||||
import { useInvalidateAuthSession } from "@/contexts/convex-auth-session"
|
||||
import { FavoritesProvider } from "@/contexts/favorites"
|
||||
import { PlaybackProvider } from "@/contexts/playback"
|
||||
import { useServerConfig } from "@/contexts/server-config"
|
||||
import { useStackScreenOptions } from "@/lib/navigation"
|
||||
import { AppNavigationSync } from "@/lib/app-navigation"
|
||||
|
||||
const AUTH_HANDSHAKE_TIMEOUT_MS = 15_000
|
||||
|
||||
export default function AppLayout() {
|
||||
const { config } = useServerConfig()
|
||||
const localAuth = useLocalConvexAuth()
|
||||
const serverAuth = useServerConvexAuth()
|
||||
const { isWebSocketConnected } = useConvexConnectionState()
|
||||
@@ -51,18 +48,6 @@ export default function AppLayout() {
|
||||
serverAuth?.isAuthenticated,
|
||||
])
|
||||
|
||||
if (!config) {
|
||||
return <Redirect href="/server" />
|
||||
}
|
||||
|
||||
if (!localAuth || localAuth.isLoading) {
|
||||
return <LoadingView />
|
||||
}
|
||||
|
||||
if (!localAuth.isAuthenticated) {
|
||||
return <Redirect href="/signin" />
|
||||
}
|
||||
|
||||
// Convex holds queries until the stored token is confirmed, so the app can
|
||||
// render cached data while the server handshake is still in progress.
|
||||
|
||||
@@ -74,7 +59,10 @@ export default function AppLayout() {
|
||||
<AddToPlaylistProvider>
|
||||
<FavoritesProvider>
|
||||
<Stack screenOptions={stackOptions}>
|
||||
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
||||
<Stack.Screen
|
||||
name="(tabs)"
|
||||
options={{ headerShown: false, animation: "none" }}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="settings"
|
||||
options={{
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
import { Redirect } from "expo-router"
|
||||
|
||||
export default function AppIndex() {
|
||||
return <Redirect href="/(app)/(tabs)/home" />
|
||||
}
|
||||
@@ -533,6 +533,7 @@ function SongMeta({
|
||||
/>
|
||||
</Pressable>
|
||||
<MediaActionMenu
|
||||
stationArtistId={song.artist.id}
|
||||
favorited={favorited}
|
||||
navigation={{
|
||||
artist: { id: song.artist.id },
|
||||
@@ -542,6 +543,7 @@ function SongMeta({
|
||||
"play-next",
|
||||
"play-last",
|
||||
"shuffle",
|
||||
"create-station",
|
||||
"favorite",
|
||||
"go-artist",
|
||||
"go-album",
|
||||
|
||||
@@ -1,28 +1,7 @@
|
||||
import { useConvexAuth } from "@convex-dev/auth/react"
|
||||
import { Redirect, Stack } from "expo-router"
|
||||
import { Stack } from "expo-router"
|
||||
|
||||
import { LoadingView } from "@/components/ui/primitives"
|
||||
import { useServerConfig } from "@/contexts/server-config"
|
||||
export const unstable_settings = { anchor: "signin" }
|
||||
|
||||
export default function AuthLayout() {
|
||||
const { config, isLoading: serverLoading } = useServerConfig()
|
||||
const auth = useConvexAuth()
|
||||
|
||||
if (serverLoading) {
|
||||
return <LoadingView />
|
||||
}
|
||||
|
||||
if (!config) {
|
||||
return <Redirect href="/server" />
|
||||
}
|
||||
|
||||
if (!auth || auth.isLoading) {
|
||||
return <LoadingView />
|
||||
}
|
||||
|
||||
if (auth.isAuthenticated) {
|
||||
return <Redirect href="/(app)/(tabs)/home" />
|
||||
}
|
||||
|
||||
return <Stack screenOptions={{ headerShown: false }} />
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Stack } from "expo-router"
|
||||
import { useConvexAuth } from "@convex-dev/auth/react"
|
||||
import { DarkTheme, Stack, ThemeProvider } from "expo-router"
|
||||
import { StatusBar } from "expo-status-bar"
|
||||
import { useColorScheme } from "react-native"
|
||||
import { GestureHandlerRootView } from "react-native-gesture-handler"
|
||||
@@ -6,23 +7,57 @@ import { SafeAreaProvider } from "react-native-safe-area-context"
|
||||
|
||||
import { Toaster } from "@/components/ui/toaster"
|
||||
import { ConvexAppProvider } from "@/contexts/convex-app"
|
||||
import { ServerConfigProvider } from "@/contexts/server-config"
|
||||
import { ServerConfigProvider, useServerConfig } from "@/contexts/server-config"
|
||||
|
||||
const navigationTheme = {
|
||||
...DarkTheme,
|
||||
colors: { ...DarkTheme.colors, background: "#000", card: "#000" },
|
||||
}
|
||||
|
||||
function RootNavigator() {
|
||||
const { config, isLoading } = useServerConfig()
|
||||
const auth = useConvexAuth()
|
||||
|
||||
if (isLoading || (config && (!auth || auth.isLoading))) {
|
||||
return null
|
||||
}
|
||||
|
||||
const isAuthenticated = Boolean(config && auth?.isAuthenticated)
|
||||
|
||||
return (
|
||||
<Stack
|
||||
screenOptions={{
|
||||
headerShown: false,
|
||||
animation: "none",
|
||||
contentStyle: { backgroundColor: "#000" },
|
||||
}}
|
||||
>
|
||||
<Stack.Screen name="index" />
|
||||
<Stack.Protected guard={isAuthenticated}>
|
||||
<Stack.Screen name="(app)" />
|
||||
</Stack.Protected>
|
||||
<Stack.Protected guard={Boolean(config) && !isAuthenticated}>
|
||||
<Stack.Screen name="(auth)" />
|
||||
</Stack.Protected>
|
||||
<Stack.Protected guard={!config}>
|
||||
<Stack.Screen name="server" />
|
||||
</Stack.Protected>
|
||||
</Stack>
|
||||
)
|
||||
}
|
||||
|
||||
export default function RootLayout() {
|
||||
const colorScheme = useColorScheme()
|
||||
|
||||
return (
|
||||
<GestureHandlerRootView style={{ flex: 1 }}>
|
||||
<GestureHandlerRootView style={{ flex: 1, backgroundColor: "#000" }}>
|
||||
<SafeAreaProvider>
|
||||
<ServerConfigProvider>
|
||||
<ConvexAppProvider>
|
||||
<StatusBar style={colorScheme === "dark" ? "light" : "dark"} />
|
||||
<Stack screenOptions={{ headerShown: false }}>
|
||||
<Stack.Screen name="index" />
|
||||
<Stack.Screen name="server" />
|
||||
<Stack.Screen name="(auth)" />
|
||||
<Stack.Screen name="(app)" />
|
||||
</Stack>
|
||||
<ThemeProvider value={navigationTheme}>
|
||||
<RootNavigator />
|
||||
</ThemeProvider>
|
||||
<Toaster />
|
||||
</ConvexAppProvider>
|
||||
</ServerConfigProvider>
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import { useConvexAuth } from "@convex-dev/auth/react"
|
||||
import { Redirect } from "expo-router"
|
||||
|
||||
import { LoadingView } from "@/components/ui/primitives"
|
||||
import { useServerConfig } from "@/contexts/server-config"
|
||||
import { AuthenticatedRedirect } from "@/components/authenticated-redirect"
|
||||
|
||||
export default function Index() {
|
||||
const { config, isLoading } = useServerConfig()
|
||||
|
||||
if (isLoading) {
|
||||
return <LoadingView />
|
||||
}
|
||||
const { config } = useServerConfig()
|
||||
const auth = useConvexAuth()
|
||||
|
||||
if (!config) {
|
||||
return <Redirect href="/server" />
|
||||
}
|
||||
|
||||
return <AuthenticatedRedirect />
|
||||
return (
|
||||
<Redirect
|
||||
href={auth?.isAuthenticated ? "/(app)/(tabs)/library" : "/signin"}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import { useRouter } from "expo-router"
|
||||
import { useEffect, useState } from "react"
|
||||
import { useState } from "react"
|
||||
import {
|
||||
KeyboardAvoidingView,
|
||||
Platform,
|
||||
@@ -14,19 +13,12 @@ import { useServerConfig } from "@/contexts/server-config"
|
||||
import { spacing, useThemeColors } from "@/lib/theme"
|
||||
|
||||
export default function ServerScreen() {
|
||||
const router = useRouter()
|
||||
const colors = useThemeColors()
|
||||
const { config, isLoading, setServerHostname } = useServerConfig()
|
||||
const { setServerHostname } = useServerConfig()
|
||||
const [hostname, setHostname] = useState("")
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [submitting, setSubmitting] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
if (config?.hostname) {
|
||||
setHostname(config.hostname)
|
||||
}
|
||||
}, [config?.hostname])
|
||||
|
||||
async function handleContinue() {
|
||||
setError(null)
|
||||
setSubmitting(true)
|
||||
@@ -38,7 +30,6 @@ export default function ServerScreen() {
|
||||
)
|
||||
return
|
||||
}
|
||||
router.replace("/signin")
|
||||
} catch {
|
||||
setError(
|
||||
"Could not save the server address. Check device storage and try again."
|
||||
@@ -48,10 +39,6 @@ export default function ServerScreen() {
|
||||
}
|
||||
}
|
||||
|
||||
if (isLoading) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<SafeAreaView style={[styles.safe, { backgroundColor: colors.background }]}>
|
||||
<KeyboardAvoidingView
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useAuthActions, useConvexAuth } from "@convex-dev/auth/react"
|
||||
import { Link, useRouter } from "expo-router"
|
||||
import { useAuthActions } from "@convex-dev/auth/react"
|
||||
import { Link } from "expo-router"
|
||||
import { useQuery } from "convex/react"
|
||||
import { useEffect, useState } from "react"
|
||||
import { useState } from "react"
|
||||
import {
|
||||
KeyboardAvoidingView,
|
||||
Platform,
|
||||
@@ -16,6 +16,7 @@ import { Button, Card, Input } from "@/components/ui/primitives"
|
||||
import { useServerConfig } from "@/contexts/server-config"
|
||||
import { api } from "@otunes/convex/_generated/api"
|
||||
import { spacing, useThemeColors } from "@/lib/theme"
|
||||
import { showError } from "@/lib/toast"
|
||||
|
||||
type AuthFlow = "signIn" | "signUp"
|
||||
|
||||
@@ -50,10 +51,8 @@ const copy: Record<
|
||||
|
||||
export function AuthForm({ flow }: { flow: AuthFlow }) {
|
||||
const { signIn } = useAuthActions()
|
||||
const auth = useConvexAuth()
|
||||
const router = useRouter()
|
||||
const colors = useThemeColors()
|
||||
const { config } = useServerConfig()
|
||||
const { config, clearServer } = useServerConfig()
|
||||
const appSettings = useQuery(api.users.getAppSettings)
|
||||
const [name, setName] = useState("")
|
||||
const [email, setEmail] = useState("")
|
||||
@@ -61,12 +60,6 @@ export function AuthForm({ flow }: { flow: AuthFlow }) {
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [submitting, setSubmitting] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
if (auth.isAuthenticated) {
|
||||
router.replace("/(app)/(tabs)/home")
|
||||
}
|
||||
}, [auth.isAuthenticated, router])
|
||||
|
||||
const text = copy[flow]
|
||||
const accountCreationDisabled = appSettings?.disableAccountCreation ?? false
|
||||
const signupsDisabled = flow === "signUp" && accountCreationDisabled
|
||||
@@ -164,11 +157,16 @@ export function AuthForm({ flow }: { flow: AuthFlow }) {
|
||||
)}
|
||||
</Card>
|
||||
|
||||
<Link href="/server" asChild>
|
||||
<Pressable style={styles.changeServer}>
|
||||
<Text style={{ color: colors.mutedForeground }}>Change server</Text>
|
||||
</Pressable>
|
||||
</Link>
|
||||
<Pressable
|
||||
style={styles.changeServer}
|
||||
onPress={() =>
|
||||
void clearServer().catch(() =>
|
||||
showError("Could not clear the server address.")
|
||||
)
|
||||
}
|
||||
>
|
||||
<Text style={{ color: colors.mutedForeground }}>Change server</Text>
|
||||
</Pressable>
|
||||
</KeyboardAvoidingView>
|
||||
</SafeAreaView>
|
||||
)
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
import { useConvexAuth } from "@convex-dev/auth/react"
|
||||
import { Redirect } from "expo-router"
|
||||
|
||||
import { LoadingView } from "@/components/ui/primitives"
|
||||
|
||||
export function AuthenticatedRedirect() {
|
||||
const auth = useConvexAuth()
|
||||
|
||||
if (!auth) {
|
||||
return <LoadingView />
|
||||
}
|
||||
|
||||
const { isLoading, isAuthenticated } = auth
|
||||
|
||||
if (isLoading) {
|
||||
return <LoadingView />
|
||||
}
|
||||
|
||||
if (!isAuthenticated) {
|
||||
return <Redirect href="/signin" />
|
||||
}
|
||||
|
||||
return <Redirect href="/(app)/(tabs)/home" />
|
||||
}
|
||||
@@ -75,6 +75,7 @@ export const AlbumCard = memo(function AlbumCard({
|
||||
return (
|
||||
<MediaContextMenu
|
||||
favorited={isAlbumFavorite(album.id)}
|
||||
stationArtistId={album.artist.id}
|
||||
navigation={{ artist: { id: album.artist.id } }}
|
||||
share={{ type: "album", albumId: album.id }}
|
||||
onAction={(action) => void handleAlbumAction(album, action)}
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
const { test } = require("node:test")
|
||||
const assert = require("node:assert/strict")
|
||||
const fs = require("node:fs")
|
||||
const vm = require("node:vm")
|
||||
const ts = require("typescript")
|
||||
|
||||
test("the native menu keeps its trigger type when screen focus replaces the Siri wrapper", () => {
|
||||
let focused = true
|
||||
const imports = {
|
||||
"react/jsx-runtime": {
|
||||
jsx: (type, props) => ({ type, props }),
|
||||
jsxs: (type, props) => ({ type, props }),
|
||||
},
|
||||
"react-native": { Platform: { OS: "ios" }, View: "View" },
|
||||
expo: { requireNativeView: (_module, view) => view },
|
||||
"expo-router": { useIsFocused: () => focused },
|
||||
"expo-app-intents": { AppEntityView: "AppEntityView" },
|
||||
"@expo/ui/community/menu": {},
|
||||
"@/contexts/server-config": { useServerConfig: () => ({ config: null }) },
|
||||
"@/lib/media-links": { shouldShowShare: () => false },
|
||||
"@/lib/share-media-link": {},
|
||||
}
|
||||
|
||||
function load(file) {
|
||||
const module = { exports: {} }
|
||||
const source = ts.transpileModule(
|
||||
fs.readFileSync(`${__dirname}/${file}.tsx`, "utf8"),
|
||||
{
|
||||
compilerOptions: {
|
||||
module: ts.ModuleKind.CommonJS,
|
||||
jsx: ts.JsxEmit.ReactJSX,
|
||||
},
|
||||
}
|
||||
).outputText
|
||||
vm.runInNewContext(source, {
|
||||
module,
|
||||
exports: module.exports,
|
||||
require: (name) => {
|
||||
assert.ok(name in imports, `Unexpected import ${name}`)
|
||||
return imports[name]
|
||||
},
|
||||
})
|
||||
return module.exports
|
||||
}
|
||||
|
||||
const { MusicEntityView } = load("music-entity-view")
|
||||
const { MediaContextMenu } = load("media-context-menu")
|
||||
const card = { type: "Pressable", props: { children: "Album" } }
|
||||
const triggers = []
|
||||
|
||||
for (const nextFocus of [true, false, true, false, true]) {
|
||||
focused = nextFocus
|
||||
const entity = MusicEntityView({ kind: "album", id: "1", children: card })
|
||||
const menu = MediaContextMenu({ children: entity, onAction() {} })
|
||||
const nativeMenu = menu.type(menu.props)
|
||||
const trigger = nativeMenu.props.children[0]
|
||||
triggers.push(trigger)
|
||||
|
||||
// Fabric must retain this host even when its child changes native type.
|
||||
assert.equal(trigger.props.collapsable, false)
|
||||
assert.equal(trigger.type, triggers[0].type)
|
||||
assert.equal(trigger.props.children.type, focused ? "AppEntityView" : "View")
|
||||
assert.equal(trigger.props.children.props.children, card)
|
||||
}
|
||||
})
|
||||
@@ -20,6 +20,7 @@ export type MediaAction =
|
||||
| "play-next"
|
||||
| "play-last"
|
||||
| "shuffle"
|
||||
| "create-station"
|
||||
| "favorite"
|
||||
| "go-artist"
|
||||
| "go-album"
|
||||
@@ -35,6 +36,7 @@ export type MediaMenuConfig = {
|
||||
playlistLabel?: string
|
||||
favorited?: boolean
|
||||
showFavorite?: boolean
|
||||
stationArtistId?: string
|
||||
navigation?: MediaNavigation
|
||||
share?: MediaShareContext
|
||||
includeActions?: MediaAction[]
|
||||
@@ -78,6 +80,11 @@ const MEDIA_ACTION_ITEMS: {
|
||||
label: (countSuffix) => `Shuffle${countSuffix}`,
|
||||
image: "shuffle",
|
||||
},
|
||||
{
|
||||
action: "create-station",
|
||||
label: () => "Create Station",
|
||||
image: "shuffle",
|
||||
},
|
||||
{
|
||||
action: "go-artist",
|
||||
label: () => "Go to Artist",
|
||||
@@ -105,6 +112,10 @@ function isActionIncluded(
|
||||
action: MediaAction,
|
||||
config: Omit<MediaMenuConfig, "onAction">
|
||||
): boolean {
|
||||
if (action === "create-station" && !config.stationArtistId) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (config.includeActions) {
|
||||
return config.includeActions.includes(action)
|
||||
}
|
||||
|
||||
@@ -136,6 +136,7 @@ export const SongListRow = memo(function SongListRow({
|
||||
inset={inset}
|
||||
onPress={handlePress}
|
||||
contextMenu={{
|
||||
stationArtistId: song.artist.id,
|
||||
favorited,
|
||||
playlistLabel,
|
||||
navigation: {
|
||||
|
||||
@@ -22,11 +22,11 @@ export function ConvexAppProvider({ children }: { children: ReactNode }) {
|
||||
return
|
||||
}
|
||||
await clearStoredAuthTokens(config.convexUrl)
|
||||
try {
|
||||
await clearAppIntentCatalogs()
|
||||
} finally {
|
||||
setAuthEpoch((epoch) => epoch + 1)
|
||||
}
|
||||
setAuthEpoch((epoch) => epoch + 1)
|
||||
// Native catalog cleanup can be slow; it must not hold the signed-in UI open.
|
||||
void clearAppIntentCatalogs().catch((error) => {
|
||||
console.warn("Could not clear app intent catalogs.", error)
|
||||
})
|
||||
}, [config])
|
||||
|
||||
if (!client || !config) {
|
||||
|
||||
@@ -46,7 +46,8 @@ export function useMediaMenuActions() {
|
||||
toggleSongFavorite,
|
||||
favoriteSongs,
|
||||
} = useFavorites()
|
||||
const { addToQueueNext, addToQueueLast, playShuffled } = usePlaybackActions()
|
||||
const { addToQueueNext, addToQueueLast, playShuffled, playArtistShuffled } =
|
||||
usePlaybackActions()
|
||||
|
||||
const runQueueAction = useCallback(
|
||||
async (action: MediaAction, songIds: Id<"songs">[]) => {
|
||||
@@ -74,6 +75,11 @@ export function useMediaMenuActions() {
|
||||
async (song: BrowseSong, action: MediaAction) => {
|
||||
const songIds = [song.id as Id<"songs">]
|
||||
switch (action) {
|
||||
case "create-station":
|
||||
await runMediaAction(() =>
|
||||
playArtistShuffled(song.artist.id as Id<"artists">)
|
||||
)
|
||||
break
|
||||
case "playlist":
|
||||
openAddToPlaylist(songIds)
|
||||
break
|
||||
@@ -95,13 +101,22 @@ export function useMediaMenuActions() {
|
||||
break
|
||||
}
|
||||
},
|
||||
[openAddToPlaylist, push, runQueueAction, toggleSongFavorite]
|
||||
[
|
||||
openAddToPlaylist,
|
||||
push,
|
||||
runQueueAction,
|
||||
toggleSongFavorite,
|
||||
playArtistShuffled,
|
||||
]
|
||||
)
|
||||
|
||||
const handleAlbumAction = useCallback(
|
||||
async (album: BrowseAlbum, action: MediaAction) => {
|
||||
await runMediaAction(async () => {
|
||||
switch (action) {
|
||||
case "create-station":
|
||||
await playArtistShuffled(album.artist.id as Id<"artists">)
|
||||
break
|
||||
case "playlist":
|
||||
await openAddAlbumToPlaylist(album.id as Id<"albums">)
|
||||
break
|
||||
@@ -132,6 +147,7 @@ export function useMediaMenuActions() {
|
||||
convex,
|
||||
cacheScope,
|
||||
openAddAlbumToPlaylist,
|
||||
playArtistShuffled,
|
||||
push,
|
||||
runQueueAction,
|
||||
toggleAlbumFavorite,
|
||||
@@ -207,9 +223,13 @@ export function useMediaMenuActions() {
|
||||
async (
|
||||
albumId: Id<"albums">,
|
||||
songIds: Id<"songs">[],
|
||||
action: MediaAction
|
||||
action: MediaAction,
|
||||
artistId: Id<"artists">
|
||||
) => {
|
||||
switch (action) {
|
||||
case "create-station":
|
||||
await runMediaAction(() => playArtistShuffled(artistId))
|
||||
break
|
||||
case "favorite":
|
||||
await toggleAlbumFavorite(albumId)
|
||||
break
|
||||
@@ -225,7 +245,7 @@ export function useMediaMenuActions() {
|
||||
break
|
||||
}
|
||||
},
|
||||
[openAddToPlaylist, runQueueAction, toggleAlbumFavorite]
|
||||
[openAddToPlaylist, runQueueAction, toggleAlbumFavorite, playArtistShuffled]
|
||||
)
|
||||
|
||||
const handleAlbumTrackAction = useCallback(
|
||||
|
||||
+22
-12
@@ -1,22 +1,32 @@
|
||||
import type { useRouter } from "expo-router"
|
||||
|
||||
import { clearAppIntentCatalogs } from "@/lib/app-intent-handled"
|
||||
import { resetPlaybackStores } from "@otunes/convex/client/playback-store"
|
||||
import { clearPersistentCache } from "@/lib/persistent-cache"
|
||||
|
||||
type AppRouter = ReturnType<typeof useRouter>
|
||||
|
||||
/** Forgets this device's cached library and playback state. */
|
||||
export async function clearLocalData() {
|
||||
resetPlaybackStores()
|
||||
await Promise.all([clearPersistentCache(), clearAppIntentCatalogs()])
|
||||
await clearPersistentCache()
|
||||
}
|
||||
|
||||
export async function signOutToSignIn(
|
||||
router: Pick<AppRouter, "replace">,
|
||||
invalidateSession: () => Promise<void>
|
||||
/** Root route guards leave the app when the session or server is cleared. */
|
||||
export async function signOut(invalidateSession: () => Promise<void>) {
|
||||
try {
|
||||
await invalidateSession()
|
||||
} finally {
|
||||
await clearLocalData()
|
||||
}
|
||||
}
|
||||
|
||||
export async function changeServer(
|
||||
invalidateSession: () => Promise<void>,
|
||||
clearServer: () => Promise<void>
|
||||
) {
|
||||
await invalidateSession()
|
||||
await clearLocalData()
|
||||
router.replace("/signin")
|
||||
try {
|
||||
await invalidateSession()
|
||||
} finally {
|
||||
try {
|
||||
await clearServer()
|
||||
} finally {
|
||||
await clearLocalData()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ export function AlbumCard({ album }: { album: BrowseAlbum }) {
|
||||
const { openAddAlbumToPlaylist } = useAddToPlaylist()
|
||||
const { isAlbumFavorite, toggleAlbumFavorite } = useFavorites()
|
||||
const { playAlbum } = usePlayback()
|
||||
const { runQueueAction } = useQueueMediaActions()
|
||||
const { runQueueAction, createStation } = useQueueMediaActions()
|
||||
const [menuOpen, setMenuOpen] = React.useState(false)
|
||||
const [hovered, setHovered] = React.useState(false)
|
||||
const showActions = hovered || menuOpen
|
||||
@@ -71,6 +71,9 @@ export function AlbumCard({ album }: { album: BrowseAlbum }) {
|
||||
|
||||
async function handleCardAction(action: MediaContextAction) {
|
||||
switch (action) {
|
||||
case "create-station":
|
||||
void createStation(album.artist.id)
|
||||
break
|
||||
case "playlist":
|
||||
void openAddAlbumToPlaylist(album.id as Id<"albums">)
|
||||
break
|
||||
@@ -153,6 +156,7 @@ export function AlbumCard({ album }: { album: BrowseAlbum }) {
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" className="w-48">
|
||||
<MediaContextMenuItems
|
||||
stationArtistId={album.artist.id}
|
||||
selectedCount={1}
|
||||
onAction={(action) => void handleCardAction(action)}
|
||||
favorited={isAlbumFavorite(album.id)}
|
||||
|
||||
@@ -228,6 +228,7 @@ function TrackRow({
|
||||
|
||||
<MediaContextMenu
|
||||
label={`More options for ${track.title}`}
|
||||
stationArtistId={artist.id}
|
||||
selectedCount={selectedCount}
|
||||
inSelectionRange={inRange}
|
||||
onOpenMenu={onPrepareContextMenu}
|
||||
@@ -265,7 +266,7 @@ export function AlbumView({
|
||||
} = useFavorites()
|
||||
const { currentSong, playFromSong, playAlbum, playAlbumShuffled } =
|
||||
usePlayback()
|
||||
const { runQueueAction } = useQueueMediaActions()
|
||||
const { runQueueAction, createStation } = useQueueMediaActions()
|
||||
const albumSongIds = React.useMemo(
|
||||
() => album.tracks.map((track) => track.id as Id<"songs">),
|
||||
[album.tracks]
|
||||
@@ -330,6 +331,9 @@ export function AlbumView({
|
||||
? [activeTrackId]
|
||||
: []
|
||||
switch (action) {
|
||||
case "create-station":
|
||||
void createStation(album.artist.id)
|
||||
break
|
||||
case "favorite":
|
||||
void favoriteSongs(targetIds as Id<"songs">[])
|
||||
break
|
||||
@@ -348,6 +352,9 @@ export function AlbumView({
|
||||
const targetIds = album.tracks.map((track) => track.id as Id<"songs">)
|
||||
|
||||
switch (action) {
|
||||
case "create-station":
|
||||
void createStation(album.artist.id)
|
||||
break
|
||||
case "favorite":
|
||||
void toggleAlbumFavorite(album.id as Id<"albums">)
|
||||
break
|
||||
@@ -442,6 +449,7 @@ export function AlbumView({
|
||||
</Button>
|
||||
<MediaContextMenu
|
||||
label="More album options"
|
||||
stationArtistId={album.artist.id}
|
||||
selectedCount={album.tracks.length}
|
||||
onOpenMenu={() => {}}
|
||||
onAction={handleAlbumMediaAction}
|
||||
|
||||
@@ -33,6 +33,7 @@ export type MediaContextAction =
|
||||
| "play-next"
|
||||
| "play-last"
|
||||
| "shuffle"
|
||||
| "create-station"
|
||||
| "favorite"
|
||||
|
||||
export type MediaContextNavigation = {
|
||||
@@ -65,6 +66,7 @@ export function MediaContextMenuItems({
|
||||
playlistLabel = "Add to Playlist",
|
||||
showFavorite = true,
|
||||
favorited = false,
|
||||
stationArtistId,
|
||||
navigation,
|
||||
share,
|
||||
}: {
|
||||
@@ -73,6 +75,7 @@ export function MediaContextMenuItems({
|
||||
playlistLabel?: string
|
||||
showFavorite?: boolean
|
||||
favorited?: boolean
|
||||
stationArtistId?: string
|
||||
navigation?: MediaContextNavigation
|
||||
share?: MediaShareContext
|
||||
}) {
|
||||
@@ -122,6 +125,15 @@ export function MediaContextMenuItems({
|
||||
{actionLabel("Shuffle", selectedCount)}
|
||||
<Shuffle />
|
||||
</DropdownMenuItem>
|
||||
{stationArtistId ? (
|
||||
<DropdownMenuItem
|
||||
className="justify-between"
|
||||
onClick={() => onAction("create-station")}
|
||||
>
|
||||
Create Station
|
||||
<Shuffle />
|
||||
</DropdownMenuItem>
|
||||
) : null}
|
||||
{artist || album ? (
|
||||
<>
|
||||
<DropdownMenuSeparator />
|
||||
@@ -193,6 +205,7 @@ export function MediaContextMenu({
|
||||
playlistLabel,
|
||||
showFavorite = true,
|
||||
favorited = false,
|
||||
stationArtistId,
|
||||
navigation,
|
||||
share,
|
||||
inSelectionRange = false,
|
||||
@@ -210,6 +223,7 @@ export function MediaContextMenu({
|
||||
playlistLabel?: string
|
||||
showFavorite?: boolean
|
||||
favorited?: boolean
|
||||
stationArtistId?: string
|
||||
navigation?: MediaContextNavigation
|
||||
share?: MediaShareContext
|
||||
inSelectionRange?: boolean
|
||||
@@ -251,6 +265,7 @@ export function MediaContextMenu({
|
||||
playlistLabel={playlistLabel}
|
||||
showFavorite={showFavorite}
|
||||
favorited={favorited}
|
||||
stationArtistId={stationArtistId}
|
||||
navigation={navigation}
|
||||
share={share}
|
||||
/>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import { stationArtistId } from "@/lib/station-artist"
|
||||
import * as React from "react"
|
||||
import Image from "next/image"
|
||||
import { useRouter } from "next/navigation"
|
||||
@@ -124,6 +125,7 @@ function PlaylistSongRow({
|
||||
selectionPosition,
|
||||
isFavorite,
|
||||
selectedCount,
|
||||
stationArtist,
|
||||
isDragging,
|
||||
onSelect,
|
||||
onPointerDown,
|
||||
@@ -147,6 +149,7 @@ function PlaylistSongRow({
|
||||
selectionPosition: SelectionRangePosition
|
||||
isFavorite: boolean
|
||||
selectedCount: number
|
||||
stationArtist?: string
|
||||
isDragging: boolean
|
||||
onSelect: (event: React.MouseEvent) => void
|
||||
onPointerDown: (event: React.MouseEvent) => void
|
||||
@@ -226,6 +229,7 @@ function PlaylistSongRow({
|
||||
|
||||
<MediaContextMenu
|
||||
label={`More options for ${song.title}`}
|
||||
stationArtistId={stationArtist}
|
||||
selectedCount={selectedCount}
|
||||
inSelectionRange={inRange}
|
||||
onOpenMenu={onPrepareContextMenu}
|
||||
@@ -285,7 +289,7 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) {
|
||||
playPlaylistShuffled,
|
||||
playFromSong,
|
||||
} = usePlayback()
|
||||
const { runQueueAction } = useQueueMediaActions()
|
||||
const { runQueueAction, createStation } = useQueueMediaActions()
|
||||
const removeSongs = useMutation(api.playlists.removeSongsFromPlaylist)
|
||||
const reorderSongs = useMutation(api.playlists.reorderPlaylistSongs)
|
||||
const deletePlaylist = useMutation(api.playlists.deletePlaylist)
|
||||
@@ -324,6 +328,11 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) {
|
||||
prepareContextMenu,
|
||||
} = useTrackSelection(songs)
|
||||
|
||||
const selectedStationArtistId = React.useMemo(
|
||||
() => stationArtistId(songs, selectedIds),
|
||||
[songs, selectedIds]
|
||||
)
|
||||
|
||||
const selectionPositions = React.useMemo(
|
||||
() => getSelectionRangePositions(songs.map((song) => song.id), selectedIds),
|
||||
[songs, selectedIds]
|
||||
@@ -363,6 +372,11 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) {
|
||||
const targetIds = resolveTargetIds(fallbackSongId)
|
||||
|
||||
switch (action) {
|
||||
case "create-station": {
|
||||
const artistId = stationArtistId(songs, new Set(targetIds))
|
||||
if (artistId) void createStation(artistId)
|
||||
break
|
||||
}
|
||||
case "favorite":
|
||||
void addFavoriteSongs(targetIds as Id<"songs">[])
|
||||
break
|
||||
@@ -637,6 +651,11 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) {
|
||||
? selectedCount
|
||||
: 1
|
||||
}
|
||||
stationArtist={
|
||||
isSelected(song.id)
|
||||
? selectedStationArtistId
|
||||
: song.artist.id
|
||||
}
|
||||
isDragging={dragIndex === index}
|
||||
onPointerDown={handlePointerDown}
|
||||
onSelect={(event) => {
|
||||
|
||||
@@ -16,11 +16,14 @@ import { albumCoverUrl } from "@/lib/cover-urls"
|
||||
export function SearchSongItem({ song }: { song: BrowseSong }) {
|
||||
const { openAddToPlaylist } = useAddToPlaylist()
|
||||
const { isSongFavorite, toggleSongFavorite } = useFavorites()
|
||||
const { runQueueAction } = useQueueMediaActions()
|
||||
const { runQueueAction, createStation } = useQueueMediaActions()
|
||||
const songIds = [song.id as Id<"songs">]
|
||||
|
||||
function handleAction(action: MediaContextAction) {
|
||||
switch (action) {
|
||||
case "create-station":
|
||||
void createStation(song.artist.id)
|
||||
break
|
||||
case "playlist":
|
||||
openAddToPlaylist(songIds)
|
||||
break
|
||||
@@ -64,6 +67,7 @@ export function SearchSongItem({ song }: { song: BrowseSong }) {
|
||||
|
||||
<MediaContextMenu
|
||||
label={`More options for ${song.title}`}
|
||||
stationArtistId={song.artist.id}
|
||||
selectedCount={1}
|
||||
onOpenMenu={() => {}}
|
||||
onAction={handleAction}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import { stationArtistId } from "@/lib/station-artist"
|
||||
import { useEffect, useMemo, useState, useRef, MouseEvent } from "react"
|
||||
import Image from "next/image"
|
||||
import Link from "next/link"
|
||||
@@ -115,6 +116,7 @@ function SongRow({
|
||||
selectionPosition,
|
||||
isFavorite,
|
||||
selectedCount,
|
||||
stationArtist,
|
||||
onSelect,
|
||||
onPointerDown,
|
||||
onToggleFavorite,
|
||||
@@ -127,6 +129,7 @@ function SongRow({
|
||||
selectionPosition: SelectionRangePosition
|
||||
isFavorite: boolean
|
||||
selectedCount: number
|
||||
stationArtist?: string
|
||||
onSelect: (event: MouseEvent) => void
|
||||
onPointerDown: (event: MouseEvent) => void
|
||||
onToggleFavorite: () => void
|
||||
@@ -238,6 +241,7 @@ function SongRow({
|
||||
</span>
|
||||
<MediaContextMenu
|
||||
label={`More options for ${song.title}`}
|
||||
stationArtistId={stationArtist}
|
||||
selectedCount={selectedCount}
|
||||
align="end"
|
||||
inSelectionRange={inRange}
|
||||
@@ -265,7 +269,7 @@ export function SongsView() {
|
||||
const { openAddToPlaylist } = useAddToPlaylist()
|
||||
const { isSongFavorite, toggleSongFavorite, favoriteSongs } = useFavorites()
|
||||
const { playFromLibrarySong } = usePlayback()
|
||||
const { runQueueAction } = useQueueMediaActions()
|
||||
const { runQueueAction, createStation } = useQueueMediaActions()
|
||||
const [sortKey, setSortKey] = useState<SortKey>("title")
|
||||
const [sortDirection, setSortDirection] =
|
||||
useState<SortDirection>("asc")
|
||||
@@ -313,6 +317,11 @@ export function SongsView() {
|
||||
clearSelection,
|
||||
} = useTrackSelection(songs)
|
||||
|
||||
const selectedStationArtistId = useMemo(
|
||||
() => stationArtistId(songs, selectedIds),
|
||||
[songs, selectedIds]
|
||||
)
|
||||
|
||||
const selectionPositions = useMemo(
|
||||
() =>
|
||||
getSelectionRangePositions(
|
||||
@@ -330,6 +339,11 @@ export function SongsView() {
|
||||
? [fallbackSongId]
|
||||
: []
|
||||
switch (action) {
|
||||
case "create-station": {
|
||||
const artistId = stationArtistId(songs, new Set(targetIds))
|
||||
if (artistId) void createStation(artistId)
|
||||
break
|
||||
}
|
||||
case "favorite":
|
||||
void favoriteSongs(targetIds as Id<"songs">[])
|
||||
break
|
||||
@@ -449,6 +463,11 @@ export function SongsView() {
|
||||
isSelected={isSelected(song.id)}
|
||||
selectionPosition={selectionPositions[index]}
|
||||
isFavorite={isSongFavorite(song.id)}
|
||||
stationArtist={
|
||||
isSelected(song.id)
|
||||
? selectedStationArtistId
|
||||
: song.artist.id
|
||||
}
|
||||
selectedCount={
|
||||
isSelected(song.id) && selectedCount > 0
|
||||
? selectedCount
|
||||
|
||||
@@ -23,14 +23,13 @@ function queueActionMessage(action: QueueMediaAction, count: number) {
|
||||
? `Queued ${count} songs to play last`
|
||||
: "Queued to play last"
|
||||
case "shuffle":
|
||||
return count > 1
|
||||
? `Playing ${count} songs shuffled`
|
||||
: "Playing shuffled"
|
||||
return count > 1 ? `Playing ${count} songs shuffled` : "Playing shuffled"
|
||||
}
|
||||
}
|
||||
|
||||
export function useQueueMediaActions() {
|
||||
const { addToQueueNext, addToQueueLast, playShuffled } = usePlayback()
|
||||
const { addToQueueNext, addToQueueLast, playShuffled, playArtistShuffled } =
|
||||
usePlayback()
|
||||
|
||||
const runQueueAction = React.useCallback(
|
||||
async (action: QueueMediaAction, songIds: Id<"songs">[]) => {
|
||||
@@ -60,5 +59,18 @@ export function useQueueMediaActions() {
|
||||
[addToQueueNext, addToQueueLast, playShuffled]
|
||||
)
|
||||
|
||||
return { runQueueAction }
|
||||
const createStation = React.useCallback(
|
||||
async (artistId: string) => {
|
||||
try {
|
||||
await playArtistShuffled(artistId as Id<"artists">)
|
||||
} catch (error) {
|
||||
toast.error(
|
||||
error instanceof Error ? error.message : "Failed to create station"
|
||||
)
|
||||
}
|
||||
},
|
||||
[playArtistShuffled]
|
||||
)
|
||||
|
||||
return { runQueueAction, createStation }
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import assert from "node:assert/strict"
|
||||
import test from "node:test"
|
||||
|
||||
import { stationArtistId } from "./station-artist.ts"
|
||||
|
||||
const songs = [
|
||||
{ id: "song-a", artist: { id: "artist-a" } },
|
||||
{ id: "song-b", artist: { id: "artist-a" } },
|
||||
{ id: "song-c", artist: { id: "artist-b" } },
|
||||
]
|
||||
|
||||
test("a single song or a selection sharing one artist can create a station", () => {
|
||||
assert.equal(stationArtistId(songs, new Set(["song-c"])), "artist-b")
|
||||
assert.equal(
|
||||
stationArtistId(songs, new Set(["song-a", "song-b"])),
|
||||
"artist-a"
|
||||
)
|
||||
})
|
||||
|
||||
test("mixed artists cannot create a station", () => {
|
||||
assert.equal(stationArtistId(songs, new Set(["song-a", "song-c"])), undefined)
|
||||
})
|
||||
|
||||
test("empty or partially missing selections cannot create a station", () => {
|
||||
assert.equal(stationArtistId(songs, new Set()), undefined)
|
||||
assert.equal(
|
||||
stationArtistId(songs, new Set(["song-a", "missing"])),
|
||||
undefined
|
||||
)
|
||||
})
|
||||
@@ -0,0 +1,14 @@
|
||||
type ArtistItem = { id: string; artist: { id: string } }
|
||||
|
||||
/** Returns an artist only when every target item is present and shares it. */
|
||||
export function stationArtistId(
|
||||
items: ArtistItem[],
|
||||
targetIds: ReadonlySet<string>
|
||||
) {
|
||||
const targets = items.filter((item) => targetIds.has(item.id))
|
||||
const artistId = targets[0]?.artist.id
|
||||
return targets.length === targetIds.size &&
|
||||
targets.every((item) => item.artist.id === artistId)
|
||||
? artistId
|
||||
: undefined
|
||||
}
|
||||
Reference in new issue
Block a user