Compare commits

..
20 changed files with 133 additions and 251 deletions

No files matched your search

+12 -5
View File
@@ -4,7 +4,6 @@ import { Stack } from "expo-router"
import { ProfileHeaderButton } from "@/components/profile-header-button"
import {
inlineTitleOptions,
showHeaderProfile,
tabStackScreenTitles,
useStackScreenOptions,
} from "@/lib/navigation"
@@ -23,10 +22,18 @@ export default function HomeLayout() {
...baseOptions,
...inlineTitleOptions,
title: tabStackScreenTitles[route.name] ?? "Home",
// iOS shows the profile button inline with the screen title instead.
headerRight: showHeaderProfile(route.name)
? () => <ProfileHeaderButton />
: undefined,
headerRight:
route.name === "index" ? () => <ProfileHeaderButton /> : undefined,
unstable_headerRightItems:
route.name === "index"
? () => [
{
type: "custom",
element: <ProfileHeaderButton />,
hidesSharedBackground: true,
},
]
: undefined,
})}
/>
)
+2 -10
View File
@@ -5,7 +5,6 @@ import Animated from "react-native-reanimated"
import { ContentCarousel } from "@/components/media-cards"
import { HomeSkeleton } from "@/components/skeletons"
import { ScreenTitle, useScreenTitleScroll } from "@/components/screen-title"
import { ProfileHeaderButton } from "@/components/profile-header-button"
import { tabContentBottomInset } from "@/components/player"
import { useCachedPaginatedQuery } from "@/hooks/use-cached-query"
import { api } from "@otunes/convex/_generated/api"
@@ -57,9 +56,7 @@ export default function HomeScreen() {
(result) => result.status === "LoadingFirstPage" && !result.isCached
)
if (isLoading) {
return (
<HomeSkeleton title="Home" titleAccessory={<ProfileHeaderButton />} />
)
return <HomeSkeleton title="Home" />
}
const added = recentlyAdded.results.slice(0, CAROUSEL_ITEM_LIMIT)
@@ -76,12 +73,7 @@ export default function HomeScreen() {
]}
contentInsetAdjustmentBehavior="automatic"
>
<ScreenTitle
title="Home"
scrollY={scrollY}
accessory={<ProfileHeaderButton />}
style={styles.title}
/>
<ScreenTitle title="Home" scrollY={scrollY} style={styles.title} />
<HomeCarousels recentlyAdded={added} recentlyPlayed={played} />
</Animated.ScrollView>
)
@@ -5,7 +5,6 @@ import { Stack } from "expo-router"
import { ProfileHeaderButton } from "@/components/profile-header-button"
import {
inlineTitleOptions,
showHeaderProfile,
tabStackScreenTitles,
useStackScreenOptions,
} from "@/lib/navigation"
@@ -27,10 +26,18 @@ export default function LibraryLayout() {
title:
tabStackScreenTitles[route.name] ??
(tabletLayout ? "Recently Added" : "Library"),
// iOS shows the profile button inline with the screen title instead.
headerRight: showHeaderProfile(route.name)
? () => <ProfileHeaderButton />
: undefined,
headerRight:
route.name === "index" ? () => <ProfileHeaderButton /> : undefined,
unstable_headerRightItems:
route.name === "index"
? () => [
{
type: "custom",
element: <ProfileHeaderButton />,
hidesSharedBackground: true,
},
]
: undefined,
})}
/>
)
@@ -8,7 +8,6 @@ import { Ionicons } from "@expo/vector-icons"
import { MediaGridList } from "@/components/media-cards"
import { tabContentBottomInset } from "@/components/player"
import { MediaGridSkeleton } from "@/components/skeletons"
import { ProfileHeaderButton } from "@/components/profile-header-button"
import { useCachedPaginatedQuery } from "@/hooks/use-cached-query"
import { useAppNavigation } from "@/lib/app-navigation"
import { api } from "@otunes/convex/_generated/api"
@@ -129,7 +128,6 @@ export default function LibraryScreen() {
return (
<MediaGridSkeleton
title={title}
titleAccessory={<ProfileHeaderButton />}
contentInset={false}
header={listHeader}
/>
@@ -139,7 +137,6 @@ export default function LibraryScreen() {
return (
<MediaGridList
title={title}
titleAccessory={<ProfileHeaderButton />}
content={results}
paddingBottom={tabContentBottomInset}
contentInset={false}
@@ -4,7 +4,6 @@ import { Stack } from "expo-router"
import { ProfileHeaderButton } from "@/components/profile-header-button"
import {
inlineTitleOptions,
showHeaderProfile,
tabStackScreenTitles,
useStackScreenOptions,
} from "@/lib/navigation"
@@ -23,10 +22,18 @@ export default function SearchLayout() {
...baseOptions,
...inlineTitleOptions,
title: tabStackScreenTitles[route.name] ?? "Search",
// iOS shows the profile button inline with the screen title instead.
headerRight: showHeaderProfile(route.name)
? () => <ProfileHeaderButton />
: undefined,
headerRight:
route.name === "index" ? () => <ProfileHeaderButton /> : undefined,
unstable_headerRightItems:
route.name === "index"
? () => [
{
type: "custom",
element: <ProfileHeaderButton />,
hidesSharedBackground: true,
},
]
: undefined,
})}
/>
)
+1 -5
View File
@@ -7,7 +7,7 @@ import { MusicEntityView } from "@/components/music-entity-view"
import { ScreenTitle, useScreenTitleScroll } from "@/components/screen-title"
import { Link } from "expo-router"
import { Ionicons } from "@expo/vector-icons"
import { memo, useCallback, type ReactElement, type ReactNode } from "react"
import { memo, useCallback, type ReactElement } from "react"
import {
FlatList,
Platform,
@@ -302,7 +302,6 @@ export function MediaGridList({
ListHeaderComponent,
contentInset = true,
title,
titleAccessory,
}: {
content: MediaItem[]
paddingBottom: number
@@ -311,7 +310,6 @@ export function MediaGridList({
contentInset?: boolean
/** iOS `ScreenTitle` shown above the grid; it replaces the top inset. */
title?: string
titleAccessory?: ReactNode
}) {
const tabletLayout = useTabletLayout()
const { columns, cardWidth, onLayout, horizontalPadding, gap } =
@@ -336,7 +334,6 @@ export function MediaGridList({
ListHeaderComponent={ListHeaderComponent}
contentInset={contentInset}
title={title}
titleAccessory={titleAccessory}
renderCard={renderTabletCard}
/>
)
@@ -347,7 +344,6 @@ export function MediaGridList({
<ScreenTitle
title={title}
scrollY={scrollY}
accessory={titleAccessory}
// Inset grids already pad the whole list horizontally.
style={{ paddingHorizontal: contentInset ? 0 : horizontalPadding }}
/>
+14 -27
View File
@@ -1,12 +1,11 @@
import { useHeaderHeight } from "expo-router/react-navigation"
import type { Component, ReactNode } from "react"
import type { Component } from "react"
import {
Platform,
StyleSheet,
Text,
type ScrollViewInstance,
type StyleProp,
type ViewStyle,
type TextStyle,
} from "react-native"
import Animated, {
useAnimatedRef,
@@ -34,20 +33,17 @@ export function useScreenTitleScroll<
* iOS screen title rendered as the first item of a screen's scroll content,
* in place of the native large title (Apple Music style): it scrolls away
* with the content, never collapses into the bar, and stays put on
* pull-down. `accessory` (e.g. the profile button) sits on the same row and
* scrolls with it. Android keeps its native header, so this renders nothing.
* pull-down. Android keeps its native header title, so this renders nothing.
*/
export function ScreenTitle({
title,
scrollY,
accessory,
style,
}: {
title: string
/** From `useScreenTitleScroll`; omit for screens that never scroll. */
scrollY?: SharedValue<number>
accessory?: ReactNode
style?: StyleProp<ViewStyle>
style?: StyleProp<TextStyle>
}) {
const colors = useThemeColors()
// At rest the scroll offset is minus the automatic header inset, so any
@@ -64,34 +60,25 @@ export function ScreenTitle({
if (Platform.OS !== "ios") return null
return (
<Animated.View style={[styles.row, style, pinStyle]}>
<Text
accessibilityRole="header"
numberOfLines={2}
style={[styles.title, { color: colors.foreground }]}
>
{title}
</Text>
{accessory}
</Animated.View>
<Animated.Text
accessibilityRole="header"
numberOfLines={2}
style={[styles.title, { color: colors.foreground }, style, pinStyle]}
>
{title}
</Animated.Text>
)
}
// Matches UIKit's large title metrics: 34pt bold in a 52pt tall area.
const styles = StyleSheet.create({
row: {
flexDirection: "row",
alignItems: "center",
gap: spacing.md,
paddingHorizontal: spacing.lg,
paddingTop: 3,
paddingBottom: 8,
},
title: {
flex: 1,
fontSize: 34,
lineHeight: 41,
fontWeight: "700",
letterSpacing: 0.37,
paddingHorizontal: spacing.lg,
paddingTop: 3,
paddingBottom: 8,
},
})
+2 -12
View File
@@ -9,7 +9,6 @@ import {
import Animated from "react-native-reanimated"
import { ContentCarousel } from "@/components/media-cards"
import { ProfileHeaderButton } from "@/components/profile-header-button"
import { ScreenTitle, useScreenTitleScroll } from "@/components/screen-title"
import type { MediaAction } from "@/components/media-context-menu"
import { tabContentBottomInset, SongListRow } from "@/components/player"
@@ -87,12 +86,7 @@ function SearchResultsBody({
)
if (isSearching) {
return (
<SongListSkeleton
title={title}
titleAccessory={<ProfileHeaderButton />}
/>
)
return <SongListSkeleton title={title} />
}
return (
@@ -107,11 +101,7 @@ function SearchResultsBody({
keyboardShouldPersistTaps="handled"
ListHeaderComponent={
<>
<ScreenTitle
title={title}
scrollY={scrollY}
accessory={<ProfileHeaderButton />}
/>
<ScreenTitle title={title} scrollY={scrollY} />
{hasQuery && !hasResults ? (
<View style={styles.empty}>
<Text
+5 -26
View File
@@ -155,15 +155,13 @@ function SongRows({ rows, inset }: { rows: number; inset?: boolean }) {
export function SongListSkeleton({
rows = 10,
title,
titleAccessory,
}: {
rows?: number
title?: string
titleAccessory?: ReactNode
}) {
return (
<SkeletonScreen>
{title ? <ScreenTitle title={title} accessory={titleAccessory} /> : null}
{title ? <ScreenTitle title={title} /> : null}
<SongRows rows={rows} />
</SkeletonScreen>
)
@@ -245,7 +243,6 @@ export function MediaGridSkeleton({
contentInset = true,
header,
title,
titleAccessory,
}: {
items?: number
contentInset?: boolean
@@ -253,7 +250,6 @@ export function MediaGridSkeleton({
header?: ReactNode
/** The loaded list's `ScreenTitle`, which replaces its top inset. */
title?: string
titleAccessory?: ReactNode
}) {
return (
<SkeletonScreen>
@@ -263,7 +259,7 @@ export function MediaGridSkeleton({
header={
title ? (
<>
<MediaGridTitle title={title} accessory={titleAccessory} />
<MediaGridTitle title={title} />
{header}
</>
) : (
@@ -275,18 +271,11 @@ export function MediaGridSkeleton({
)
}
function MediaGridTitle({
title,
accessory,
}: {
title: string
accessory?: ReactNode
}) {
function MediaGridTitle({ title }: { title: string }) {
const { horizontalPadding } = useMediaGridLayout()
return (
<ScreenTitle
title={title}
accessory={accessory}
style={{ paddingHorizontal: horizontalPadding }}
/>
)
@@ -305,21 +294,11 @@ export function CarouselSkeleton() {
)
}
export function HomeSkeleton({
title,
titleAccessory,
}: {
title: string
titleAccessory?: ReactNode
}) {
export function HomeSkeleton({ title }: { title: string }) {
return (
<SkeletonScreen>
<View style={styles.home}>
<ScreenTitle
title={title}
accessory={titleAccessory}
style={styles.homeTitle}
/>
<ScreenTitle title={title} style={styles.homeTitle} />
<CarouselSkeleton />
<CarouselSkeleton />
</View>
@@ -4,7 +4,6 @@ import {
useRef,
useState,
type ReactElement,
type ReactNode,
} from "react"
import {
type ScrollViewInstance,
@@ -32,7 +31,6 @@ type GridProps = {
contentInset?: boolean
/** iOS `ScreenTitle` shown above the grid; it replaces the top inset. */
title?: string
titleAccessory?: ReactNode
renderCard: (item: MediaItem, width: number) => ReactElement
}
@@ -47,7 +45,6 @@ export function TabletMediaGrid({
ListHeaderComponent,
contentInset = true,
title,
titleAccessory,
renderCard,
}: GridProps) {
const colors = useThemeColors()
@@ -129,7 +126,6 @@ export function TabletMediaGrid({
<ScreenTitle
title={title}
scrollY={titleScrollY}
accessory={titleAccessory}
style={{ paddingHorizontal: horizontalPadding }}
/>
) : null}
+4 -2
View File
@@ -9,13 +9,15 @@
"APP_VARIANT": "development"
},
"developmentClient": true,
"distribution": "internal"
"distribution": "internal",
"credentialsSource": "local"
},
"preview": {
"env": {
"APP_VARIANT": "preview"
},
"distribution": "internal"
"distribution": "internal",
"credentialsSource": "local"
},
"production": {
"env": {
-5
View File
@@ -24,11 +24,6 @@ export const tabStackScreenTitles: Record<string, string> = {
export const inlineTitleOptions: StackScreenOptions =
Platform.OS === "ios" ? { headerTitleStyle: { color: "transparent" } } : {}
/** Tab roots show the profile button in the header, except on iOS where `ScreenTitle` holds it. */
export function showHeaderProfile(routeName: string) {
return routeName === "index" && Platform.OS !== "ios"
}
export function useStackScreenOptions(
overrides?: StackScreenOptions
): StackScreenOptions {
-3
View File
@@ -114,7 +114,6 @@ export function AlbumView({
}) {
const {
isSongFavorite,
areSongsFavorite,
isAlbumFavorite,
toggleSongFavorite,
toggleAlbumFavorite,
@@ -155,7 +154,6 @@ export function AlbumView({
handlePointerDown,
prepareContextMenu,
} = useTrackSelection(album.tracks, validHighlightedSongId)
const selectionFavorited = areSongsFavorite(selectedIds)
const selectionPositions = React.useMemo(
() =>
@@ -415,7 +413,6 @@ export function AlbumView({
isFavorite={isSongFavorite(track.id)}
selectedCount={selectedCount}
selectionStationArtistId={album.artist.id}
selectionFavorited={selectionFavorited}
isNowPlaying={currentSongId === track.id}
onPointerDown={handlePointerDown}
onSelect={handleRowSelect}
+21 -12
View File
@@ -37,8 +37,7 @@ type FavoritesContextValue = {
) => Promise<boolean>
toggleAlbumFavorite: (albumId: Id<"albums">) => Promise<void>
toggleArtistFavorite: (artistId: Id<"artists">) => Promise<void>
/** True when `songIds` is non-empty and every song is favorited. */
areSongsFavorite: (songIds: Iterable<string>) => boolean
favoriteSongs: (songIds: Id<"songs">[]) => Promise<void>
}
const FavoritesContext = React.createContext<FavoritesContextValue | null>(null)
@@ -131,16 +130,26 @@ export function FavoritesProvider({ children }: { children: React.ReactNode }) {
[songIds, favoriteSong, unfavoriteSong]
)
const areSongsFavorite = React.useCallback(
(ids: Iterable<string>) => {
let any = false
for (const id of ids) {
if (!songIds.has(id)) return false
any = true
const favoriteSongs = React.useCallback(
async (ids: Id<"songs">[]) => {
const unique = [...new Set(ids)]
if (unique.length === 0) {
return
}
try {
await favoriteSongsMutation({ songIds: unique })
toast.success(
unique.length > 1
? `Favorited ${unique.length} songs`
: "Added to favorites"
)
} catch (error) {
toast.error(
error instanceof Error ? error.message : "Failed to update favorites"
)
}
return any
},
[songIds]
[favoriteSongsMutation]
)
const toggleSongsFavorite = React.useCallback(
@@ -223,7 +232,7 @@ export function FavoritesProvider({ children }: { children: React.ReactNode }) {
toggleSongsFavorite,
toggleAlbumFavorite,
toggleArtistFavorite,
areSongsFavorite,
favoriteSongs,
}),
[
isSongFavorite,
@@ -233,7 +242,7 @@ export function FavoritesProvider({ children }: { children: React.ReactNode }) {
toggleSongsFavorite,
toggleAlbumFavorite,
toggleArtistFavorite,
areSongsFavorite,
favoriteSongs,
]
)
+1 -4
View File
@@ -48,8 +48,7 @@ export function OtherDownloadsView() {
[songs]
)
const { isSongFavorite, areSongsFavorite, toggleSongFavorite } =
useFavorites()
const { isSongFavorite, toggleSongFavorite } = useFavorites()
const { playFromSong, playInOrder, playShuffled } = usePlaybackActions()
const {
selectedIds,
@@ -63,7 +62,6 @@ export function OtherDownloadsView() {
() => stationArtistId(songs, selectedIds),
[songs, selectedIds]
)
const selectionFavorited = areSongsFavorite(selectedIds)
const selectionPositions = useMemo(
() =>
getSelectionRangePositions(
@@ -142,7 +140,6 @@ export function OtherDownloadsView() {
isFavorite={isSongFavorite(songs[index].id)}
selectedCount={selectedCount}
selectionStationArtistId={selectedStationArtistId}
selectionFavorited={selectionFavorited}
onPointerDown={handlePointerDown}
onSelect={handleRowSelect}
onPlay={handleRowPlay}
+2 -9
View File
@@ -74,12 +74,8 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) {
currentUser === undefined
? playlist.isOwner
: currentUser?._id === playlist.owner.id
const {
isSongFavorite,
areSongsFavorite,
toggleSongFavorite,
toggleSongsFavorite,
} = useFavorites()
const { isSongFavorite, toggleSongFavorite, toggleSongsFavorite } =
useFavorites()
const currentSongId = useCurrentSongId()
const {
playInOrder,
@@ -147,7 +143,6 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) {
() => stationArtistId(songs, selectedIds),
[songs, selectedIds]
)
const selectionFavorited = areSongsFavorite(selectedIds)
const selectionPositions = React.useMemo(
() =>
@@ -470,7 +465,6 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) {
onAction={handlePlaylistMediaAction}
playlistLabel={ADD_TO_ANOTHER_PLAYLIST}
showFavorite={!isFavorites}
favorited={areSongsFavorite(playlistSongIds)}
downloaded={playlistDownloaded}
trackRowTrigger={false}
triggerVariant="secondary"
@@ -528,7 +522,6 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) {
selectionPosition={selectionPositions[index]}
selectedCount={selectedCount}
selectionStationArtistId={selectedStationArtistId}
selectionFavorited={selectionFavorited}
playlistLabel={ADD_TO_ANOTHER_PLAYLIST}
downloadCollection={downloadRef}
showFavoriteInMenu={!isFavorites}
+40 -97
View File
@@ -3,16 +3,12 @@
import * as React from "react"
import { useFavorites } from "@/components/favorites-provider"
import {
MediaContextMenuArea,
type MediaContextAction,
} from "@/components/media-context-menu"
import type { MediaContextAction } from "@/components/media-context-menu"
import { PlaybackSongMeta } from "@/components/playback-song-meta"
import { usePlayback } from "@/components/playback-provider"
import { TrackCover, TrackRow } from "@/components/track-row"
import { Skeleton } from "@/components/ui/skeleton"
import { Spinner } from "@/components/ui/spinner"
import { useSongDownloadState } from "@/hooks/use-downloads"
import { useMediaActions } from "@/hooks/use-media-actions"
import { useTrackSelection } from "@/hooks/use-track-selection"
import type { Id } from "@otunes/convex/_generated/dataModel"
@@ -54,51 +50,6 @@ function toSelectableQueue(
})
}
/**
* Opens the song's right-click menu over `children`, for the queue rows that
* stand alone (history and the current song) rather than in the selection.
*/
function SongMenuArea({
song,
children,
}: {
song: BrowseSong
children: React.ReactElement
}) {
const { isSongFavorite, toggleSongFavorite } = useFavorites()
const { runSongsAction } = useMediaActions()
const downloaded = useSongDownloadState(song.id) === "here"
function handleAction(action: MediaContextAction) {
if (action === "favorite") {
void toggleSongFavorite(song.id)
return
}
runSongsAction(action, [song.id], song.artist.id)
}
return (
<MediaContextMenuArea
menu={{
label: `More options for ${song.title}`,
stationArtistId: song.artist.id,
selectedCount: 1,
onOpenMenu: () => {},
onAction: handleAction,
favorited: isSongFavorite(song.id),
downloaded,
navigation: {
artist: { id: song.artist.id },
album: { id: song.album.id },
},
share: { type: "song", albumId: song.album.id, songId: song.id },
}}
>
{children}
</MediaContextMenuArea>
)
}
/** A played song; clicking it plays it again from that point in history. */
function HistorySongRow({
song,
@@ -114,27 +65,25 @@ function HistorySongRow({
}
return (
<SongMenuArea song={song}>
<li
role="button"
tabIndex={0}
className="flex cursor-pointer items-center gap-3 px-4 py-2 text-sm hover:bg-foreground/5 data-[state=open]:bg-foreground/5"
onClick={() => onPlay(historyIndex)}
onKeyDown={(event) => {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault()
onPlay(historyIndex)
}
}}
>
<TrackCover
albumId={song.album.id}
alt={song.album.title}
inRange={false}
/>
<PlaybackSongMeta song={song} align="start" showAlbum={false} />
</li>
</SongMenuArea>
<li
role="button"
tabIndex={0}
className="flex cursor-pointer items-center gap-3 px-4 py-2 text-sm hover:bg-foreground/5"
onClick={() => onPlay(historyIndex)}
onKeyDown={(event) => {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault()
onPlay(historyIndex)
}
}}
>
<TrackCover
albumId={song.album.id}
alt={song.album.title}
inRange={false}
/>
<PlaybackSongMeta song={song} align="start" showAlbum={false} />
</li>
)
}
@@ -244,7 +193,7 @@ export function QueuePanel() {
prepareContextMenu,
clearSelection,
} = useTrackSelection(selectionItems)
const { isSongFavorite, areSongsFavorite } = useFavorites()
const { isSongFavorite } = useFavorites()
const { runSongsAction } = useMediaActions()
/** The rows a menu acts on: the selection, else just the clicked row. */
@@ -268,11 +217,6 @@ export function QueuePanel() {
),
[selectableQueue, selectedIds]
)
const selectionFavorited = areSongsFavorite(
selectableQueue.flatMap((item) =>
item.song && selectedIds.has(item.selectionId) ? [item.song.id] : []
)
)
const handleMediaAction = React.useCallback(
(action: MediaContextAction, selectionId: string) => {
@@ -410,25 +354,25 @@ export function QueuePanel() {
{/* Fills the viewport so the current song can always scroll to the top. */}
<div ref={currentRef} className="flex min-h-full flex-col">
{currentSong ? (
<SongMenuArea song={currentSong}>
<div className="flex items-center gap-3 px-4 py-3">
<TrackCover
albumId={currentSong.album.id}
alt={currentSong.album.title}
inRange={false}
size="lg"
/>
<PlaybackSongMeta
song={currentSong}
align="start"
showAlbum={false}
/>
</div>
</SongMenuArea>
) : currentQueueSongId ? (
<div className="px-4 py-3">
<Skeleton className="size-14 shrink-0 rounded-md" />
{currentQueueSongId ? (
<div className="flex items-center gap-3 px-4 py-3">
{currentSong ? (
<>
<TrackCover
albumId={currentSong.album.id}
alt={currentSong.album.title}
inRange={false}
size="lg"
/>
<PlaybackSongMeta
song={currentSong}
align="start"
showAlbum={false}
/>
</>
) : (
<Skeleton className="size-14 shrink-0 rounded-md" />
)}
</div>
) : null}
@@ -458,7 +402,6 @@ export function QueuePanel() {
isFavorite={isSongFavorite(item.song.id)}
selectedCount={selectedCount}
selectionStationArtistId={selectedStationArtistId}
selectionFavorited={selectionFavorited}
removeLabel="Remove from Queue"
selectionPosition={selectionPositions[index]}
isDragging={draggingIndices.has(index)}
+1 -4
View File
@@ -47,8 +47,7 @@ const SONGS_PAGE_SIZE = 50
const estimateSongRowSize = () => 56
export function SongsView() {
const { isSongFavorite, areSongsFavorite, toggleSongFavorite } =
useFavorites()
const { isSongFavorite, toggleSongFavorite } = useFavorites()
const { playFromLibrarySong } = usePlaybackActions()
const [sortKey, setSortKey] = useState<SortKey>("title")
const [sortDirection, setSortDirection] = useState<SortDirection>("asc")
@@ -99,7 +98,6 @@ export function SongsView() {
() => stationArtistId(songs, selectedIds),
[songs, selectedIds]
)
const selectionFavorited = areSongsFavorite(selectedIds)
const selectionPositions = useMemo(
() =>
@@ -224,7 +222,6 @@ export function SongsView() {
isFavorite={isSongFavorite(songs[index].id)}
selectedCount={selectedCount}
selectionStationArtistId={selectedStationArtistId}
selectionFavorited={selectionFavorited}
onPointerDown={handlePointerDown}
onSelect={handleRowSelect}
onPlay={handleRowPlay}
+1 -7
View File
@@ -68,8 +68,6 @@ export type TrackRowProps = {
selectedCount?: number
/** Station artist for the selection when this row is selected. */
selectionStationArtistId?: string
/** Whether every selected song is favorited, when this row is selected. */
selectionFavorited?: boolean
playlistLabel?: string
showFavoriteInMenu?: boolean
/** Adds a destructive menu item calling `onRemove`. */
@@ -270,7 +268,6 @@ function TrackRowComponent({
isDragging = false,
selectedCount = 0,
selectionStationArtistId,
selectionFavorited,
playlistLabel,
showFavoriteInMenu = true,
removeLabel,
@@ -348,10 +345,7 @@ function TrackRowComponent({
onAction: (action) => onMediaAction(action, rowId),
playlistLabel,
showFavorite: showFavoriteInMenu,
favorited:
inRange && selectedCount > 0
? (selectionFavorited ?? isFavorite)
: isFavorite,
favorited: isFavorite,
navigation: {
artist: { id: song.artist.id },
album: { id: song.album.id },
+3 -6
View File
@@ -26,8 +26,7 @@ function songsTitle(songIds: readonly string[]) {
export function useMediaActions() {
const { openAddToPlaylist, openAddArtistToPlaylist } = useAddToPlaylist()
const { areSongsFavorite, toggleSongsFavorite, toggleArtistFavorite } =
useFavorites()
const { favoriteSongs, toggleArtistFavorite } = useFavorites()
const { runQueueAction, createStation } = useQueueMediaActions()
const convex = useConvex()
const cacheScope = useCacheScope()
@@ -45,8 +44,7 @@ export function useMediaActions() {
if (stationArtist) void createStation(stationArtist)
break
case "favorite":
// Unfavorite only when every song already is, matching the menu label.
void toggleSongsFavorite(songIds, areSongsFavorite(songIds))
void favoriteSongs(songIds)
break
case "playlist":
openAddToPlaylist(songIds)
@@ -75,8 +73,7 @@ export function useMediaActions() {
},
[
createStation,
areSongsFavorite,
toggleSongsFavorite,
favoriteSongs,
openAddToPlaylist,
runQueueAction,
requestDownload,