11import { useEffect , useState } from 'react' ;
22import { keepPreviousData , useQuery } from '@tanstack/react-query' ;
3- import { get } from 'lodash-es' ;
43import ReactGA from 'react-ga-neo' ;
54import { Trans } from 'react-i18next' ;
65import { useSelector } from 'react-redux' ;
@@ -23,8 +22,11 @@ import { UserResultsHeading } from './partials/UserResultsHeading';
2322
2423import { MAX_RECENT_USERS } from 'Constants' ;
2524
25+ import type { AxiosError } from 'axios' ;
2626import type { RootState } from 'store' ;
2727
28+ type UserGetRecentTracksResult = Awaited < ReturnType < typeof userGetRecentTracks > > ;
29+
2830export function ScrobbleUserResults ( ) {
2931 const { username : usernameFromParams } = useParams ( ) ;
3032 const lowercaseUsername = usernameFromParams . toLowerCase ( ) ;
@@ -34,7 +36,10 @@ export function ScrobbleUserResults() {
3436 const [ recentUsers , setRecentUsers ] = useLocalStorage ( 'recentUsers' , [ ] ) ;
3537 const navigate = useNavigate ( ) ;
3638
37- const { data, isLoading, isFetching, isError, error, isSuccess, isPlaceholderData } = useQuery ( {
39+ const { data, isLoading, isFetching, isError, error, isSuccess, isPlaceholderData } = useQuery <
40+ UserGetRecentTracksResult ,
41+ AxiosError
42+ > ( {
3843 queryKey : [ 'profile' , lowercaseUsername , 'scrobbles' , currentPage ] ,
3944 queryFn : ( ) => userGetRecentTracks ( lowercaseUsername , currentPage ) ,
4045 staleTime : 1000 * 60 * 3 , // minutes
@@ -84,7 +89,7 @@ export function ScrobbleUserResults() {
8489
8590 useEffect ( ( ) => {
8691 if ( isError ) {
87- const errNumber = get ( error , ' response.data.error' ) ;
92+ const errNumber = ( error ?. response ? .data as any ) ? .error ;
8893 // 6: User not found - 17: User has a private profile
8994 if ( errNumber === 6 || errNumber === 17 ) {
9095 // ToDo: handle private profile case
0 commit comments