fix: all headers hopefully are fixed
This commit is contained in:
1 parent
0ff352e11a
commit
482bec1fd1
59 files changed
+782
-362
No files matched your search
@@ -96,15 +96,7 @@ export default function TabsLayout() {
|
||||
<NativeTabs.Trigger.Label>Library</NativeTabs.Trigger.Label>
|
||||
</NativeTabs.Trigger>
|
||||
|
||||
<NativeTabs.Trigger name="playlists" disableTransparentOnScrollEdge>
|
||||
<NativeTabs.Trigger.Icon
|
||||
sf={{ default: "music.note.list", selected: "music.note.list" }}
|
||||
md="playlist_play"
|
||||
/>
|
||||
<NativeTabs.Trigger.Label>Playlists</NativeTabs.Trigger.Label>
|
||||
</NativeTabs.Trigger>
|
||||
|
||||
<NativeTabs.Trigger name="search" role="search" disableTransparentOnScrollEdge>
|
||||
<NativeTabs.Trigger name="search" disableTransparentOnScrollEdge>
|
||||
<NativeTabs.Trigger.Icon sf="magnifyingglass" md="search" />
|
||||
<NativeTabs.Trigger.Label>Search</NativeTabs.Trigger.Label>
|
||||
</NativeTabs.Trigger>
|
||||
|
||||
@@ -1,7 +1,21 @@
|
||||
import { Stack } from "expo-router"
|
||||
|
||||
import { useStackScreenOptions } from "@/lib/navigation"
|
||||
import { tabStackScreenTitles, useStackScreenOptions } from "@/lib/navigation"
|
||||
|
||||
export const unstable_settings = {
|
||||
initialRouteName: "index",
|
||||
}
|
||||
|
||||
export default function HomeLayout() {
|
||||
return <Stack screenOptions={useStackScreenOptions({ title: "Home" })} />
|
||||
const baseOptions = useStackScreenOptions({ title: "Home" })
|
||||
|
||||
return (
|
||||
<Stack
|
||||
initialRouteName="index"
|
||||
screenOptions={({ route }) => ({
|
||||
...baseOptions,
|
||||
title: tabStackScreenTitles[route.name] ?? "Home",
|
||||
})}
|
||||
/>
|
||||
)
|
||||
}
|
||||
+8
-4
@@ -1,6 +1,6 @@
|
||||
import { useQuery } from "convex/react"
|
||||
import { Image } from "expo-image"
|
||||
import { Stack, useLocalSearchParams, useRouter } from "expo-router"
|
||||
import { Stack, useLocalSearchParams } from "expo-router"
|
||||
import { useState } from "react"
|
||||
import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native"
|
||||
import { Ionicons } from "@expo/vector-icons"
|
||||
@@ -16,15 +16,19 @@ import { api } from "@otunes/convex/_generated/api"
|
||||
import type { Id } from "@otunes/convex/_generated/dataModel"
|
||||
import type { BrowseAlbumTrack } from "@otunes/convex/types"
|
||||
import { formatDuration, formatMetadata } from "@/lib/format"
|
||||
import { useAppNavigation } from "@/lib/app-navigation"
|
||||
import { albumCoverUrl } from "@/lib/urls"
|
||||
import { radius, spacing, useThemeColors } from "@/lib/theme"
|
||||
|
||||
export default function AlbumScreen() {
|
||||
const { id } = useLocalSearchParams<{ id: string }>()
|
||||
const router = useRouter()
|
||||
const { push } = useAppNavigation()
|
||||
const colors = useThemeColors()
|
||||
const { config } = useServerConfig()
|
||||
const album = useQuery(api.library.browseAlbumDetail, { id: id as Id<"albums"> })
|
||||
const album = useQuery(
|
||||
api.library.browseAlbumDetail,
|
||||
typeof id === "string" ? { id: id as Id<"albums"> } : "skip"
|
||||
)
|
||||
const { playAlbum, playAlbumShuffled, playFromSong } = usePlayback()
|
||||
const { isAlbumFavorite, toggleAlbumFavorite } = useFavorites()
|
||||
const { openAddAlbumToPlaylist } = useAddToPlaylist()
|
||||
@@ -84,7 +88,7 @@ export default function AlbumScreen() {
|
||||
contentFit="cover"
|
||||
/>
|
||||
<Text style={[styles.title, { color: colors.foreground }]}>{album.title}</Text>
|
||||
<Pressable onPress={() => router.push(`/artist/${album.artist.id}`)}>
|
||||
<Pressable onPress={() => push(`/artist/${album.artist.id}`)}>
|
||||
<Text style={[styles.artist, { color: colors.mutedForeground }]}>{album.artist.name}</Text>
|
||||
</Pressable>
|
||||
{metadata ? (
|
||||
File renamed without changes.
File renamed without changes.
+3
-3
@@ -1,18 +1,18 @@
|
||||
import { useQuery } from "convex/react"
|
||||
import { useRouter } from "expo-router"
|
||||
import { Pressable, ScrollView, StyleSheet, Text } from "react-native"
|
||||
import { Image } from "expo-image"
|
||||
|
||||
import { LoadingView } from "@/components/ui/primitives"
|
||||
import { contentBottomInset } from "@/components/player"
|
||||
import { useServerConfig } from "@/contexts/server-config"
|
||||
import { useAppNavigation } from "@/lib/app-navigation"
|
||||
import { api } from "@otunes/convex/_generated/api"
|
||||
import type { BrowseArtist } from "@otunes/convex/types"
|
||||
import { artistCoverUrl } from "@/lib/urls"
|
||||
import { radius, spacing, useThemeColors } from "@/lib/theme"
|
||||
|
||||
export default function ArtistsScreen() {
|
||||
const router = useRouter()
|
||||
const { push } = useAppNavigation()
|
||||
const colors = useThemeColors()
|
||||
const { config } = useServerConfig()
|
||||
const artists = useQuery(api.library.browseArtists)
|
||||
@@ -31,7 +31,7 @@ export default function ArtistsScreen() {
|
||||
<Pressable
|
||||
key={artist.id}
|
||||
style={[styles.row, { borderBottomColor: colors.border }]}
|
||||
onPress={() => router.push(`/artist/${artist.id}`)}
|
||||
onPress={() => push(`/artist/${artist.id}`)}
|
||||
>
|
||||
<Image
|
||||
source={{ uri: artistCoverUrl(config.serverUrl, artist.id) }}
|
||||
File renamed without changes.
+1
-1
@@ -96,7 +96,7 @@ export default function PlaylistScreen() {
|
||||
<>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
title: playlist.title,
|
||||
title: "",
|
||||
headerLargeTitle: false,
|
||||
headerRight: () => (
|
||||
<Pressable onPress={() => setMenuOpen(true)} hitSlop={8}>
|
||||
+17
-3
@@ -1,7 +1,7 @@
|
||||
import { useQuery } from "convex/react"
|
||||
import { Image } from "expo-image"
|
||||
import { useState } from "react"
|
||||
import { ScrollView, StyleSheet, Text, View } from "react-native"
|
||||
import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native"
|
||||
|
||||
import { MediaActionsSheet, type MediaAction } from "@/components/media-actions-sheet"
|
||||
import { Button, LoadingView } from "@/components/ui/primitives"
|
||||
@@ -14,6 +14,8 @@ import { api } from "@otunes/convex/_generated/api"
|
||||
import type { BrowseSong } from "@otunes/convex/types"
|
||||
import { playlistCoverUrl } from "@/lib/urls"
|
||||
import { radius, spacing, useThemeColors } from "@/lib/theme"
|
||||
import { Ionicons } from "@expo/vector-icons"
|
||||
import { Stack } from "expo-router"
|
||||
|
||||
export default function FavoritesScreen() {
|
||||
const colors = useThemeColors()
|
||||
@@ -54,6 +56,12 @@ export default function FavoritesScreen() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
title: "",
|
||||
headerLargeTitle: false,
|
||||
}}
|
||||
/>
|
||||
<ScrollView
|
||||
style={{ flex: 1, backgroundColor: colors.background }}
|
||||
contentContainerStyle={{ paddingBottom: contentBottomInset }}
|
||||
@@ -65,10 +73,16 @@ export default function FavoritesScreen() {
|
||||
style={styles.cover}
|
||||
contentFit="cover"
|
||||
/>
|
||||
<Text style={[styles.title, { color: colors.foreground }]}>{favorites.title}</Text>
|
||||
<Text style={[styles.title, { color: colors.foreground }]}>
|
||||
{favorites.title}
|
||||
</Text>
|
||||
<View style={styles.actions}>
|
||||
<Button title="Play" onPress={() => void playInOrder(songIds)} />
|
||||
<Button title="Shuffle" variant="secondary" onPress={() => void playShuffled(songIds)} />
|
||||
<Button
|
||||
title="Shuffle"
|
||||
variant="secondary"
|
||||
onPress={() => void playShuffled(songIds)}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,7 +1,21 @@
|
||||
import { Stack } from "expo-router"
|
||||
|
||||
import { useStackScreenOptions } from "@/lib/navigation"
|
||||
import { tabStackScreenTitles, useStackScreenOptions } from "@/lib/navigation"
|
||||
|
||||
export const unstable_settings = {
|
||||
initialRouteName: "index",
|
||||
}
|
||||
|
||||
export default function LibraryLayout() {
|
||||
return <Stack screenOptions={useStackScreenOptions({ title: "Library" })} />
|
||||
const baseOptions = useStackScreenOptions({ title: "Library" })
|
||||
|
||||
return (
|
||||
<Stack
|
||||
initialRouteName="index"
|
||||
screenOptions={({ route }) => ({
|
||||
...baseOptions,
|
||||
title: tabStackScreenTitles[route.name] ?? "Library",
|
||||
})}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../home/album/[id]"
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../home/artist/[id]"
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../home/browse/albums"
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../home/browse/artists"
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../home/browse/songs"
|
||||
@@ -1,5 +1,4 @@
|
||||
import { useQuery } from "convex/react"
|
||||
import { useRouter } from "expo-router"
|
||||
import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native"
|
||||
import { SymbolView } from "expo-symbols"
|
||||
import { Platform } from "react-native"
|
||||
@@ -8,16 +7,16 @@ import { Ionicons } from "@expo/vector-icons"
|
||||
import { MediaGrid } from "@/components/media-cards"
|
||||
import { tabContentBottomInset } from "@/components/player"
|
||||
import { LoadingView } from "@/components/ui/primitives"
|
||||
import { useAppNavigation } from "@/lib/app-navigation"
|
||||
import { api } from "@otunes/convex/_generated/api"
|
||||
import { appleMusic, spacing, useThemeColors } from "@/lib/theme"
|
||||
|
||||
const links = [
|
||||
{ title: "Playlists", href: "/(app)/(tabs)/playlists", icon: "music.note.list" as const },
|
||||
{ title: "Artists", href: "/library/artists", icon: "mic.fill" as const },
|
||||
{ title: "Albums", href: "/library/albums", icon: "square.stack" as const },
|
||||
{ title: "Songs", href: "/library/songs", icon: "music.note" as const },
|
||||
{ title: "Playlists", href: "/playlists", icon: "music.note.list" as const },
|
||||
{ title: "Artists", href: "/browse/artists", icon: "mic.fill" as const },
|
||||
{ title: "Albums", href: "/browse/albums", icon: "square.stack" as const },
|
||||
{ title: "Songs", href: "/browse/songs", icon: "music.note" as const },
|
||||
{ title: "Recently Played", href: "/recently-played", icon: "clock" as const },
|
||||
{ title: "Recently Added", href: "/recently-added", icon: "sparkles" as const },
|
||||
{ title: "Favorites", href: "/playlist/favorites", icon: "star" as const },
|
||||
]
|
||||
|
||||
@@ -45,7 +44,7 @@ function LibraryIcon({ name }: { name: (typeof links)[number]["icon"] }) {
|
||||
}
|
||||
|
||||
export default function LibraryScreen() {
|
||||
const router = useRouter()
|
||||
const { push } = useAppNavigation()
|
||||
const colors = useThemeColors()
|
||||
const recentlyAdded = useQuery(api.library.browseRecentlyAdded)
|
||||
|
||||
@@ -59,7 +58,7 @@ export default function LibraryScreen() {
|
||||
<Pressable
|
||||
key={link.href}
|
||||
style={[styles.row, { borderBottomColor: colors.border }]}
|
||||
onPress={() => router.push(link.href as never)}
|
||||
onPress={() => push(link.href)}
|
||||
>
|
||||
<LibraryIcon name={link.icon} />
|
||||
<Text style={[styles.rowTitle, { color: colors.foreground }]}>{link.title}</Text>
|
||||
@@ -68,7 +67,7 @@ export default function LibraryScreen() {
|
||||
))}
|
||||
|
||||
<View style={styles.section}>
|
||||
<Pressable onPress={() => router.push("/recently-added")}>
|
||||
<Pressable onPress={() => push("/recently-added")}>
|
||||
<Text style={[styles.sectionTitle, { color: colors.foreground }]}>
|
||||
Recently Added
|
||||
</Text>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../home/playlist/[id]"
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../home/playlist/favorites"
|
||||
@@ -0,0 +1,56 @@
|
||||
import { useQuery } from "convex/react"
|
||||
import { Pressable, ScrollView, StyleSheet } from "react-native"
|
||||
|
||||
import { MediaGrid } from "@/components/media-cards"
|
||||
import { LoadingView } from "@/components/ui/primitives"
|
||||
import { tabContentBottomInset } from "@/components/player"
|
||||
import { api } from "@otunes/convex/_generated/api"
|
||||
import { spacing, useThemeColors } from "@/lib/theme"
|
||||
import { Ionicons } from "@expo/vector-icons"
|
||||
import { Stack } from "expo-router"
|
||||
import { SymbolView } from "expo-symbols"
|
||||
import { useAddToPlaylist } from "@/contexts/add-to-playlist"
|
||||
|
||||
export default function PlaylistsTabScreen() {
|
||||
const colors = useThemeColors()
|
||||
const playlists = useQuery(api.playlists.listAllPlaylists)
|
||||
const { openCreatePlaylist } = useAddToPlaylist()
|
||||
|
||||
if (playlists === undefined) {
|
||||
return <LoadingView />
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
title: "Playlists",
|
||||
headerLargeTitle: true,
|
||||
headerRight: () => (
|
||||
<Pressable
|
||||
onPress={openCreatePlaylist}
|
||||
accessibilityLabel="New playlist"
|
||||
hitSlop={4}
|
||||
>
|
||||
<SymbolView name="plus" size={24} tintColor={colors.foreground} />
|
||||
</Pressable>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
<ScrollView
|
||||
style={{ flex: 1, backgroundColor: colors.background }}
|
||||
contentContainerStyle={[
|
||||
styles.content,
|
||||
{ paddingBottom: tabContentBottomInset },
|
||||
]}
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
>
|
||||
<MediaGrid content={playlists} />
|
||||
</ScrollView>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
content: { padding: spacing.lg },
|
||||
})
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../home/queue"
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../home/recently-added"
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../home/recently-played"
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../home/settings"
|
||||
@@ -1,11 +1,12 @@
|
||||
import { useAuthActions } from "@convex-dev/auth/react"
|
||||
import { useQuery } from "convex/react"
|
||||
import { useRouter } from "expo-router"
|
||||
import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native"
|
||||
import { Ionicons } from "@expo/vector-icons"
|
||||
|
||||
import { tabContentBottomInset } from "@/components/player"
|
||||
import { useInvalidateAuthSession } from "@/contexts/convex-auth-session"
|
||||
import { useServerConfig } from "@/contexts/server-config"
|
||||
import { useAppNavigation } from "@/lib/app-navigation"
|
||||
import { signOutToSignIn } from "@/lib/session"
|
||||
import { api } from "@otunes/convex/_generated/api"
|
||||
import type { PlaylistSummary } from "@otunes/convex/types"
|
||||
@@ -14,18 +15,19 @@ import { radius, spacing, useThemeColors } from "@/lib/theme"
|
||||
|
||||
export default function MoreScreen() {
|
||||
const router = useRouter()
|
||||
const { push } = useAppNavigation()
|
||||
const colors = useThemeColors()
|
||||
const { signOut } = useAuthActions()
|
||||
const { invalidateSession } = useInvalidateAuthSession()
|
||||
const { clearServer } = useServerConfig()
|
||||
const user = useQuery(api.auth.currentUser)
|
||||
const sidebarPlaylists = useQuery(api.playlists.listSidebarPlaylists)
|
||||
|
||||
async function handleSignOut() {
|
||||
await signOutToSignIn(signOut, router)
|
||||
await signOutToSignIn(router, invalidateSession)
|
||||
}
|
||||
|
||||
async function handleChangeServer() {
|
||||
await signOut()
|
||||
await invalidateSession()
|
||||
await clearServer()
|
||||
router.replace("/server")
|
||||
}
|
||||
@@ -51,11 +53,11 @@ export default function MoreScreen() {
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<Pressable style={styles.row} onPress={() => router.push("/settings")}>
|
||||
<Pressable style={styles.row} onPress={() => push("/settings")}>
|
||||
<Ionicons name="settings-outline" size={20} color={colors.foreground} />
|
||||
<Text style={[styles.rowText, { color: colors.foreground }]}>Settings</Text>
|
||||
</Pressable>
|
||||
<Pressable style={styles.row} onPress={() => router.push("/queue")}>
|
||||
<Pressable style={styles.row} onPress={() => push("/queue")}>
|
||||
<Ionicons name="list-outline" size={20} color={colors.foreground} />
|
||||
<Text style={[styles.rowText, { color: colors.foreground }]}>Queue</Text>
|
||||
</Pressable>
|
||||
@@ -67,7 +69,7 @@ export default function MoreScreen() {
|
||||
<Pressable
|
||||
key={playlist.id}
|
||||
style={styles.row}
|
||||
onPress={() => router.push(`/playlist/${playlist.id}`)}
|
||||
onPress={() => push(`/playlist/${playlist.id}`)}
|
||||
>
|
||||
<Ionicons name="musical-notes" size={20} color={colors.foreground} />
|
||||
<Text style={[styles.rowText, { color: colors.foreground }]}>{playlist.title}</Text>
|
||||
@@ -81,7 +83,7 @@ export default function MoreScreen() {
|
||||
<Pressable
|
||||
key={playlist.id}
|
||||
style={styles.row}
|
||||
onPress={() => router.push(`/playlist/${playlist.id}`)}
|
||||
onPress={() => push(`/playlist/${playlist.id}`)}
|
||||
>
|
||||
<Ionicons name="musical-notes-outline" size={20} color={colors.foreground} />
|
||||
<Text style={[styles.rowText, { color: colors.foreground }]}>{playlist.title}</Text>
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import { Stack } from "expo-router"
|
||||
import { Pressable, Text } from "react-native"
|
||||
|
||||
import { useAddToPlaylist } from "@/contexts/add-to-playlist"
|
||||
import { useStackScreenOptions } from "@/lib/navigation"
|
||||
import { appleMusic } from "@/lib/theme"
|
||||
|
||||
function NewPlaylistButton() {
|
||||
const { openCreatePlaylist } = useAddToPlaylist()
|
||||
|
||||
return (
|
||||
<Pressable onPress={openCreatePlaylist} hitSlop={8}>
|
||||
<Text style={{ color: appleMusic.pink, fontSize: 17, fontWeight: "600" }}>
|
||||
New
|
||||
</Text>
|
||||
</Pressable>
|
||||
)
|
||||
}
|
||||
|
||||
export default function PlaylistsLayout() {
|
||||
return (
|
||||
<Stack
|
||||
screenOptions={useStackScreenOptions({
|
||||
title: "Playlists",
|
||||
headerRight: () => <NewPlaylistButton />,
|
||||
})}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
import { useQuery } from "convex/react"
|
||||
import { ScrollView, StyleSheet } from "react-native"
|
||||
|
||||
import { MediaGrid } from "@/components/media-cards"
|
||||
import { LoadingView } from "@/components/ui/primitives"
|
||||
import { tabContentBottomInset } from "@/components/player"
|
||||
import { api } from "@otunes/convex/_generated/api"
|
||||
import { spacing, useThemeColors } from "@/lib/theme"
|
||||
|
||||
export default function PlaylistsTabScreen() {
|
||||
const colors = useThemeColors()
|
||||
const playlists = useQuery(api.playlists.listAllPlaylists)
|
||||
|
||||
if (playlists === undefined) {
|
||||
return <LoadingView />
|
||||
}
|
||||
|
||||
return (
|
||||
<ScrollView
|
||||
style={{ flex: 1, backgroundColor: colors.background }}
|
||||
contentContainerStyle={[styles.content, { paddingBottom: tabContentBottomInset }]}
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
>
|
||||
<MediaGrid content={playlists} />
|
||||
</ScrollView>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
content: { padding: spacing.lg },
|
||||
})
|
||||
@@ -1,7 +1,21 @@
|
||||
import { Stack } from "expo-router"
|
||||
|
||||
import { useStackScreenOptions } from "@/lib/navigation"
|
||||
import { tabStackScreenTitles, useStackScreenOptions } from "@/lib/navigation"
|
||||
|
||||
export const unstable_settings = {
|
||||
initialRouteName: "index",
|
||||
}
|
||||
|
||||
export default function SearchLayout() {
|
||||
return <Stack screenOptions={useStackScreenOptions({ title: "Search" })} />
|
||||
const baseOptions = useStackScreenOptions({ title: "Search" })
|
||||
|
||||
return (
|
||||
<Stack
|
||||
initialRouteName="index"
|
||||
screenOptions={({ route }) => ({
|
||||
...baseOptions,
|
||||
title: tabStackScreenTitles[route.name] ?? baseOptions.title,
|
||||
})}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../home/album/[id]"
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../home/artist/[id]"
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../home/browse/albums"
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../home/browse/artists"
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../home/browse/songs"
|
||||
@@ -1,130 +1,29 @@
|
||||
import { useQuery } from "convex/react"
|
||||
import { Stack } from "expo-router"
|
||||
import { useMemo, useState } from "react"
|
||||
import { ScrollView, StyleSheet, Text, View } from "react-native"
|
||||
import { useCallback } from "react"
|
||||
|
||||
import { ContentCarousel } from "@/components/media-cards"
|
||||
import { tabContentBottomInset, SongRow } from "@/components/player"
|
||||
import { LoadingView } from "@/components/ui/primitives"
|
||||
import { usePlayback } from "@/contexts/playback"
|
||||
import { api } from "@otunes/convex/_generated/api"
|
||||
import type { BrowseSong } from "@otunes/convex/types"
|
||||
import { spacing, useThemeColors } from "@/lib/theme"
|
||||
|
||||
const SEARCH_DEBOUNCE_MS = 300
|
||||
import { SearchResults } from "@/components/search-results"
|
||||
import { useDebouncedSearch } from "@/hooks/use-debounced-search"
|
||||
|
||||
export default function SearchScreen() {
|
||||
const colors = useThemeColors()
|
||||
const { playFromSong } = usePlayback()
|
||||
const [query, setQuery] = useState("")
|
||||
const [searchQuery, setSearchQuery] = useState("")
|
||||
const [debounceId, setDebounceId] = useState<ReturnType<typeof setTimeout> | null>(null)
|
||||
const { searchQuery, onQueryChange, onSearchSubmit } = useDebouncedSearch()
|
||||
|
||||
const hasQuery = searchQuery.length > 0
|
||||
const results = useQuery(
|
||||
api.library.searchLibrary,
|
||||
hasQuery ? { query: searchQuery } : "skip"
|
||||
)
|
||||
const playlistResults = useQuery(
|
||||
api.playlists.searchPlaylists,
|
||||
hasQuery ? { query: searchQuery } : "skip"
|
||||
)
|
||||
|
||||
const isSearching = hasQuery && results === undefined
|
||||
|
||||
function handleQueryChange(value: string) {
|
||||
setQuery(value)
|
||||
if (debounceId) clearTimeout(debounceId)
|
||||
const id = setTimeout(() => setSearchQuery(value.trim()), SEARCH_DEBOUNCE_MS)
|
||||
setDebounceId(id)
|
||||
}
|
||||
|
||||
const hasLibraryResults = useMemo(
|
||||
() =>
|
||||
Boolean(
|
||||
results &&
|
||||
(results.topResults.length > 0 ||
|
||||
results.artists.length > 0 ||
|
||||
results.albums.length > 0 ||
|
||||
results.songs.length > 0)
|
||||
),
|
||||
[results]
|
||||
const handleChangeText = useCallback(
|
||||
(event: { nativeEvent: { text: string } }) => {
|
||||
onQueryChange(event.nativeEvent.text)
|
||||
},
|
||||
[onQueryChange]
|
||||
)
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack.SearchBar
|
||||
placeholder="Artists, Songs, Lyrics, and More"
|
||||
onChangeText={(event) => handleQueryChange(event.nativeEvent.text)}
|
||||
onSearchButtonPress={() => setSearchQuery(query.trim())}
|
||||
onChangeText={handleChangeText}
|
||||
onSearchButtonPress={onSearchSubmit}
|
||||
autoCapitalize="none"
|
||||
/>
|
||||
|
||||
{isSearching ? (
|
||||
<LoadingView />
|
||||
) : !hasQuery ? (
|
||||
<View style={styles.empty}>
|
||||
<Text style={[styles.emptyText, { color: colors.mutedForeground }]}>
|
||||
Find your favorite music
|
||||
</Text>
|
||||
</View>
|
||||
) : (
|
||||
<ScrollView
|
||||
style={{ flex: 1, backgroundColor: colors.background }}
|
||||
contentContainerStyle={{ paddingBottom: tabContentBottomInset }}
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
keyboardShouldPersistTaps="handled"
|
||||
>
|
||||
{!hasLibraryResults ? (
|
||||
<View style={styles.empty}>
|
||||
<Text style={[styles.emptyText, { color: colors.mutedForeground }]}>
|
||||
No results for "{searchQuery}"
|
||||
</Text>
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{results?.artists.length ? (
|
||||
<View style={styles.section}>
|
||||
<ContentCarousel title="Artists" content={results.artists} />
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{results?.albums.length ? (
|
||||
<View style={styles.section}>
|
||||
<ContentCarousel title="Albums" content={results.albums} />
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{results?.songs.length ? (
|
||||
<View style={styles.section}>
|
||||
{results.songs.map((song: BrowseSong) => (
|
||||
<SongRow
|
||||
key={song.id}
|
||||
song={song}
|
||||
onPress={() =>
|
||||
void playFromSong(
|
||||
song.id,
|
||||
results.songs.map((s: BrowseSong) => s.id)
|
||||
)
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{playlistResults && playlistResults.length > 0 ? (
|
||||
<View style={styles.section}>
|
||||
<ContentCarousel title="Playlists" content={playlistResults} />
|
||||
</View>
|
||||
) : null}
|
||||
</ScrollView>
|
||||
)}
|
||||
<SearchResults searchQuery={searchQuery} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
empty: { padding: spacing.xl, alignItems: "center" },
|
||||
emptyText: { fontSize: 16 },
|
||||
section: { paddingHorizontal: spacing.lg, paddingBottom: spacing.lg, gap: spacing.md },
|
||||
})
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../home/playlist/[id]"
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../home/playlist/favorites"
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../home/queue"
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../home/recently-added"
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../home/recently-played"
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../home/settings"
|
||||
@@ -1,70 +1,85 @@
|
||||
import { useConvexAuth } from "@convex-dev/auth/react"
|
||||
import { useConvexAuth as useLocalConvexAuth } from "@convex-dev/auth/react"
|
||||
import { useConvexAuth as useServerConvexAuth } from "convex/react"
|
||||
import { Redirect, Stack } from "expo-router"
|
||||
import { Platform } from "react-native"
|
||||
import { useEffect } from "react"
|
||||
|
||||
import { FloatingMiniPlayer } from "@/components/mini-player"
|
||||
import { ConvexAuthRecovery } from "@/components/convex-auth-recovery"
|
||||
import { LoadingView } from "@/components/ui/primitives"
|
||||
import { AddToPlaylistProvider } from "@/contexts/add-to-playlist"
|
||||
import { useInvalidateAuthSession } from "@/contexts/convex-auth-session"
|
||||
import { FavoritesProvider } from "@/contexts/favorites"
|
||||
import { PlaybackProvider } from "@/contexts/playback"
|
||||
import { useServerConfig } from "@/contexts/server-config"
|
||||
import { useStackScreenOptions } from "@/lib/navigation"
|
||||
|
||||
const AUTH_HANDSHAKE_TIMEOUT_MS = 15_000
|
||||
|
||||
export default function AppLayout() {
|
||||
const { config } = useServerConfig()
|
||||
const auth = useConvexAuth()
|
||||
const localAuth = useLocalConvexAuth()
|
||||
const serverAuth = useServerConvexAuth()
|
||||
const { invalidateSession } = useInvalidateAuthSession()
|
||||
const stackOptions = useStackScreenOptions()
|
||||
|
||||
useEffect(() => {
|
||||
if (!localAuth?.isAuthenticated || serverAuth?.isAuthenticated) {
|
||||
return
|
||||
}
|
||||
|
||||
const timer = setTimeout(() => {
|
||||
void invalidateSession()
|
||||
}, AUTH_HANDSHAKE_TIMEOUT_MS)
|
||||
|
||||
return () => clearTimeout(timer)
|
||||
}, [
|
||||
invalidateSession,
|
||||
localAuth?.isAuthenticated,
|
||||
serverAuth?.isAuthenticated,
|
||||
])
|
||||
|
||||
if (!config) {
|
||||
return <Redirect href="/server" />
|
||||
}
|
||||
|
||||
if (!auth) {
|
||||
if (!localAuth || localAuth.isLoading) {
|
||||
return <LoadingView />
|
||||
}
|
||||
|
||||
const { isLoading, isAuthenticated } = auth
|
||||
|
||||
if (isLoading) {
|
||||
return <LoadingView />
|
||||
}
|
||||
|
||||
if (!isAuthenticated) {
|
||||
if (!localAuth.isAuthenticated) {
|
||||
return <Redirect href="/signin" />
|
||||
}
|
||||
|
||||
if (!serverAuth || serverAuth.isLoading || serverAuth.isRefreshing) {
|
||||
return <LoadingView />
|
||||
}
|
||||
|
||||
if (!serverAuth.isAuthenticated) {
|
||||
return <LoadingView />
|
||||
}
|
||||
|
||||
return (
|
||||
<PlaybackProvider>
|
||||
<AddToPlaylistProvider>
|
||||
<FavoritesProvider>
|
||||
<Stack screenOptions={stackOptions}>
|
||||
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
||||
<Stack.Screen
|
||||
name="player"
|
||||
options={{
|
||||
headerShown: false,
|
||||
presentation: Platform.OS === "ios" ? "modal" : "fullScreenModal",
|
||||
animation: "slide_from_bottom",
|
||||
gestureEnabled: true,
|
||||
gestureDirection: "vertical",
|
||||
fullScreenGestureEnabled: true,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen name="album/[id]" options={{ title: "Album" }} />
|
||||
<Stack.Screen name="artist/[id]" options={{ title: "Artist" }} />
|
||||
<Stack.Screen name="playlist/[id]" options={{ title: "Playlist" }} />
|
||||
<Stack.Screen name="playlist/favorites" options={{ title: "Favorites" }} />
|
||||
<Stack.Screen name="library/albums" options={{ title: "Albums" }} />
|
||||
<Stack.Screen name="library/artists" options={{ title: "Artists" }} />
|
||||
<Stack.Screen name="library/songs" options={{ title: "Songs" }} />
|
||||
<Stack.Screen name="recently-played" options={{ title: "Recently Played" }} />
|
||||
<Stack.Screen name="recently-added" options={{ title: "Recently Added" }} />
|
||||
<Stack.Screen name="queue" options={{ title: "Queue" }} />
|
||||
<Stack.Screen name="settings" options={{ title: "Settings" }} />
|
||||
</Stack>
|
||||
<FloatingMiniPlayer />
|
||||
</FavoritesProvider>
|
||||
</AddToPlaylistProvider>
|
||||
</PlaybackProvider>
|
||||
<ConvexAuthRecovery onInvalidate={invalidateSession}>
|
||||
<PlaybackProvider>
|
||||
<AddToPlaylistProvider>
|
||||
<FavoritesProvider>
|
||||
<Stack screenOptions={stackOptions}>
|
||||
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
||||
<Stack.Screen
|
||||
name="player"
|
||||
options={{
|
||||
headerShown: false,
|
||||
presentation: Platform.OS === "ios" ? "modal" : "fullScreenModal",
|
||||
animation: "slide_from_bottom",
|
||||
gestureEnabled: true,
|
||||
gestureDirection: "vertical",
|
||||
fullScreenGestureEnabled: true,
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
</FavoritesProvider>
|
||||
</AddToPlaylistProvider>
|
||||
</PlaybackProvider>
|
||||
</ConvexAuthRecovery>
|
||||
)
|
||||
}
|
||||
@@ -20,11 +20,13 @@ import { useFavorites } from "@/contexts/favorites"
|
||||
import { usePlayback } from "@/contexts/playback"
|
||||
import { useServerConfig } from "@/contexts/server-config"
|
||||
import { formatDuration, formatRemainingDuration } from "@/lib/format"
|
||||
import { useAppNavigation } from "@/lib/app-navigation"
|
||||
import { albumCoverUrl } from "@/lib/urls"
|
||||
import { appleMusic, radius, spacing, usePlayerTheme } from "@/lib/theme"
|
||||
|
||||
export default function PlayerScreen() {
|
||||
const router = useRouter()
|
||||
const { push } = useAppNavigation()
|
||||
const insets = useSafeAreaInsets()
|
||||
const player = usePlayerTheme()
|
||||
const { config } = useServerConfig()
|
||||
@@ -76,10 +78,10 @@ export default function PlayerScreen() {
|
||||
await playShuffled([currentSong!.id])
|
||||
break
|
||||
case "go-artist":
|
||||
router.push(`/artist/${currentSong!.artist.id}`)
|
||||
push(`/artist/${currentSong!.artist.id}`)
|
||||
break
|
||||
case "go-album":
|
||||
router.push(`/album/${currentSong!.album.id}`)
|
||||
push(`/album/${currentSong!.album.id}`)
|
||||
break
|
||||
default:
|
||||
break
|
||||
@@ -226,7 +228,7 @@ export default function PlayerScreen() {
|
||||
/>
|
||||
</Pressable>
|
||||
<Pressable
|
||||
onPress={() => router.push("/queue")}
|
||||
onPress={() => push("/queue")}
|
||||
hitSlop={12}
|
||||
style={styles.footerButton}
|
||||
disabled={queueSongIds.length === 0}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useAuthActions } from "@convex-dev/auth/react"
|
||||
import { useAuthActions, useConvexAuth } from "@convex-dev/auth/react"
|
||||
import { Link, useRouter } from "expo-router"
|
||||
import { useQuery } from "convex/react"
|
||||
import { useState } from "react"
|
||||
import { useEffect, useState } from "react"
|
||||
import {
|
||||
KeyboardAvoidingView,
|
||||
Platform,
|
||||
@@ -50,6 +50,7 @@ const copy: Record<
|
||||
|
||||
export function AuthForm({ flow }: { flow: AuthFlow }) {
|
||||
const { signIn } = useAuthActions()
|
||||
const auth = useConvexAuth()
|
||||
const router = useRouter()
|
||||
const colors = useThemeColors()
|
||||
const { config } = useServerConfig()
|
||||
@@ -60,6 +61,12 @@ export function AuthForm({ flow }: { flow: AuthFlow }) {
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [submitting, setSubmitting] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
if (auth.isAuthenticated) {
|
||||
router.replace("/(app)/(tabs)/home")
|
||||
}
|
||||
}, [auth.isAuthenticated, router])
|
||||
|
||||
const text = copy[flow]
|
||||
const accountCreationDisabled = appSettings?.disableAccountCreation ?? false
|
||||
const signupsDisabled = flow === "signUp" && accountCreationDisabled
|
||||
@@ -80,7 +87,6 @@ export function AuthForm({ flow }: { flow: AuthFlow }) {
|
||||
|
||||
try {
|
||||
await signIn("password", formData)
|
||||
router.replace("/(app)/(tabs)/home")
|
||||
} catch {
|
||||
setError(
|
||||
flow === "signIn"
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
import { useConvexAuth as useLocalConvexAuth } from "@convex-dev/auth/react"
|
||||
import { useConvexAuth as useServerConvexAuth } from "convex/react"
|
||||
import {
|
||||
Component,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useRef,
|
||||
type ErrorInfo,
|
||||
type ReactNode,
|
||||
} from "react"
|
||||
|
||||
import { LoadingView } from "@/components/ui/primitives"
|
||||
import { shouldInvalidateAuthSession } from "@/lib/auth-errors"
|
||||
|
||||
type ConvexAuthRecoveryProps = {
|
||||
children: ReactNode
|
||||
onInvalidate: () => Promise<void>
|
||||
}
|
||||
|
||||
type ConvexAuthErrorBoundaryProps = {
|
||||
children: ReactNode
|
||||
sessionEstablished: boolean
|
||||
onAuthError: () => void
|
||||
}
|
||||
|
||||
type ConvexAuthErrorBoundaryState = {
|
||||
error: Error | null
|
||||
}
|
||||
|
||||
class ConvexAuthErrorBoundary extends Component<
|
||||
ConvexAuthErrorBoundaryProps,
|
||||
ConvexAuthErrorBoundaryState
|
||||
> {
|
||||
state: ConvexAuthErrorBoundaryState = { error: null }
|
||||
|
||||
static getDerivedStateFromError(error: Error): ConvexAuthErrorBoundaryState {
|
||||
return { error }
|
||||
}
|
||||
|
||||
componentDidCatch(error: Error, _errorInfo: ErrorInfo) {
|
||||
if (shouldInvalidateAuthSession(error, this.props.sessionEstablished)) {
|
||||
this.props.onAuthError()
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { error } = this.state
|
||||
if (error) {
|
||||
if (shouldInvalidateAuthSession(error, this.props.sessionEstablished)) {
|
||||
return <LoadingView />
|
||||
}
|
||||
throw error
|
||||
}
|
||||
|
||||
return this.props.children
|
||||
}
|
||||
}
|
||||
|
||||
export function ConvexAuthRecovery({ children, onInvalidate }: ConvexAuthRecoveryProps) {
|
||||
const localAuth = useLocalConvexAuth()
|
||||
const serverAuth = useServerConvexAuth()
|
||||
const hadServerAuthRef = useRef(false)
|
||||
const invalidatingRef = useRef(false)
|
||||
|
||||
if (serverAuth?.isAuthenticated) {
|
||||
hadServerAuthRef.current = true
|
||||
}
|
||||
|
||||
const invalidateOnce = useCallback(async () => {
|
||||
if (invalidatingRef.current) {
|
||||
return
|
||||
}
|
||||
|
||||
invalidatingRef.current = true
|
||||
try {
|
||||
await onInvalidate()
|
||||
} catch {
|
||||
invalidatingRef.current = false
|
||||
}
|
||||
}, [onInvalidate])
|
||||
|
||||
useEffect(() => {
|
||||
if (!hadServerAuthRef.current) {
|
||||
return
|
||||
}
|
||||
if (!localAuth?.isAuthenticated) {
|
||||
return
|
||||
}
|
||||
if (!serverAuth || serverAuth.isLoading || serverAuth.isRefreshing) {
|
||||
return
|
||||
}
|
||||
if (serverAuth.isAuthenticated) {
|
||||
return
|
||||
}
|
||||
|
||||
void invalidateOnce()
|
||||
}, [invalidateOnce, localAuth, serverAuth])
|
||||
|
||||
const sessionEstablished = Boolean(
|
||||
serverAuth &&
|
||||
!serverAuth.isLoading &&
|
||||
!serverAuth.isRefreshing &&
|
||||
serverAuth.isAuthenticated
|
||||
)
|
||||
|
||||
return (
|
||||
<ConvexAuthErrorBoundary
|
||||
sessionEstablished={sessionEstablished}
|
||||
onAuthError={() => void invalidateOnce()}
|
||||
>
|
||||
{children}
|
||||
</ConvexAuthErrorBoundary>
|
||||
)
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Ionicons } from "@expo/vector-icons"
|
||||
import { Image } from "expo-image"
|
||||
import { useRouter } from "expo-router"
|
||||
import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native"
|
||||
|
||||
import { useServerConfig } from "@/contexts/server-config"
|
||||
import { useAppNavigation } from "@/lib/app-navigation"
|
||||
import type { BrowseAlbum, BrowseArtist, PlaylistSummary } from "@otunes/convex/types"
|
||||
import { albumCoverUrl, artistCoverUrl, playlistCoverUrl } from "@/lib/urls"
|
||||
import { carouselCardWidth, radius, spacing, useThemeColors, useTwoColumnCardWidth } from "@/lib/theme"
|
||||
@@ -40,7 +40,7 @@ export function AlbumCard({
|
||||
album: BrowseAlbum
|
||||
width?: number
|
||||
}) {
|
||||
const router = useRouter()
|
||||
const { push } = useAppNavigation()
|
||||
const { config } = useServerConfig()
|
||||
const colors = useThemeColors()
|
||||
if (!config) return null
|
||||
@@ -48,7 +48,7 @@ export function AlbumCard({
|
||||
return (
|
||||
<Pressable
|
||||
style={[styles.card, { width }]}
|
||||
onPress={() => router.push(`/album/${album.id}`)}
|
||||
onPress={() => push(`/album/${album.id}`)}
|
||||
>
|
||||
<CoverImage uri={albumCoverUrl(config.serverUrl, album.id)} size={width} />
|
||||
<Text style={[styles.title, { color: colors.foreground }]} numberOfLines={2}>
|
||||
@@ -68,7 +68,7 @@ export function ArtistCard({
|
||||
artist: BrowseArtist
|
||||
width?: number
|
||||
}) {
|
||||
const router = useRouter()
|
||||
const { push } = useAppNavigation()
|
||||
const { config } = useServerConfig()
|
||||
const colors = useThemeColors()
|
||||
if (!config) return null
|
||||
@@ -76,7 +76,7 @@ export function ArtistCard({
|
||||
return (
|
||||
<Pressable
|
||||
style={[styles.card, { width }]}
|
||||
onPress={() => router.push(`/artist/${artist.id}`)}
|
||||
onPress={() => push(`/artist/${artist.id}`)}
|
||||
>
|
||||
<CoverImage uri={artistCoverUrl(config.serverUrl, artist.id)} size={width} rounded />
|
||||
<Text style={[styles.title, { color: colors.foreground }]} numberOfLines={2}>
|
||||
@@ -93,7 +93,7 @@ export function PlaylistCard({
|
||||
playlist: PlaylistSummary
|
||||
width?: number
|
||||
}) {
|
||||
const router = useRouter()
|
||||
const { push } = useAppNavigation()
|
||||
const { config } = useServerConfig()
|
||||
const colors = useThemeColors()
|
||||
if (!config) return null
|
||||
@@ -101,7 +101,7 @@ export function PlaylistCard({
|
||||
return (
|
||||
<Pressable
|
||||
style={[styles.card, { width }]}
|
||||
onPress={() => router.push(`/playlist/${playlist.id}`)}
|
||||
onPress={() => push(`/playlist/${playlist.id}`)}
|
||||
>
|
||||
<CoverImage uri={playlistCoverUrl(config.serverUrl, playlist.id)} size={width} />
|
||||
<Text style={[styles.title, { color: colors.foreground }]} numberOfLines={2}>
|
||||
@@ -143,14 +143,14 @@ export function ContentCarousel({
|
||||
href?: string
|
||||
content: MediaItem[]
|
||||
}) {
|
||||
const router = useRouter()
|
||||
const { push } = useAppNavigation()
|
||||
const colors = useThemeColors()
|
||||
|
||||
return (
|
||||
<View style={styles.section}>
|
||||
<Pressable
|
||||
disabled={!href}
|
||||
onPress={() => href && router.push(href as never)}
|
||||
onPress={() => href && push(href)}
|
||||
style={styles.sectionHeader}
|
||||
>
|
||||
<Text style={[styles.sectionTitle, { color: colors.foreground }]}>{title}</Text>
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import { Ionicons } from "@expo/vector-icons"
|
||||
import { BlurView } from "expo-blur"
|
||||
import { Image } from "expo-image"
|
||||
import { NativeTabs } from "expo-router/unstable-native-tabs"
|
||||
import { useRouter, useSegments } from "expo-router"
|
||||
import { useRouter } from "expo-router"
|
||||
import { Platform, Pressable, StyleSheet, Text, View } from "react-native"
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context"
|
||||
|
||||
import { usePlayback } from "@/contexts/playback"
|
||||
import { useServerConfig } from "@/contexts/server-config"
|
||||
@@ -12,12 +10,12 @@ import { albumCoverUrl } from "@/lib/urls"
|
||||
import { miniPlayerHeight, tabBarHeight, useBlurTint, useMiniPlayerBackground, useThemeColors } from "@/lib/theme"
|
||||
|
||||
function MiniPlayerContent({
|
||||
compact,
|
||||
placement,
|
||||
variant = "bar",
|
||||
onOpenPlayer,
|
||||
}: {
|
||||
compact?: boolean
|
||||
variant?: "bar" | "accessory"
|
||||
placement: "regular" | "inline"
|
||||
variant: "bar" | "accessory"
|
||||
onOpenPlayer: () => void
|
||||
}) {
|
||||
const colors = useThemeColors()
|
||||
@@ -33,6 +31,7 @@ function MiniPlayerContent({
|
||||
return null
|
||||
}
|
||||
|
||||
const compact = placement === "inline"
|
||||
const isAccessory = variant === "accessory"
|
||||
const artworkStyle = isAccessory ? styles.accessoryArtwork : styles.artwork
|
||||
const rowStyle = compact ? styles.inlineContent : isAccessory ? styles.accessoryContent : styles.content
|
||||
@@ -133,18 +132,8 @@ function MiniPlayerContent({
|
||||
|
||||
function MiniPlayerChrome({ children }: { children: React.ReactNode }) {
|
||||
const colors = useThemeColors()
|
||||
const blurTint = useBlurTint()
|
||||
const backgroundColor = useMiniPlayerBackground()
|
||||
|
||||
if (Platform.OS === "ios") {
|
||||
return (
|
||||
<BlurView intensity={80} tint={blurTint} style={styles.blur}>
|
||||
<View style={[styles.topBorder, { backgroundColor: colors.border }]} />
|
||||
{children}
|
||||
</BlurView>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={[styles.androidBar, { backgroundColor }]}>
|
||||
<View style={[styles.topBorder, { backgroundColor: colors.border }]} />
|
||||
@@ -165,7 +154,7 @@ export function TabBottomAccessory() {
|
||||
const content = (
|
||||
<View style={styles.accessoryContainer}>
|
||||
<MiniPlayerContent
|
||||
compact={placement === "inline"}
|
||||
placement={placement}
|
||||
variant="accessory"
|
||||
onOpenPlayer={() => router.push("/player")}
|
||||
/>
|
||||
@@ -178,43 +167,43 @@ export function TabBottomAccessory() {
|
||||
|
||||
return content
|
||||
}
|
||||
|
||||
function useFloatingMiniPlayerLayout() {
|
||||
const segments = useSegments() as string[]
|
||||
const insets = useSafeAreaInsets()
|
||||
|
||||
const onPlayerModal = segments.includes("player")
|
||||
const onAuthFlow =
|
||||
segments.includes("signin") ||
|
||||
segments.includes("signup") ||
|
||||
segments.includes("server")
|
||||
const onTabs = segments.includes("(tabs)")
|
||||
|
||||
const bottom = insets.bottom + (onTabs ? 0 : 0)
|
||||
|
||||
return {
|
||||
bottom,
|
||||
hidden: onPlayerModal || onAuthFlow || onTabs,
|
||||
}
|
||||
}
|
||||
|
||||
export function FloatingMiniPlayer() {
|
||||
const router = useRouter()
|
||||
const { bottom, hidden } = useFloatingMiniPlayerLayout()
|
||||
const { currentSong, queueSongIds } = usePlayback()
|
||||
|
||||
if (hidden || !currentSong || queueSongIds.length === 0) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<View pointerEvents="box-none" style={[styles.floatingContainer, { bottom }]}>
|
||||
<MiniPlayerChrome>
|
||||
<MiniPlayerContent onOpenPlayer={() => router.push("/player")} />
|
||||
</MiniPlayerChrome>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
//
|
||||
// function useFloatingMiniPlayerLayout() {
|
||||
// const segments = useSegments() as string[]
|
||||
// const insets = useSafeAreaInsets()
|
||||
//
|
||||
// const onPlayerModal = segments.includes("player")
|
||||
// const onAuthFlow =
|
||||
// segments.includes("signin") ||
|
||||
// segments.includes("signup") ||
|
||||
// segments.includes("server")
|
||||
// const onTabs = segments.includes("(tabs)")
|
||||
//
|
||||
// const bottom = insets.bottom + (onTabs ? 0 : 0)
|
||||
//
|
||||
// return {
|
||||
// bottom,
|
||||
// hidden: onPlayerModal || onAuthFlow || onTabs,
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// export function FloatingMiniPlayer() {
|
||||
// const router = useRouter()
|
||||
// const { bottom, hidden } = useFloatingMiniPlayerLayout()
|
||||
// const { currentSong, queueSongIds } = usePlayback()
|
||||
//
|
||||
// if (hidden || !currentSong || queueSongIds.length === 0) {
|
||||
// return null
|
||||
// }
|
||||
//
|
||||
// return (
|
||||
// <View pointerEvents="box-none" style={[styles.floatingContainer, { bottom }]}>
|
||||
// <MiniPlayerChrome>
|
||||
// <MiniPlayerContent onOpenPlayer={() => router.push("/player")} />
|
||||
// </MiniPlayerChrome>
|
||||
// </View>
|
||||
// )
|
||||
// }
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
floatingContainer: {
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
import { useQuery } from "convex/react"
|
||||
import { memo, useMemo } from "react"
|
||||
import { ScrollView, StyleSheet, Text, View } from "react-native"
|
||||
|
||||
import { ContentCarousel } from "@/components/media-cards"
|
||||
import { tabContentBottomInset, SongRow } from "@/components/player"
|
||||
import { LoadingView } from "@/components/ui/primitives"
|
||||
import { usePlayback } from "@/contexts/playback"
|
||||
import { api } from "@otunes/convex/_generated/api"
|
||||
import type { BrowseSong } from "@otunes/convex/types"
|
||||
import { spacing, useThemeColors } from "@/lib/theme"
|
||||
|
||||
function SearchResultsBody({ searchQuery }: { searchQuery: string }) {
|
||||
const colors = useThemeColors()
|
||||
const { playFromSong } = usePlayback()
|
||||
const hasQuery = searchQuery.length > 0
|
||||
|
||||
const results = useQuery(
|
||||
api.library.searchLibrary,
|
||||
hasQuery ? { query: searchQuery } : "skip"
|
||||
)
|
||||
const playlistResults = useQuery(
|
||||
api.playlists.searchPlaylists,
|
||||
hasQuery ? { query: searchQuery } : "skip"
|
||||
)
|
||||
|
||||
const isSearching = hasQuery && results === undefined
|
||||
|
||||
const hasLibraryResults = useMemo(
|
||||
() =>
|
||||
Boolean(
|
||||
results &&
|
||||
(results.topResults.length > 0 ||
|
||||
results.artists.length > 0 ||
|
||||
results.albums.length > 0 ||
|
||||
results.songs.length > 0)
|
||||
),
|
||||
[results]
|
||||
)
|
||||
|
||||
if (isSearching) {
|
||||
return <LoadingView />
|
||||
}
|
||||
|
||||
if (!hasQuery) {
|
||||
return (
|
||||
<View style={styles.empty}>
|
||||
<Text style={[styles.emptyText, { color: colors.mutedForeground }]}>
|
||||
Find your favorite music
|
||||
</Text>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<ScrollView
|
||||
style={{ flex: 1, backgroundColor: colors.background }}
|
||||
contentContainerStyle={{ paddingBottom: tabContentBottomInset }}
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
keyboardShouldPersistTaps="handled"
|
||||
>
|
||||
{!hasLibraryResults ? (
|
||||
<View style={styles.empty}>
|
||||
<Text style={[styles.emptyText, { color: colors.mutedForeground }]}>
|
||||
No results for "{searchQuery}"
|
||||
</Text>
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{results?.artists.length ? (
|
||||
<View style={styles.section}>
|
||||
<ContentCarousel title="Artists" content={results.artists} />
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{results?.albums.length ? (
|
||||
<View style={styles.section}>
|
||||
<ContentCarousel title="Albums" content={results.albums} />
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{results?.songs.length ? (
|
||||
<View style={styles.section}>
|
||||
{results.songs.map((song: BrowseSong) => (
|
||||
<SongRow
|
||||
key={song.id}
|
||||
song={song}
|
||||
onPress={() =>
|
||||
void playFromSong(
|
||||
song.id,
|
||||
results.songs.map((s: BrowseSong) => s.id)
|
||||
)
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{playlistResults && playlistResults.length > 0 ? (
|
||||
<View style={styles.section}>
|
||||
<ContentCarousel title="Playlists" content={playlistResults} />
|
||||
</View>
|
||||
) : null}
|
||||
</ScrollView>
|
||||
)
|
||||
}
|
||||
|
||||
export const SearchResults = memo(SearchResultsBody)
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
empty: { padding: spacing.xl, alignItems: "center" },
|
||||
emptyText: { fontSize: 16 },
|
||||
section: { paddingHorizontal: spacing.lg, paddingBottom: spacing.lg, gap: spacing.md },
|
||||
})
|
||||
@@ -1,5 +1,4 @@
|
||||
import { useConvex, useMutation, useQuery } from "convex/react"
|
||||
import { useRouter } from "expo-router"
|
||||
import {
|
||||
createContext,
|
||||
useCallback,
|
||||
@@ -15,6 +14,7 @@ import { api } from "@otunes/convex/_generated/api"
|
||||
import type { OwnedPlaylistForAdd } from "@otunes/convex/types"
|
||||
import type { Id } from "@otunes/convex/_generated/dataModel"
|
||||
import { showError, showSuccess } from "@/lib/toast"
|
||||
import { useAppNavigation } from "@/lib/app-navigation"
|
||||
import { useThemeColors } from "@/lib/theme"
|
||||
|
||||
type AddToPlaylistContextValue = {
|
||||
@@ -37,7 +37,7 @@ export function useAddToPlaylist() {
|
||||
|
||||
export function AddToPlaylistProvider({ children }: { children: ReactNode }) {
|
||||
const convex = useConvex()
|
||||
const router = useRouter()
|
||||
const { push } = useAppNavigation()
|
||||
const colors = useThemeColors()
|
||||
const ownedPlaylists = useQuery(api.playlists.listOwnedPlaylists)
|
||||
const addSongs = useMutation(api.playlists.addSongsToPlaylist)
|
||||
@@ -126,13 +126,13 @@ export function AddToPlaylistProvider({ children }: { children: ReactNode }) {
|
||||
showSuccess("Playlist created")
|
||||
setCreateOpen(false)
|
||||
setOpen(false)
|
||||
router.push(`/playlist/${playlistId}`)
|
||||
push(`/playlist/${playlistId}`)
|
||||
} catch (error) {
|
||||
showError(error instanceof Error ? error.message : "Failed to create playlist")
|
||||
} finally {
|
||||
setSubmitting(false)
|
||||
}
|
||||
}, [newPlaylistName, createPlaylist, pendingSongIds, addSongs, router])
|
||||
}, [newPlaylistName, createPlaylist, pendingSongIds, addSongs, push])
|
||||
|
||||
const value = useMemo(
|
||||
() => ({
|
||||
|
||||
@@ -1,29 +1,42 @@
|
||||
import { ConvexAuthProvider } from "@convex-dev/auth/react"
|
||||
import { ConvexReactClient } from "convex/react"
|
||||
import { useMemo, type ReactNode } from "react"
|
||||
import { useCallback, useMemo, useState, type ReactNode } from "react"
|
||||
|
||||
import { ConvexAuthSessionProvider } from "@/contexts/convex-auth-session"
|
||||
import { useServerConfig } from "@/contexts/server-config"
|
||||
import { secureStorage } from "@/lib/auth-storage"
|
||||
import { clearStoredAuthTokens, secureStorage } from "@/lib/auth-storage"
|
||||
|
||||
export function ConvexAppProvider({ children }: { children: ReactNode }) {
|
||||
const { config } = useServerConfig()
|
||||
const [authEpoch, setAuthEpoch] = useState(0)
|
||||
|
||||
const client = useMemo(() => {
|
||||
if (!config) return null
|
||||
return new ConvexReactClient(config.convexUrl)
|
||||
}, [config?.convexUrl])
|
||||
}, [config?.convexUrl, authEpoch])
|
||||
|
||||
const invalidateSession = useCallback(async () => {
|
||||
if (!config) {
|
||||
return
|
||||
}
|
||||
await clearStoredAuthTokens(config.convexUrl)
|
||||
setAuthEpoch((epoch) => epoch + 1)
|
||||
}, [config])
|
||||
|
||||
if (!client || !config) {
|
||||
return <>{children}</>
|
||||
}
|
||||
|
||||
return (
|
||||
<ConvexAuthProvider
|
||||
client={client}
|
||||
storage={secureStorage}
|
||||
storageNamespace={config.convexUrl}
|
||||
>
|
||||
{children}
|
||||
</ConvexAuthProvider>
|
||||
<ConvexAuthSessionProvider invalidateSession={invalidateSession}>
|
||||
<ConvexAuthProvider
|
||||
key={authEpoch}
|
||||
client={client}
|
||||
storage={secureStorage}
|
||||
storageNamespace={config.convexUrl}
|
||||
>
|
||||
{children}
|
||||
</ConvexAuthProvider>
|
||||
</ConvexAuthSessionProvider>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { createContext, useContext, type ReactNode } from "react"
|
||||
|
||||
type ConvexAuthSessionContextValue = {
|
||||
invalidateSession: () => Promise<void>
|
||||
}
|
||||
|
||||
const ConvexAuthSessionContext = createContext<ConvexAuthSessionContextValue | null>(
|
||||
null
|
||||
)
|
||||
|
||||
export function ConvexAuthSessionProvider({
|
||||
children,
|
||||
invalidateSession,
|
||||
}: {
|
||||
children: ReactNode
|
||||
invalidateSession: () => Promise<void>
|
||||
}) {
|
||||
return (
|
||||
<ConvexAuthSessionContext.Provider value={{ invalidateSession }}>
|
||||
{children}
|
||||
</ConvexAuthSessionContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
export function useInvalidateAuthSession() {
|
||||
const context = useContext(ConvexAuthSessionContext)
|
||||
if (!context) {
|
||||
throw new Error("useInvalidateAuthSession must be used within ConvexAppProvider")
|
||||
}
|
||||
return context
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import { useCallback, useEffect, useRef, useState } from "react"
|
||||
|
||||
const DEFAULT_DEBOUNCE_MS = 300
|
||||
|
||||
export function useDebouncedSearch(debounceMs = DEFAULT_DEBOUNCE_MS) {
|
||||
const queryRef = useRef("")
|
||||
const debounceRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||
const [searchQuery, setSearchQuery] = useState("")
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (debounceRef.current) {
|
||||
clearTimeout(debounceRef.current)
|
||||
}
|
||||
}
|
||||
}, [])
|
||||
|
||||
const commitSearch = useCallback((value: string) => {
|
||||
setSearchQuery(value.trim())
|
||||
}, [])
|
||||
|
||||
const onQueryChange = useCallback(
|
||||
(value: string) => {
|
||||
queryRef.current = value
|
||||
if (debounceRef.current) {
|
||||
clearTimeout(debounceRef.current)
|
||||
}
|
||||
debounceRef.current = setTimeout(() => {
|
||||
commitSearch(value)
|
||||
}, debounceMs)
|
||||
},
|
||||
[commitSearch, debounceMs]
|
||||
)
|
||||
|
||||
const onSearchSubmit = useCallback(() => {
|
||||
if (debounceRef.current) {
|
||||
clearTimeout(debounceRef.current)
|
||||
}
|
||||
commitSearch(queryRef.current)
|
||||
}, [commitSearch])
|
||||
|
||||
return { searchQuery, onQueryChange, onSearchSubmit }
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { useRouter, useSegments, type Href } from "expo-router"
|
||||
|
||||
export const APP_TABS = ["home", "library", "search"] as const
|
||||
export type AppTab = (typeof APP_TABS)[number]
|
||||
|
||||
const TAB_SET = new Set<string>(APP_TABS)
|
||||
|
||||
export function getActiveTab(segments: string[]): AppTab {
|
||||
for (const segment of segments) {
|
||||
if (TAB_SET.has(segment)) {
|
||||
return segment as AppTab
|
||||
}
|
||||
}
|
||||
|
||||
return "home"
|
||||
}
|
||||
|
||||
export function tabPath(tab: AppTab, path: string): Href {
|
||||
const normalized = path.startsWith("/") ? path : `/${path}`
|
||||
return `/(app)/(tabs)/${tab}${normalized}` as Href
|
||||
}
|
||||
|
||||
export function useAppNavigation() {
|
||||
const router = useRouter()
|
||||
const segments = useSegments()
|
||||
const tab = getActiveTab(segments)
|
||||
|
||||
return {
|
||||
tab,
|
||||
href: (path: string) => tabPath(tab, path),
|
||||
push: (path: string) => router.push(tabPath(tab, path)),
|
||||
replace: (path: string) => router.replace(tabPath(tab, path)),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import { ConvexError, type Value } from "convex/values"
|
||||
|
||||
const AUTH_ERROR_MESSAGES = new Set([
|
||||
"Not authenticated",
|
||||
"User not logged in",
|
||||
])
|
||||
|
||||
function matchesAuthMessage(message: string): boolean {
|
||||
if (AUTH_ERROR_MESSAGES.has(message)) {
|
||||
return true
|
||||
}
|
||||
|
||||
const normalized = message.toLowerCase()
|
||||
return (
|
||||
normalized.includes("not authenticated") ||
|
||||
normalized.includes("unauthenticated") ||
|
||||
normalized.includes("invalid session") ||
|
||||
normalized.includes("invalid token") ||
|
||||
normalized.includes("auth error")
|
||||
)
|
||||
}
|
||||
|
||||
function convexErrorData(error: ConvexError<Value>): string | null {
|
||||
if (typeof error.data === "string") {
|
||||
return error.data
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export function isConvexTransportAuthFailure(error: unknown): boolean {
|
||||
if (!(error instanceof Error)) {
|
||||
return false
|
||||
}
|
||||
|
||||
return (
|
||||
error.message.includes("[CONVEX") && error.message.includes("Server Error")
|
||||
)
|
||||
}
|
||||
|
||||
export function isConvexAuthError(error: unknown): boolean {
|
||||
if (error instanceof ConvexError) {
|
||||
const data = convexErrorData(error)
|
||||
if (data && matchesAuthMessage(data)) {
|
||||
return true
|
||||
}
|
||||
if (matchesAuthMessage(error.message)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return isConvexTransportAuthFailure(error)
|
||||
}
|
||||
|
||||
export function shouldInvalidateAuthSession(
|
||||
error: unknown,
|
||||
sessionEstablished: boolean
|
||||
): boolean {
|
||||
if (!sessionEstablished) {
|
||||
return false
|
||||
}
|
||||
|
||||
return isConvexAuthError(error)
|
||||
}
|
||||
@@ -1,6 +1,13 @@
|
||||
import * as SecureStore from "expo-secure-store"
|
||||
import type { TokenStorage } from "@convex-dev/auth/react"
|
||||
|
||||
const AUTH_STORAGE_KEYS = [
|
||||
"__convexAuthOAuthVerifier",
|
||||
"__convexAuthJWT",
|
||||
"__convexAuthRefreshToken",
|
||||
"__convexAuthServerStateFetchTime",
|
||||
] as const
|
||||
|
||||
const secureStoreOptions: SecureStore.SecureStoreOptions = {
|
||||
keychainAccessible: SecureStore.AFTER_FIRST_UNLOCK,
|
||||
}
|
||||
@@ -25,6 +32,19 @@ export async function secureRemoveItem(key: string): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
export function authStorageKey(key: string, storageNamespace: string): string {
|
||||
const escapedNamespace = storageNamespace.replace(/[^a-zA-Z0-9]/g, "")
|
||||
return `${key}_${escapedNamespace}`
|
||||
}
|
||||
|
||||
export async function clearStoredAuthTokens(storageNamespace: string): Promise<void> {
|
||||
await Promise.all(
|
||||
AUTH_STORAGE_KEYS.map((key) =>
|
||||
secureRemoveItem(authStorageKey(key, storageNamespace))
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
export const secureStorage: TokenStorage = {
|
||||
getItem(key) {
|
||||
return secureGetItem(key)
|
||||
|
||||
@@ -1,21 +1,29 @@
|
||||
import { useColorScheme } from "react-native"
|
||||
|
||||
import { colors } from "@/lib/theme"
|
||||
import type { ScreenProps as BaseScreenProps } from "expo-router/build/useScreens"
|
||||
import type {
|
||||
NativeStackNavigationEventMap,
|
||||
NativeStackNavigationOptions,
|
||||
} from "expo-router/build/react-navigation/native-stack"
|
||||
import type { ParamListBase, StackNavigationState } from "expo-router/build/react-navigation/native"
|
||||
|
||||
type StackScreenOptions = {
|
||||
title?: string
|
||||
headerLargeTitle?: boolean
|
||||
headerShadowVisible?: boolean
|
||||
headerStyle?: { backgroundColor?: string }
|
||||
headerTintColor?: string
|
||||
headerLargeTitleStyle?: { color?: string }
|
||||
headerBackButtonDisplayMode?: "minimal" | "default" | "generic"
|
||||
contentStyle?: { backgroundColor?: string }
|
||||
headerShown?: boolean
|
||||
headerRight?: () => React.ReactNode
|
||||
presentation?: "card" | "modal" | "transparentModal" | "containedModal" | "fullScreenModal"
|
||||
animation?: "default" | "fade" | "fade_from_bottom" | "flip" | "simple_push" | "slide_from_bottom" | "slide_from_right" | "slide_from_left" | "none"
|
||||
gestureEnabled?: boolean
|
||||
type StackBaseScreenProps = BaseScreenProps<
|
||||
NativeStackNavigationOptions,
|
||||
StackNavigationState<ParamListBase>,
|
||||
NativeStackNavigationEventMap
|
||||
>
|
||||
|
||||
type StackScreenOptions = StackBaseScreenProps["options"]
|
||||
|
||||
export const tabStackScreenTitles: Record<string, string> = {
|
||||
"browse/albums": "Albums",
|
||||
"browse/artists": "Artists",
|
||||
"browse/songs": "Songs",
|
||||
"recently-played": "Recently Played",
|
||||
"recently-added": "Recently Added",
|
||||
playlists: "Playlists",
|
||||
settings: "Settings",
|
||||
}
|
||||
|
||||
export function useStackScreenOptions(
|
||||
@@ -26,12 +34,10 @@ export function useStackScreenOptions(
|
||||
|
||||
return {
|
||||
headerLargeTitle: true,
|
||||
headerShadowVisible: false,
|
||||
headerStyle: { backgroundColor: theme.background },
|
||||
headerTransparent: true,
|
||||
headerTintColor: theme.foreground,
|
||||
headerLargeTitleStyle: { color: theme.foreground },
|
||||
headerBackButtonDisplayMode: "minimal",
|
||||
contentStyle: { backgroundColor: theme.background },
|
||||
...overrides,
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,9 @@ import type { useRouter } from "expo-router"
|
||||
type AppRouter = ReturnType<typeof useRouter>
|
||||
|
||||
export async function signOutToSignIn(
|
||||
signOut: () => Promise<void>,
|
||||
router: Pick<AppRouter, "replace">
|
||||
router: Pick<AppRouter, "replace">,
|
||||
invalidateSession: () => Promise<void>
|
||||
) {
|
||||
await signOut()
|
||||
await invalidateSession()
|
||||
router.replace("/signin")
|
||||
}
|
||||
Reference in new issue
Block a user