feat(mobile): trending screen

- Updated imports for EntryDetailScreen and FeedScreen to reflect new file structure.
- Introduced OnboardingScreen and PlayerScreen components to improve user onboarding and media playback experience.
- Added PhUsersBold icon component for enhanced UI consistency.
- Adjusted animation timing in ItemPressableModule for better touch feedback.
- Updated sitemap to reflect new screen paths.

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2025-04-16 21:58:21 +08:00
parent 3bc658540a
commit dbf6954da0
26 changed files with 290 additions and 73 deletions
@@ -49,7 +49,7 @@ class ItemPressableView: ExpoView {
if touchHighlight {
layer.backgroundColor = UIColor.systemGray5.cgColor
UIView.animate(withDuration: 0.2, delay: 0.5, options: [.curveEaseOut]) {
UIView.animate(withDuration: 0.2, delay: 0.1, options: [.curveEaseOut]) {
self.layer.backgroundColor = bgColor
}
}
@@ -0,0 +1,15 @@
import * as React from "react"
import type { SvgProps } from "react-native-svg"
import Svg, { Path } from "react-native-svg"
export function PhUsersBold(props: SvgProps & { size?: number; color?: string }) {
const { size = 24, color = "currentColor", ...rest } = props
return (
<Svg width={size} height={size} viewBox="0 0 256 256" {...rest}>
<Path
fill={color}
d="M125.18 156.94a64 64 0 1 0-82.36 0a100.23 100.23 0 0 0-39.49 32a12 12 0 0 0 19.35 14.2a76 76 0 0 1 122.64 0a12 12 0 0 0 19.36-14.2a100.33 100.33 0 0 0-39.5-32M44 108a40 40 0 1 1 40 40a40 40 0 0 1-40-40m206.1 97.67a12 12 0 0 1-16.78-2.57A76.31 76.31 0 0 0 172 172a12 12 0 0 1 0-24a40 40 0 1 0-10.3-78.67a12 12 0 1 1-6.16-23.19a64 64 0 0 1 57.64 110.8a100.23 100.23 0 0 1 39.49 32a12 12 0 0 1-2.57 16.73"
/>
</Svg>
)
}
@@ -23,6 +23,7 @@ import { GroupedInsetListCardItemStyle } from "./GroupedInsetListCardItemStyle"
interface GroupedInsetListCardProps {
showSeparator?: boolean
SeparatorComponent?: FC
SeparatorElement?: React.ReactNode
}
interface BaseCellClassNames {
@@ -38,7 +39,14 @@ export const GroupedOutlineDescription: FC<{
export const GroupedInsetListCard: FC<
PropsWithChildren & ViewProps & GroupedInsetListCardProps
> = ({ children, className, showSeparator = true, SeparatorComponent, ...props }) => {
> = ({
children,
className,
showSeparator = true,
SeparatorComponent,
SeparatorElement,
...props
}) => {
const nextChildren = React.useMemo(
() => React.Children.toArray(children).filter(Boolean),
[children],
@@ -63,13 +71,19 @@ export const GroupedInsetListCard: FC<
((child.type as Function).name === GroupedInsetListNavigationLink.name ||
(child.type as any).itemStyle === GroupedInsetListCardItemStyle.NavigationLink)
const NextSeparatorComponent =
typeof SeparatorComponent === "function" ? <SeparatorComponent /> : undefined
const NextSeparatorElement = SeparatorElement
? React.isValidElement(SeparatorElement)
? SeparatorElement
: NextSeparatorComponent
: NextSeparatorComponent
return (
<Fragment key={index}>
{child}
{!isLast &&
(SeparatorComponent ? (
<SeparatorComponent />
) : (
(NextSeparatorElement ?? (
<View
className={cn(
"bg-non-opaque-separator dark:bg-opaque-separator/70",
@@ -13,7 +13,7 @@ import { ContextMenu } from "@/src/components/ui/context-menu"
import { useNavigation } from "@/src/lib/navigation/hooks"
import { toast } from "@/src/lib/toast"
import { getHorizontalScrolling } from "@/src/modules/screen/atoms"
import { EntryDetailScreen } from "@/src/screens/(stack)/entries/[entryId]"
import { EntryDetailScreen } from "@/src/screens/(stack)/entries/[entryId]/EntryDetailScreen"
import { useIsEntryStarred } from "@/src/store/collection/hooks"
import { collectionSyncService } from "@/src/store/collection/store"
import { useEntry } from "@/src/store/entry/hooks"
@@ -13,7 +13,7 @@ import { views } from "@/src/constants/views"
import { useNavigation } from "@/src/lib/navigation/hooks"
import type { Navigation } from "@/src/lib/navigation/Navigation"
import { toast } from "@/src/lib/toast"
import { FeedScreen } from "@/src/screens/(stack)/feeds/[feedId]"
import { FeedScreen } from "@/src/screens/(stack)/feeds/[feedId]/FeedScreen"
import { useEntryIdsByFeedId, usePrefetchEntries } from "@/src/store/entry/hooks"
import { getFeed } from "@/src/store/feed/getter"
import { getSubscription } from "@/src/store/subscription/getter"
@@ -36,7 +36,7 @@ export const GoodLuck = () => {
return (
<View className="mt-4">
{isLoading ? (
<View className="flex h-12 items-center justify-center">
<View className="mt-5 flex h-12 items-center justify-center">
<PlatformActivityIndicator />
</View>
) : (
+11 -4
View File
@@ -13,12 +13,15 @@ import Animated, {
import { useSafeAreaFrame, useSafeAreaInsets } from "react-native-safe-area-context"
import { BlurEffect } from "@/src/components/common/BlurEffect"
import { UINavigationHeaderActionButton } from "@/src/components/layouts/header/NavigationHeader"
import { getDefaultHeaderHeight } from "@/src/components/layouts/utils"
import { Search2CuteReIcon } from "@/src/icons/search_2_cute_re"
import { useScreenIsInSheetModal } from "@/src/lib/navigation/hooks"
import { TrendingUpCuteReIcon } from "@/src/icons/trending_up_cute_re"
import { useNavigation, useScreenIsInSheetModal } from "@/src/lib/navigation/hooks"
import { Navigation } from "@/src/lib/navigation/Navigation"
import { ScreenItemContext } from "@/src/lib/navigation/ScreenItemContext"
import SearchScreen from "@/src/screens/(headless)/search"
import { TrendingScreen } from "@/src/screens/(stack)/trending/TrendingScreen"
import { accentColor, useColor } from "@/src/theme/colors"
import { useSearchPageContext } from "./ctx"
@@ -62,10 +65,8 @@ const DynamicBlurEffect = () => {
</Animated.View>
)
}
export const DiscoverHeader = () => {
return <DiscoverHeaderImpl />
}
const DiscoverHeaderImpl = () => {
const frame = useSafeAreaFrame()
const insets = useSafeAreaInsets()
const sheetModal = useScreenIsInSheetModal()
@@ -74,6 +75,7 @@ const DiscoverHeaderImpl = () => {
const setHeaderHeight = useSetAtom(headerHeightAtom)
const navigation = useNavigation()
return (
<View
style={{ minHeight: headerHeight, paddingTop: insets.top }}
@@ -86,6 +88,11 @@ const DiscoverHeaderImpl = () => {
<View style={styles.header}>
<PlaceholerSearchBar />
<UINavigationHeaderActionButton
onPress={() => navigation.pushControllerView(TrendingScreen)}
>
<TrendingUpCuteReIcon color={accentColor} />
</UINavigationHeaderActionButton>
</View>
</View>
)
@@ -18,7 +18,7 @@ import { PlayCuteFiIcon } from "@/src/icons/play_cute_fi"
import { useNavigation } from "@/src/lib/navigation/hooks"
import { getAttachmentState, player } from "@/src/lib/player"
import { getHorizontalScrolling } from "@/src/modules/screen/atoms"
import { EntryDetailScreen } from "@/src/screens/(stack)/entries/[entryId]"
import { EntryDetailScreen } from "@/src/screens/(stack)/entries/[entryId]/EntryDetailScreen"
import { useEntry } from "@/src/store/entry/hooks"
import { getInboxFrom } from "@/src/store/entry/utils"
import { useFeed } from "@/src/store/feed/hooks"
@@ -13,8 +13,8 @@ import { ItemPressableStyle } from "@/src/components/ui/pressable/enum"
import { ItemPressable } from "@/src/components/ui/pressable/ItemPressable"
import { useNavigation } from "@/src/lib/navigation/hooks"
import { getHorizontalScrolling } from "@/src/modules/screen/atoms"
import { EntryDetailScreen } from "@/src/screens/(stack)/entries/[entryId]"
import { FeedScreen } from "@/src/screens/(stack)/feeds/[feedId]"
import { EntryDetailScreen } from "@/src/screens/(stack)/entries/[entryId]/EntryDetailScreen"
import { FeedScreen } from "@/src/screens/(stack)/feeds/[feedId]/FeedScreen"
import { useEntry } from "@/src/store/entry/hooks"
import { useFeed } from "@/src/store/feed/hooks"
import { useEntryTranslation } from "@/src/store/translation/hooks"
@@ -13,7 +13,7 @@ import { Image } from "@/src/components/ui/image/Image"
import { BottomTabContext } from "@/src/lib/navigation/bottom-tab/BottomTabContext"
import { useNavigation } from "@/src/lib/navigation/hooks"
import { useActiveTrack } from "@/src/lib/player"
import { PlayerScreen } from "@/src/screens/player"
import { PlayerScreen } from "@/src/screens/PlayerScreen"
import { usePrefetchImageColors } from "@/src/store/image/hooks"
import { PlayPauseButton, SeekButton } from "./control"
@@ -9,7 +9,7 @@ import { ItemPressable } from "@/src/components/ui/pressable/ItemPressable"
import { RightCuteFiIcon } from "@/src/icons/right_cute_fi"
import { useNavigation } from "@/src/lib/navigation/hooks"
import { closeDrawer, getHorizontalScrolling, selectFeed } from "@/src/modules/screen/atoms"
import { FeedScreen } from "@/src/screens/(stack)/feeds/[feedId]"
import { FeedScreen } from "@/src/screens/(stack)/feeds/[feedId]/FeedScreen"
import { useUnreadCounts } from "@/src/store/unread/hooks"
import { useColor } from "@/src/theme/colors"
@@ -21,7 +21,7 @@ import { StarCuteFiIcon } from "@/src/icons/star_cute_fi"
import { useNavigation } from "@/src/lib/navigation/hooks"
import { closeDrawer, getHorizontalScrolling, selectFeed } from "@/src/modules/screen/atoms"
import { TimelineSelectorList } from "@/src/modules/screen/TimelineSelectorList"
import { FeedScreen } from "@/src/screens/(stack)/feeds/[feedId]"
import { FeedScreen } from "@/src/screens/(stack)/feeds/[feedId]/FeedScreen"
import { FEED_COLLECTION_LIST } from "@/src/store/entry/utils"
import {
useGroupedSubscription,
@@ -10,7 +10,7 @@ import { ItemPressable } from "@/src/components/ui/pressable/ItemPressable"
import { InboxCuteFiIcon } from "@/src/icons/inbox_cute_fi"
import { useNavigation } from "@/src/lib/navigation/hooks"
import { getHorizontalScrolling, selectFeed } from "@/src/modules/screen/atoms"
import { FeedScreen } from "@/src/screens/(stack)/feeds/[feedId]"
import { FeedScreen } from "@/src/screens/(stack)/feeds/[feedId]/FeedScreen"
import { useSubscription } from "@/src/store/subscription/hooks"
import { getInboxStoreId } from "@/src/store/subscription/utils"
import { useUnreadCount } from "@/src/store/unread/hooks"
@@ -9,7 +9,7 @@ import { Image } from "@/src/components/ui/image/Image"
import { ItemPressableStyle } from "@/src/components/ui/pressable/enum"
import { ItemPressable } from "@/src/components/ui/pressable/ItemPressable"
import { useNavigation } from "@/src/lib/navigation/hooks"
import { FeedScreen } from "@/src/screens/(stack)/feeds/[feedId]"
import { FeedScreen } from "@/src/screens/(stack)/feeds/[feedId]/FeedScreen"
import { useList } from "@/src/store/list/hooks"
import { useListUnreadCount } from "@/src/store/unread/hooks"
@@ -12,7 +12,7 @@ import { ItemPressable } from "@/src/components/ui/pressable/ItemPressable"
import { WifiOffCuteReIcon } from "@/src/icons/wifi_off_cute_re"
import { useNavigation } from "@/src/lib/navigation/hooks"
import { closeDrawer, getHorizontalScrolling, selectFeed } from "@/src/modules/screen/atoms"
import { FeedScreen } from "@/src/screens/(stack)/feeds/[feedId]"
import { FeedScreen } from "@/src/screens/(stack)/feeds/[feedId]/FeedScreen"
import { useFeed, usePrefetchFeed } from "@/src/store/feed/hooks"
import { useSubscription } from "@/src/store/subscription/hooks"
import { useUnreadCount } from "@/src/store/unread/hooks"
+23 -3
View File
@@ -1,4 +1,5 @@
import type { FeedViewType } from "@follow/constants"
import { useQuery } from "@tanstack/react-query"
import { Fragment, useCallback, useEffect, useMemo } from "react"
import { useTranslation } from "react-i18next"
import { FlatList, Image, Share, Text, TouchableOpacity, View } from "react-native"
@@ -40,6 +41,7 @@ import { ItemSeparator } from "@/src/modules/subscription/ItemSeparator"
import type { FeedModel } from "@/src/store/feed/types"
import type { ListModel } from "@/src/store/list/store"
import { useUser, useWhoami } from "@/src/store/user/hooks"
import { userSyncService } from "@/src/store/user/store"
import { useColor } from "@/src/theme/colors"
type Subscription = Awaited<ReturnType<typeof apiClient.subscriptions.$get>>["data"][number]
@@ -55,6 +57,15 @@ export const ProfileScreen: NavigationControllerView<{
return <ProfileScreenImpl userId={userId || whoami?.id} />
}
const usePrefetchUser = (userId: string) => {
const { data } = useQuery({
queryKey: ["user", userId],
queryFn: () => userSyncService.fetchUser(userId),
enabled: !!userId,
staleTime: 1000 * 60 * 5,
})
return data
}
function ProfileScreenImpl(props: { userId: string }) {
const { t } = useTranslation()
const scrollY = useSharedValue(0)
@@ -72,6 +83,7 @@ function ProfileScreenImpl(props: { userId: string }) {
headerOpacity.value = scrollY.value / 100
})
usePrefetchUser(props.userId)
const user = useUser(props.userId)
useEffect(() => {
if (isError) {
@@ -103,7 +115,7 @@ function ProfileScreenImpl(props: { userId: string }) {
<BlurEffect />
<InternalNavigationHeader
title={t("profile.title", {
name: user?.name,
name: user?.name || user?.handle,
})}
headerRight={
<UINavigationHeaderActionButton onPress={openShareUrl}>
@@ -258,7 +270,11 @@ const renderListItems = ({ item }: { item: PickedListModel }) => (
{!item.image && <FallbackIcon title={item.title} size={24} />}
</View>
<Text className="text-text" style={{ marginLeft: GROUPED_ICON_TEXT_GAP }}>
<Text
className="text-text mr-4"
numberOfLines={1}
style={{ marginLeft: GROUPED_ICON_TEXT_GAP }}
>
{item.title}
</Text>
</View>
@@ -284,7 +300,11 @@ const renderFeedItems = ({ item }: { item: PickedFeedModel }) => (
size={24}
/>
</View>
<Text className="text-text" style={{ marginLeft: GROUPED_ICON_TEXT_GAP }}>
<Text
className="text-text mr-4"
numberOfLines={1}
style={{ marginLeft: GROUPED_ICON_TEXT_GAP }}
>
{item.title}
</Text>
</View>
@@ -32,19 +32,6 @@ export default function Discover() {
</View>
}
>
{/* <Pressable
className="mt-6 flex-row items-center gap-1 px-6 pt-4"
onPress={() => {
navigation.pushControllerView(Recommendations)
}}
>
<Text className="text-label text-2xl font-bold leading-[1.1]">Trending</Text>
<RightCuteFiIcon height={20} width={20} color={secondaryLabelColor} />
</Pressable> */}
{/* <TrendingRecommendations /> */}
<View className="mt-6 flex-row items-center gap-1 px-6 pt-4">
<Text className="text-label text-2xl font-bold leading-[1.1]">Good Luck</Text>
</View>
@@ -127,39 +114,6 @@ const styles = StyleSheet.create({
aspectRatio: 1.6,
},
})
// const TrendingRecommendations = () => {
// const { data, isLoading } = useQuery({
// queryKey: ["trending"],
// queryFn: () => getTrendingAggregates({ language: "en" }),
// })
// const array = data?.trendingFeeds.slice(0, 4)
// return (
// <View className="gap-y-4 p-4 pl-8">
// {array?.map((feed, index) => (
// <Fragment key={feed.id}>
// <View className="flex-row items-center gap-2">
// <FeedIcon size={36} feed={feed as any} />
// <View>
// <Text numberOfLines={1} className="text-label text-lg font-medium">
// {feed.title}
// </Text>
// {!!feed.description && (
// <Text numberOfLines={1} className="text-secondary-label text-sm">
// {feed.description}
// </Text>
// )}
// </View>
// </View>
// {index !== array.length - 1 && (
// <View className="bg-opaque-separator dark:bg-non-opaque-separator/50 h-px w-full" />
// )}
// </Fragment>
// ))}
// </View>
// )
// }
export const DiscoverTabScreen: TabScreenComponent = Discover
DiscoverTabScreen.tabBarIcon = ({ focused, color }) => {
const Icon = !focused ? Search3CuteReIcon : Search3CuteFiIcon
@@ -0,0 +1,191 @@
import { useQuery } from "@tanstack/react-query"
import { Text, View } from "react-native"
import { useColor } from "react-native-uikit-colors"
import { getTrendingAggregates } from "@/src/api/trending"
import { PhUsersBold } from "@/src/components/icons/PhUsersBold"
import {
NavigationBlurEffectHeaderView,
SafeNavigationScrollView,
} from "@/src/components/layouts/views/SafeNavigationScrollView"
import { UserAvatar } from "@/src/components/ui/avatar/UserAvatar"
import {
GroupedInsetListCard,
GroupedInsetListSectionHeader,
} from "@/src/components/ui/grouped/GroupedList"
import { FallbackIcon } from "@/src/components/ui/icon/fallback-icon"
import { FeedIcon } from "@/src/components/ui/icon/feed-icon"
import { Image } from "@/src/components/ui/image/Image"
import { PlatformActivityIndicator } from "@/src/components/ui/loading/PlatformActivityIndicator"
import { ItemPressable } from "@/src/components/ui/pressable/ItemPressable"
import { openLink } from "@/src/lib/native"
import { useNavigation } from "@/src/lib/navigation/hooks"
import type { NavigationControllerView } from "@/src/lib/navigation/types"
import { FollowScreen } from "../../(modal)/follow"
import { ProfileScreen } from "../../(modal)/profile"
const UserCount = ({ count, className }: { count: number; className?: string }) => {
const secondaryLabelColor = useColor("secondaryLabel")
return (
<View className="flex-row items-center gap-1 opacity-60">
<PhUsersBold color={secondaryLabelColor} size={12} />
<Text className={`text-label text-xs tabular-nums ${className}`}>{count}</Text>
</View>
)
}
export const TrendingScreen: NavigationControllerView = () => {
const { data, isLoading } = useQuery({
queryKey: ["trending"],
queryFn: () => getTrendingAggregates({ language: "en" }),
})
const navigation = useNavigation()
return (
<SafeNavigationScrollView Header={<NavigationBlurEffectHeaderView title={"Trending"} />}>
{isLoading ? (
<View className="h-36 items-center justify-center">
<PlatformActivityIndicator />
</View>
) : (
<>
{/* Trending Users Section */}
{data && data.trendingUsers.length > 0 && (
<View>
<GroupedInsetListSectionHeader label={"Trending Users"} />
<GroupedInsetListCard
SeparatorElement={
<View
style={{
transform: [{ scaleY: 0.5 }],
}}
className="bg-non-opaque-separator ml-16 h-px"
collapsable={false}
/>
}
>
{/* Remaining Users */}
{data.trendingUsers.map((user) => (
<ItemPressable
key={user.id}
onPress={() =>
navigation.presentControllerView(ProfileScreen, {
userId: user.id,
})
}
className="flex-row items-center px-4 py-2.5"
>
<UserAvatar image={user.image} size={36} />
<Text className="text-label ml-3 font-medium">{user.name}</Text>
</ItemPressable>
))}
</GroupedInsetListCard>
</View>
)}
{/* Trending Lists Section */}
{data && data.trendingLists.length > 0 && (
<View className="mt-6">
<GroupedInsetListSectionHeader label={"Trending Lists"} />
<GroupedInsetListCard>
{data.trendingLists.map((item) => (
<ItemPressable
key={item.id}
onPress={() =>
navigation.presentControllerView(FollowScreen, {
type: "list",
id: item.id,
})
}
className="flex-row items-center px-4 py-3.5"
>
<View className="ml-1 overflow-hidden rounded">
{!!item.image && (
<Image
proxy={{
width: 36,
height: 36,
}}
style={{ height: 36, width: 36 }}
source={{ uri: item.image }}
/>
)}
{!item.image && <FallbackIcon title={item.title || ""} size={36} />}
</View>
<View className="ml-3 flex-1">
<Text className="text-label text-base font-medium" numberOfLines={1}>
{item.title}
</Text>
{!!item.description && (
<Text className="text-secondary-label text-sm" numberOfLines={2}>
{item.description}
</Text>
)}
{/* @ts-ignore */}
{!!item.subscriberCount && <UserCount count={item.subscriberCount} />}
</View>
</ItemPressable>
))}
</GroupedInsetListCard>
</View>
)}
{/* Trending Feeds Section */}
{data && data.trendingFeeds.length > 0 && (
<View className="mt-6">
<GroupedInsetListSectionHeader label={"Trending Feeds"} />
<GroupedInsetListCard>
{data.trendingFeeds.map((feed) => (
<ItemPressable
key={feed.id}
onPress={() =>
navigation.presentControllerView(FollowScreen, {
type: "feed",
id: feed.id,
})
}
className="flex-row items-center justify-between px-4 py-3"
>
<View className="flex-1 flex-row items-center">
<FeedIcon feed={feed as any} size={24} className="rounded" />
<Text className="text-label ml-3 flex-1" numberOfLines={1}>
{feed.title}
</Text>
</View>
{!!(feed as any).subscriberCount && (
<UserCount count={(feed as any).subscriberCount} />
)}
</ItemPressable>
))}
</GroupedInsetListCard>
</View>
)}
{/* Trending Entries Section */}
{data && data.trendingEntries.length > 0 && (
<View className="mb-8 mt-6">
<GroupedInsetListSectionHeader label={"Trending Entries"} />
<GroupedInsetListCard>
{data.trendingEntries.map((entry) => (
<ItemPressable
key={entry.id}
onPress={() => openLink(entry.url)}
className="flex-row items-center justify-between px-4 py-3"
>
<Text className="text-accent flex-1" numberOfLines={1}>
{entry.title}
</Text>
<View className="flex-row items-center gap-1 opacity-60">
<Text className="text-xs">{entry.readCount}</Text>
</View>
</ItemPressable>
))}
</GroupedInsetListCard>
</View>
)}
</>
)}
</SafeNavigationScrollView>
)
}
+1 -1
View File
@@ -12,7 +12,7 @@ import { ForgetPasswordScreen } from "./screens/(modal)/forget-password"
import { InvitationScreen } from "./screens/(modal)/invitation"
import { LoginScreen } from "./screens/(modal)/login"
import { SignUpScreen } from "./screens/(modal)/sign-up"
import { OnboardingScreen } from "./screens/onboarding"
import { OnboardingScreen } from "./screens/OnboardingScreen"
export function registerSitemap() {
;[TermsScreen].forEach((Component) => {
+1 -1
View File
@@ -8,7 +8,7 @@ import { apiClient } from "@/src/lib/api-fetch"
import { kv } from "@/src/lib/kv"
import { useNavigation } from "@/src/lib/navigation/hooks"
import { requestNotificationPermission } from "@/src/lib/permission"
import { EntryDetailScreen } from "@/src/screens/(stack)/entries/[entryId]"
import { EntryDetailScreen } from "@/src/screens/(stack)/entries/[entryId]/EntryDetailScreen"
import { useHasNotificationActions } from "../action/hooks"
import { useWhoami } from "../user/hooks"
+1 -1
View File
@@ -5,7 +5,7 @@ import { useEffect } from "react"
import { apiClient } from "@/src/lib/api-fetch"
import { kv } from "@/src/lib/kv"
import { useNavigation } from "@/src/lib/navigation/hooks"
import { OnboardingScreen } from "@/src/screens/onboarding"
import { OnboardingScreen } from "@/src/screens/OnboardingScreen"
import { isNewUserQueryKey, isOnboardingFinishedStorageKey } from "./constants"
import { userSyncService, useUserStore } from "./store"
+16
View File
@@ -153,6 +153,22 @@ class UserSyncService {
return res
}
async fetchUser(userId: string) {
const res = await apiClient.profiles.$get({ query: { id: userId } })
if (res.code === 0) {
const { whoami } = get()
immerSet((state) => {
state.users[userId] = {
email: null,
isMe: whoami?.id === userId ? 1 : 0,
...res.data,
}
})
}
return res.data
}
}
class UserActions {