diff --git a/packages/common/src/api/tan-query/users/useUserByParams.ts b/packages/common/src/api/tan-query/users/useUserByParams.ts index da45225f9ce..261173cb00d 100644 --- a/packages/common/src/api/tan-query/users/useUserByParams.ts +++ b/packages/common/src/api/tan-query/users/useUserByParams.ts @@ -16,7 +16,7 @@ type UserParams = { id?: ID } | { handle?: string | null } * @returns The user data or null if not found */ export const useUserByParams = < - TResult extends { user_id: number; handle: string } = UserMetadata + TResult extends Partial = UserMetadata >( params: UserParams, options?: SelectableQueryOptions diff --git a/packages/common/src/hooks/useIsArtist.ts b/packages/common/src/hooks/useIsArtist.ts index f5a0a8f8e3b..2416cf39cd4 100644 --- a/packages/common/src/hooks/useIsArtist.ts +++ b/packages/common/src/hooks/useIsArtist.ts @@ -2,20 +2,22 @@ import { useEffect } from 'react' import { useDispatch } from 'react-redux' +import { useUserByParams } from '~/api' import { useCurrentAccount } from '~/api/tan-query/users/account/useCurrentAccount' -import { useProfileUser } from '~/api/tan-query/users/useProfileUser' +import { ID } from '~/models' import { accountActions } from '~/store/account' const { fetchHasTracks } = accountActions -export const useIsArtist = () => { - const { user_id, track_count } = - useProfileUser({ +export const useIsArtist = (params: { id?: ID; handle?: string }) => { + const { data: user } = + useUserByParams(params, { select: (user) => ({ user_id: user.user_id, track_count: user.track_count }) - }).user ?? {} + }) ?? {} + const { user_id, track_count } = user ?? {} const { data: account } = useCurrentAccount() const currentUserId = account?.userId diff --git a/packages/mobile/src/screens/profile-screen/ProfileTabs/ProfileTabNavigator.tsx b/packages/mobile/src/screens/profile-screen/ProfileTabs/ProfileTabNavigator.tsx index 71060b87224..cbf92d5e03b 100644 --- a/packages/mobile/src/screens/profile-screen/ProfileTabs/ProfileTabNavigator.tsx +++ b/packages/mobile/src/screens/profile-screen/ProfileTabs/ProfileTabNavigator.tsx @@ -49,7 +49,7 @@ export const ProfileTabNavigator = ({ const { params } = useRoute<'Profile'>() const initialParams = { id: user_id, handle: params.handle } - const isArtist = useIsArtist() + const isArtist = useIsArtist(params) const showCollectiblesTab = useShouldShowCollectiblesTab() diff --git a/packages/web/src/pages/profile-page/ProfilePageProvider.tsx b/packages/web/src/pages/profile-page/ProfilePageProvider.tsx index 58a38d61a7f..26a16bfa073 100644 --- a/packages/web/src/pages/profile-page/ProfilePageProvider.tsx +++ b/packages/web/src/pages/profile-page/ProfilePageProvider.tsx @@ -1129,7 +1129,7 @@ type HookStateProps = { } const hookStateToProps = (Component: typeof ProfilePage) => { return (props: ProfilePageProps) => { - const isArtist = useIsArtist() + const isArtist = useIsArtist({ id: props.profile?.profile?.user_id }) const { data: accountData } = useCurrentAccountUser({ select: (user) => ({ accountUserId: user?.user_id diff --git a/packages/web/src/pages/transaction-history-page/desktop/TransactionHistoryPage.tsx b/packages/web/src/pages/transaction-history-page/desktop/TransactionHistoryPage.tsx index d9daff21fca..4a0fde3c1c8 100644 --- a/packages/web/src/pages/transaction-history-page/desktop/TransactionHistoryPage.tsx +++ b/packages/web/src/pages/transaction-history-page/desktop/TransactionHistoryPage.tsx @@ -1,6 +1,7 @@ import { useCallback, useState } from 'react' -import { useFeatureFlag, useIsArtist } from '@audius/common/hooks' +import { useCurrentAccount } from '@audius/common/api' +import { useFeatureFlag } from '@audius/common/hooks' import { FeatureFlags } from '@audius/common/services' import { Button, @@ -41,7 +42,9 @@ type TableMetadata = { export const TransactionHistoryPage = ({ tableView }: TransactionHistoryPageProps) => { - const isArtist = useIsArtist() + const { data: isArtist } = useCurrentAccount({ + select: (account) => account?.hasTracks + }) const [tableOptions, setTableOptions] = useState(null) const [selectedTable, setSelectedTable] = useState(null) diff --git a/packages/web/src/pages/transaction-history-page/mobile/TransactionHistoryPage.tsx b/packages/web/src/pages/transaction-history-page/mobile/TransactionHistoryPage.tsx index b5d29f9da66..e3b60dc9f0a 100644 --- a/packages/web/src/pages/transaction-history-page/mobile/TransactionHistoryPage.tsx +++ b/packages/web/src/pages/transaction-history-page/mobile/TransactionHistoryPage.tsx @@ -1,7 +1,11 @@ import { useCallback, useState } from 'react' -import { selectIsGuestAccount, useCurrentAccountUser } from '@audius/common/api' -import { useFeatureFlag, useIsArtist } from '@audius/common/hooks' +import { + selectIsGuestAccount, + useCurrentAccount, + useCurrentAccountUser +} from '@audius/common/api' +import { useFeatureFlag } from '@audius/common/hooks' import { FeatureFlags } from '@audius/common/services' import { route } from '@audius/common/utils' import { @@ -47,7 +51,9 @@ export const TransactionHistoryPage = ({ tableView }: TransactionHistoryPageProps) => { const dispatch = useDispatch() - const isArtist = useIsArtist() + const { data: isArtist } = useCurrentAccount({ + select: (account) => account?.hasTracks + }) const { data: accountData } = useCurrentAccountUser({ select: (user) => ({ handle: user?.handle,