diff --git a/core/screens/userprofile/components/OwnProfileView.tsx b/core/screens/userprofile/components/OwnProfileView.tsx index 1b92198f257b64b4493ab6e85fedadf9b27bee83..a83ea72c4a968a60abd0cb8d21d6856ba547d14c 100644 --- a/core/screens/userprofile/components/OwnProfileView.tsx +++ b/core/screens/userprofile/components/OwnProfileView.tsx @@ -48,15 +48,20 @@ const OwnProfileView = ({ user, toggleEditMode, activeTab, onTabChange }: PropsW const { colors } = theme const styles = useMemo(() => getStyles(theme), [theme]) - const { data: dataInsights } = useQuery<InsightsByUserIdResponse>(insightsByUserIdTotalResultsQuery, { - variables: { userId: user.id }, - onError: (error) => - logError(error, 'Failed to load insights for user', { - location: 'OwnProfileView.insightsByUserIdTotalResultsQuery', - }), - }) + const { data: dataInsights, error: insightsError } = useQuery<InsightsByUserIdResponse>( + insightsByUserIdTotalResultsQuery, + { + variables: { userId: user.id }, + skip: !user?.id, + onError: (error) => { + logError(error, 'Failed to load insights for user', { + location: 'OwnProfileView.insightsByUserIdTotalResultsQuery', + }) + }, + } + ) - const hasInsights = !!dataInsights?.insightsByUserId?.totalResults + const hasInsights = !insightsError && !!dataInsights?.insightsByUserId?.totalResults const tabNamesInOrder = [Tab.PROFILE, Tab.POSTS] if (hasInsights) tabNamesInOrder.push(Tab.INSIGHTS)