diff --git a/apps/mobile/src/modules/settings/SettingsList.tsx b/apps/mobile/src/modules/settings/SettingsList.tsx index 8e421fa07..dd3091a65 100644 --- a/apps/mobile/src/modules/settings/SettingsList.tsx +++ b/apps/mobile/src/modules/settings/SettingsList.tsx @@ -1,7 +1,7 @@ import { useIsFocused } from "@react-navigation/native" import * as FileSystem from "expo-file-system" import type { FC, RefObject } from "react" -import { Fragment, useContext, useEffect } from "react" +import { Fragment, useContext, useEffect, useMemo } from "react" import type { ScrollView } from "react-native" import { Alert, View } from "react-native" import { useSafeAreaInsets } from "react-native-safe-area-context" @@ -26,6 +26,7 @@ import { Settings1CuteFiIcon } from "@/src/icons/settings_1_cute_fi" import { StarCuteFiIcon } from "@/src/icons/star_cute_fi" import { UserSettingCuteFiIcon } from "@/src/icons/user_setting_cute_fi" import { signOut } from "@/src/lib/auth" +import { useWhoami } from "@/src/store/user/hooks" import { useSettingsNavigation } from "./hooks" @@ -38,6 +39,7 @@ interface GroupNavigationLink { ) => void iconBackgroundColor: string + anonymous?: boolean todo?: boolean } const SettingGroupNavigationLinks: GroupNavigationLink[] = [ @@ -57,6 +59,7 @@ const SettingGroupNavigationLinks: GroupNavigationLink[] = [ }, iconBackgroundColor: "#FBBF24", todo: true, + anonymous: false, }, { label: "Appearance", @@ -73,6 +76,7 @@ const SettingGroupNavigationLinks: GroupNavigationLink[] = [ navigation.navigate("Data") }, iconBackgroundColor: "#CBAD6D", + anonymous: false, }, { label: "Account", @@ -81,6 +85,7 @@ const SettingGroupNavigationLinks: GroupNavigationLink[] = [ navigation.navigate("Account") }, iconBackgroundColor: "#d08700", + anonymous: false, }, ] @@ -93,6 +98,7 @@ const DataGroupNavigationLinks: GroupNavigationLink[] = [ }, iconBackgroundColor: "#059669", todo: true, + anonymous: false, }, { @@ -103,6 +109,7 @@ const DataGroupNavigationLinks: GroupNavigationLink[] = [ }, iconBackgroundColor: "#10B981", todo: true, + anonymous: false, }, { label: "Lists", @@ -112,6 +119,7 @@ const DataGroupNavigationLinks: GroupNavigationLink[] = [ }, iconBackgroundColor: "#34D399", // todo: true, + anonymous: false, }, ] @@ -155,6 +163,7 @@ const ActionGroupNavigationLinks: GroupNavigationLink[] = [ ]) }, iconBackgroundColor: "#F87181", + anonymous: false, }, ] @@ -187,7 +196,6 @@ const NavigationLinkGroup: FC<{ ) const navigationGroups = [ - // UserGroupNavigationLinks, DataGroupNavigationLinks, SettingGroupNavigationLinks, PrivacyGroupNavigationLinks, @@ -207,12 +215,26 @@ export const SettingsList: FC<{ scrollRef: RefObject }> = ({ scrollR const insets = useSafeAreaInsets() const tabBarHeight = useBottomTabBarHeight() + + const whoami = useWhoami() + + const filteredNavigationGroups = useMemo(() => { + if (whoami) return navigationGroups + + return navigationGroups + .map((group) => { + const filteredGroup = group.filter((link) => link.anonymous !== false) + if (filteredGroup.length === 0) return false + return filteredGroup + }) + .filter((group) => group !== false) + }, [whoami]) return ( - {navigationGroups.map((group, index) => ( + {filteredNavigationGroups.map((group, index) => ( }> = ({ scrollR navigation={navigation} scrollRef={scrollRef} /> - {index < navigationGroups.length - 1 && } + {index < filteredNavigationGroups.length - 1 && } ))}