Fix beahviors

This commit is contained in:
remhelper committed 2026-07-06 02:03:42 +00:00 Verified
1 parent b3fc2eeb58
commit 66e4e9d677
4 files changed
+36 -4

No files matched your search

+15 -2
View File
@@ -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 <LoadingView />
}
@@ -52,7 +65,7 @@ export default function QueueScreen() {
options={{
headerRight: () =>
queueSongIds.length > 0 ? (
<Button title="Clear" variant="ghost" onPress={() => void clearQueue()} />
<Button title="Clear" variant="ghost" onPress={handleClearQueue} />
) : null,
}}
/>
+13
View File
@@ -3,6 +3,7 @@ import Slider from "@react-native-community/slider"
import { BlurView } from "expo-blur"
import { useRouter } from "expo-router"
import * as Haptics from "expo-haptics"
import { useEffect, useRef } from "react"
import {
Platform,
Pressable,
@@ -26,6 +27,7 @@ import { appleMusic, radius, spacing, usePlayerTheme } from "@/lib/theme"
export default function PlayerScreen() {
const router = useRouter()
const hadSongRef = useRef(false)
const { push } = useAppNavigation()
const insets = useSafeAreaInsets()
const player = usePlayerTheme()
@@ -50,6 +52,17 @@ export default function PlayerScreen() {
skipPrevious,
} = usePlayback()
useEffect(() => {
if (currentSong) {
hadSongRef.current = true
return
}
if (hadSongRef.current) {
router.back()
}
}, [currentSong, router])
if (!currentSong || !config) {
return null
}
+4 -1
View File
@@ -664,10 +664,13 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
},
skipNext: async () => {
const isFinishingQueue = repeatEnabled === "none" && queueLength <= 1
if (isFinishingQueue) {
setIsPlaying(false)
await seekTo(0)
}
await skipNextMutation()
if (isFinishingQueue) {
await seekTo(0)
setIsPlaying(false)
}
},
skipPrevious: async () => {
+4 -1
View File
@@ -1075,10 +1075,13 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
skipNext: async () => {
const isFinishingQueue =
repeatEnabled === "none" && queueSongIds.length <= 1
if (isFinishingQueue) {
setIsPlaying(false)
seekTo(0)
}
await skipNextMutation()
if (isFinishingQueue) {
seekTo(0)
setIsPlaying(false)
}
},
skipPrevious: async () => {