diff --git a/.dockerignore b/.dockerignore index 3e1c66f..2330f90 100644 --- a/.dockerignore +++ b/.dockerignore @@ -54,12 +54,11 @@ playwright.config.* *~ *.log -# Environment variables (only commit template files) -.env -.env*.local -.env.development -.env.test -.env.production.local +# Environment variables, in any workspace. Next.js inlines NEXT_PUBLIC_* values +# into the bundle and the Convex CLI reads .env.local on deploy. +**/.env +**/.env.* +!**/.env.example # Docker configuration files (not needed inside build context) Dockerfile* diff --git a/Dockerfile b/Dockerfile index 543c78d..ae29c75 100644 --- a/Dockerfile +++ b/Dockerfile @@ -195,7 +195,12 @@ RUN node --version \ && ldd /convex/generate_key \ && ! ldd /convex/convex-local-backend /convex/generate_key | grep -q 'not found' -RUN useradd --system --user-group --home-dir /app --shell /usr/sbin/nologin otunes +# The backend gets its own user so the web server cannot read the database or +# instance secret. It joins the otunes group to clean up the web server's HLS +# cache in /tmp/otunes. +RUN useradd --system --user-group --home-dir /app --shell /usr/sbin/nologin otunes \ + && useradd --system --user-group --groups otunes --create-home --home-dir /home/convex \ + --shell /usr/sbin/nologin convex COPY --from=convex-functions /app /opt/otunes/convex COPY docker/generate-auth-keys.mjs /opt/otunes/generate-auth-keys.mjs diff --git a/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/queue.tsx b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/queue.tsx deleted file mode 100644 index 4d4acb6..0000000 --- a/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/queue.tsx +++ /dev/null @@ -1 +0,0 @@ -export { default } from "../library/queue" diff --git a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx index a32bf8c..66a7c26 100644 --- a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx +++ b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx @@ -35,7 +35,7 @@ import { MediaActionMenu, MediaContextMenu, type MediaAction, -} from "@/components/media-actions-sheet" +} from "@/components/media-context-menu" import { CollectionDetailSkeleton } from "@/components/skeletons" import { Button } from "@/components/ui/primitives" import { contentBottomInset } from "@/components/player" @@ -488,7 +488,7 @@ const AlbumTrackRow = memo(function AlbumTrackRow({ action: MediaAction ) => Promise }) { - const Row = Platform.OS === "ios" ? SongSwipeRow : Pressable + const Row = Platform.OS !== "web" ? SongSwipeRow : Pressable const { config } = useServerConfig() return ( void onAction(track, album, "play-next")} + onAddToQueue={() => void onAction(track, album, "play-last")} style={styles.trackRow} onPress={() => void onPlay(track.id as Id<"songs">, songIds)} > diff --git a/apps/mobile/app/(app)/(tabs)/home/artist/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/artist/[id].tsx index ef90e47..4b6b215 100644 --- a/apps/mobile/app/(app)/(tabs)/home/artist/[id].tsx +++ b/apps/mobile/app/(app)/(tabs)/home/artist/[id].tsx @@ -6,7 +6,7 @@ import { Ionicons } from "@expo/vector-icons" import { CoverImage } from "@/components/cover-image" import { MediaGridList } from "@/components/media-cards" -import { MediaActionMenu } from "@/components/media-actions-sheet" +import { MediaActionMenu } from "@/components/media-context-menu" import { CollectionDetailSkeleton } from "@/components/skeletons" import { Button } from "@/components/ui/primitives" import { contentBottomInset } from "@/components/player" diff --git a/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx index f11a0d1..e9f46f1 100644 --- a/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx +++ b/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx @@ -46,7 +46,7 @@ import { import { MediaActionMenu, type MediaAction, -} from "@/components/media-actions-sheet" +} from "@/components/media-context-menu" import { CollectionDetailSkeleton } from "@/components/skeletons" import { Button } from "@/components/ui/primitives" import { contentBottomInset, SongListRow } from "@/components/player" @@ -314,7 +314,6 @@ function PlaylistContent({ deletePlaylist, handlePlaylistDetailAction, palette.foreground, - palette.background, palette.isDark, playlistId, playlist?.title, @@ -434,11 +433,18 @@ const PlaylistSongRow = memo(function PlaylistSongRow({ palette={palette} inset swipe={ - Platform.OS === "ios" + Platform.OS !== "web" ? { group: swipeGroup, backgroundColor: palette.background, onPlayNext: () => onAction(song, "play-next"), + onAddToQueue: () => onAction(song, "play-last"), + onRemove: + Platform.OS === "android" && removable + ? () => { + void onRemove(song.id) + } + : undefined, } : undefined } @@ -447,7 +453,7 @@ const PlaylistSongRow = memo(function PlaylistSongRow({ /> ) - if (Platform.OS === "ios" || !removable) { + if (Platform.OS !== "web" || !removable) { return row } diff --git a/apps/mobile/app/(app)/(tabs)/home/queue.tsx b/apps/mobile/app/(app)/(tabs)/home/queue.tsx deleted file mode 100644 index c378ed7..0000000 --- a/apps/mobile/app/(app)/(tabs)/home/queue.tsx +++ /dev/null @@ -1,186 +0,0 @@ -import { Stack, useRouter } from "expo-router" -import { memo, useCallback, useMemo } from "react" -import { FlatList, Pressable, StyleSheet, Text, View } from "react-native" - -import { Button } from "@/components/ui/primitives" -import { contentBottomInset, SongRow } from "@/components/player" -import { SongRowSkeleton } from "@/components/skeletons" -import { usePlaybackActions, usePlaybackQueue } from "@/contexts/playback" -import type { Id } from "@otunes/convex/_generated/dataModel" -import { longListProps } from "@/lib/list" -import { useSong, useSongs } from "@/lib/song-cache" -import { spacing, useThemeColors } from "@/lib/theme" - -/** `key` stays stable when earlier songs leave the queue, so rows are not remounted on skip. */ -type QueueItem = { songId: Id<"songs">; queueIndex: number; key: string } - -function queueItemKey(item: QueueItem) { - return item.key -} - -const QueueRow = memo(function QueueRow({ - songId, - queueIndex, - isLast, - isCurrent, - onSkipTo, - onMove, -}: Omit & { - isLast: boolean - isCurrent: boolean - onSkipTo: (index: number) => void - onMove: (index: number, direction: -1 | 1) => void -}) { - const colors = useThemeColors() - const song = useSong(songId) - - return ( - - {song ? ( - onSkipTo(queueIndex)} /> - ) : ( - - )} - - onMove(queueIndex, -1)} - > - Move up - - onMove(queueIndex, 1)}> - Move down - - {isCurrent ? ( - - Now playing - - ) : null} - - - ) -}) - -export default function QueueScreen() { - const router = useRouter() - const colors = useThemeColors() - const { queueSongIds, queueHistorySongIds } = usePlaybackQueue() - const { skipToQueueIndex, clearQueue, reorderQueue } = usePlaybackActions() - const historySongs = useSongs(queueHistorySongIds) - - const items = useMemo(() => { - const occurrences = new Map() - return queueSongIds.map((songId, queueIndex) => { - const occurrence = occurrences.get(songId) ?? 0 - occurrences.set(songId, occurrence + 1) - return { songId, queueIndex, key: `${songId}:${occurrence}` } - }) - }, [queueSongIds]) - - const moveSong = useCallback( - (fromIndex: number, direction: -1 | 1) => { - const toIndex = fromIndex + direction - if (toIndex < 0 || toIndex >= queueSongIds.length) return - const next = [...queueSongIds] - const [item] = next.splice(fromIndex, 1) - next.splice(toIndex, 0, item) - void reorderQueue(next) - }, - [queueSongIds, reorderQueue] - ) - - function handleClearQueue() { - if (router.canGoBack()) { - router.back() - setTimeout(() => { - void clearQueue() - }, 0) - return - } - - void clearQueue() - } - - return ( - <> - - queueSongIds.length > 0 ? ( -