Files
otunes/apps/mobile/components/profile-header-button.tsx
joshuafhigginsandClaude Opus 5.5 Verified 4da45b9707 fix(convex): move playback state and avatars off the users document
Playback queue, history and progress move into playbackStates and
playbackProgress tables, so progress saves no longer rerun user queries.
Avatars move to Convex file storage behind a web proxy route. The server
caps queues at 5,000 songs, and the client stops retrying rejected syncs.
migrations:migrateUsers moves existing data and runs on Docker boot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 14:15:27 -05:00

76 lines
1.9 KiB
TypeScript

import { useTabletLayout } from "@/hooks/use-tablet-layout"
import { useOpenSettings } from "@/hooks/use-open-settings"
import { Image } from "expo-image"
import { Pressable, StyleSheet, Text, View } from "react-native"
import { useCachedQuery } from "@/hooks/use-cached-query"
import { useProfileImageUrl } from "@/hooks/use-profile-image-url"
import { initialsFromName } from "@/lib/format"
import { radius, useThemeColors } from "@/lib/theme"
import { api } from "@otunes/convex/_generated/api"
export function ProfileHeaderButton() {
const tabletLayout = useTabletLayout()
const openSettings = useOpenSettings()
const colors = useThemeColors()
const user = useCachedQuery(api.auth.currentUser)
const imageUrl = useProfileImageUrl(user?.image)
if (tabletLayout) return null
return (
<Pressable
accessibilityLabel="Open profile"
accessibilityRole="button"
hitSlop={8}
onPress={openSettings}
style={({ pressed }) => [styles.button, { opacity: pressed ? 0.75 : 1 }]}
>
<View
style={[
styles.avatar,
{
backgroundColor: colors.muted,
borderColor: colors.border,
},
]}
>
{imageUrl ? (
<Image
source={{ uri: imageUrl }}
style={styles.image}
contentFit="cover"
/>
) : (
<Text style={[styles.initials, { color: colors.foreground }]}>
{initialsFromName(user?.name ?? "Me")}
</Text>
)}
</View>
</Pressable>
)
}
const styles = StyleSheet.create({
button: {
marginRight: 4,
},
avatar: {
width: 42,
height: 42,
borderRadius: radius.full,
borderWidth: 1,
alignItems: "center",
justifyContent: "center",
overflow: "hidden",
},
image: {
width: "100%",
height: "100%",
},
initials: {
fontSize: 14,
fontWeight: "700",
},
})