From b3fc2eeb5895b09870b4410b8fe45e823b193eee Mon Sep 17 00:00:00 2001 From: Rem Helper Date: Mon, 6 Jul 2026 01:24:19 +0000 Subject: [PATCH 1/2] Hide player bar when queue is empty - Stop showing the mini player when there is no queued track - Reset playback state to 0 and paused at end of queue - Keep the current song in queue history when skipping the last track --- apps/mobile/app/(app)/(tabs)/_layout.tsx | 11 ++++++++--- apps/mobile/contexts/playback.tsx | 13 +++++++++++++ apps/web/components/playback-provider.tsx | 13 +++++++++++++ packages/convex/convex/playback.ts | 7 +++---- 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/apps/mobile/app/(app)/(tabs)/_layout.tsx b/apps/mobile/app/(app)/(tabs)/_layout.tsx index 075ee6e..6620e89 100644 --- a/apps/mobile/app/(app)/(tabs)/_layout.tsx +++ b/apps/mobile/app/(app)/(tabs)/_layout.tsx @@ -4,6 +4,7 @@ import { DynamicColorIOS, Platform, useColorScheme } from "react-native" import { useMemo } from "react" import { TabBottomAccessory } from "@/components/mini-player" +import { usePlayback } from "@/contexts/playback" import { appleMusic, colors } from "@/lib/theme" function useRouterTheme() { @@ -75,6 +76,8 @@ function useNativeTabColors() { export default function TabsLayout() { const routerTheme = useRouterTheme() const tabColors = useNativeTabColors() + const { currentSong, queueSongIds } = usePlayback() + const showBottomAccessory = Boolean(currentSong && queueSongIds.length > 0) return ( @@ -90,9 +93,11 @@ export default function TabsLayout() { tintColor={appleMusic.pink} minimizeBehavior="onScrollDown" > - - - + {showBottomAccessory ? ( + + + + ) : null} diff --git a/apps/mobile/contexts/playback.tsx b/apps/mobile/contexts/playback.tsx index df05584..d50356b 100644 --- a/apps/mobile/contexts/playback.tsx +++ b/apps/mobile/contexts/playback.tsx @@ -236,7 +236,15 @@ export function PlaybackProvider({ children }: { children: ReactNode }) { autoPlayNextRef.current = true isPlayingRef.current = true setIsPlayingState(true) + return } + + autoPlayNextRef.current = false + isPlayingRef.current = false + void playerRef.current?.seekTo(0) + currentTimeRef.current = 0 + setCurrentTime(0) + setIsPlayingState(false) }) .catch(() => { autoPlayNextRef.current = false @@ -655,7 +663,12 @@ export function PlaybackProvider({ children }: { children: ReactNode }) { await skipToQueueIndexMutation({ index }) }, skipNext: async () => { + const isFinishingQueue = repeatEnabled === "none" && queueLength <= 1 await skipNextMutation() + if (isFinishingQueue) { + await seekTo(0) + setIsPlaying(false) + } }, skipPrevious: async () => { if (currentTime > PREVIOUS_TRACK_RESTART_THRESHOLD_SECONDS) { diff --git a/apps/web/components/playback-provider.tsx b/apps/web/components/playback-provider.tsx index 4f7b9b5..370c2c1 100644 --- a/apps/web/components/playback-provider.tsx +++ b/apps/web/components/playback-provider.tsx @@ -790,7 +790,14 @@ export function PlaybackProvider({ children }: { children: ReactNode }) { autoPlayNextRef.current = true isPlayingRef.current = true setIsPlaying(true) + return } + + autoPlayNextRef.current = false + isPlayingRef.current = false + audio.currentTime = 0 + setCurrentTime(0) + setIsPlaying(false) }) .catch(() => { autoPlayNextRef.current = false @@ -1066,7 +1073,13 @@ export function PlaybackProvider({ children }: { children: ReactNode }) { await skipToQueueIndexMutation({ index }) }, skipNext: async () => { + const isFinishingQueue = + repeatEnabled === "none" && queueSongIds.length <= 1 await skipNextMutation() + if (isFinishingQueue) { + seekTo(0) + setIsPlaying(false) + } }, skipPrevious: async () => { if (currentTime > PREVIOUS_TRACK_RESTART_THRESHOLD_SECONDS) { diff --git a/packages/convex/convex/playback.ts b/packages/convex/convex/playback.ts index 955a483..b67cb08 100644 --- a/packages/convex/convex/playback.ts +++ b/packages/convex/convex/playback.ts @@ -511,17 +511,16 @@ export const skipNext = mutation({ return } - const history = appendToQueueHistory(user.queueHistory ?? [], current) - if (rest.length === 0) { await ctx.db.patch(userId, { - songQueue: [], - queueHistory: history, + songQueue: [current], currentSongProgress: 0, }) return } + const history = appendToQueueHistory(user.queueHistory ?? [], current) + await ctx.db.patch(userId, { songQueue: rest, queueHistory: history, -- 2.54.1 From 66e4e9d677d657f83dd996cea8899361533f7cf7 Mon Sep 17 00:00:00 2001 From: Rem Helper Date: Mon, 6 Jul 2026 02:02:53 +0000 Subject: [PATCH 2/2] Fix beahviors --- apps/mobile/app/(app)/(tabs)/home/queue.tsx | 17 +++++++++++++++-- apps/mobile/app/(app)/player.tsx | 13 +++++++++++++ apps/mobile/contexts/playback.tsx | 5 ++++- apps/web/components/playback-provider.tsx | 5 ++++- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/apps/mobile/app/(app)/(tabs)/home/queue.tsx b/apps/mobile/app/(app)/(tabs)/home/queue.tsx index a1b4283..1a1257e 100644 --- a/apps/mobile/app/(app)/(tabs)/home/queue.tsx +++ b/apps/mobile/app/(app)/(tabs)/home/queue.tsx @@ -1,5 +1,5 @@ import { usePaginatedQuery, useQuery } from "convex/react" -import { Stack } from "expo-router" +import { Stack, useRouter } from "expo-router" import { FlatList, Pressable, StyleSheet, Text, View } from "react-native" import { Button, LoadingView } from "@/components/ui/primitives" @@ -12,6 +12,7 @@ import { spacing, useThemeColors } from "@/lib/theme" const PAGE_SIZE = 50 export default function QueueScreen() { + const router = useRouter() const colors = useThemeColors() const { queueSongIds, @@ -42,6 +43,18 @@ export default function QueueScreen() { void reorderQueue(next) } + function handleClearQueue() { + if (router.canGoBack()) { + router.back() + setTimeout(() => { + void clearQueue() + }, 0) + return + } + + void clearQueue() + } + if (queueSongs === undefined) { return } @@ -52,7 +65,7 @@ export default function QueueScreen() { options={{ headerRight: () => queueSongIds.length > 0 ? ( -