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
This commit is contained in:
remhelper authored and joshuafhiggins committed 2026-07-05 21:30:09 -04:00 Verified
1 parent b1af72bfa5
commit 0e702bb852
4 files changed
+37 -7

No files matched your search

+8 -3
View File
@@ -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 (
<ThemeProvider value={routerTheme}>
@@ -90,9 +93,11 @@ export default function TabsLayout() {
tintColor={appleMusic.pink}
minimizeBehavior="onScrollDown"
>
<NativeTabs.BottomAccessory>
<TabBottomAccessory />
</NativeTabs.BottomAccessory>
{showBottomAccessory ? (
<NativeTabs.BottomAccessory>
<TabBottomAccessory />
</NativeTabs.BottomAccessory>
) : null}
<NativeTabs.Trigger name="home" disableTransparentOnScrollEdge>
<NativeTabs.Trigger.Icon sf="house.fill" md="home" />
+13
View File
@@ -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) {
+13
View File
@@ -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) {
+3 -4
View File
@@ -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,