Skip to content

Commit

Permalink
ptrDistance & loading element for user artists
Browse files Browse the repository at this point in the history
  • Loading branch information
damienmauchamp committed Apr 25, 2024
1 parent 2f586a5 commit 817f44f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
51 changes: 28 additions & 23 deletions src/components/Pages/User/ArtistsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import useAPI from '@/lib/useAPI'
import { useQuery } from 'react-query'
import { UserArtist } from '@/types/Items'
import ArtistListItem from '../../Elements/ArtistListItem/ArtistListItem'
import LoadingSection from '../../Components/Loading/LoadingSection'

interface ArtistsPageProps {}

Expand All @@ -20,24 +21,24 @@ export default function ArtistPage({ ...props }: ArtistsPageProps) {
const api = useAPI()

// artists
const { data, refetch } = useQuery(
'userArtists',
async () => await api.getUserArtists(),
{
enabled: false,
retry: 1,
onSuccess: (res) => {
console.log('SUCCESS setUserArtists:', res.data.data)
setUserArtists(res.data.data as UserArtist[])
// setUserArtists(fortmatResponse(res))
},
onError: (err: any) => {
setUserArtists([])
console.log('err', err)
// setUserArtists(fortmatResponse(err.response?.data || err))
},
}
)
const {
data,
refetch,
isLoading: isLoadingArtists,
} = useQuery('userArtists', async () => await api.getUserArtists(), {
enabled: false,
retry: 1,
onSuccess: (res) => {
console.log('SUCCESS setUserArtists:', res.data.data)
setUserArtists(res.data.data as UserArtist[])
// setUserArtists(fortmatResponse(res))
},
onError: (err: any) => {
setUserArtists([])
console.log('err', err)
// setUserArtists(fortmatResponse(err.response?.data || err))
},
})
const [userArtists, setUserArtists] = useState<UserArtist[]>(
data?.data.data || []
)
Expand Down Expand Up @@ -198,11 +199,15 @@ export default function ArtistPage({ ...props }: ArtistsPageProps) {
dividersIos
className="artists-list searchbar-found"
>
<ul>
{userArtists.map((artist: UserArtist) => (
<ArtistListItem key={artist.id} artist={artist} />
))}
</ul>
{isLoadingArtists ? (
<LoadingSection />
) : (
<ul>
{userArtists.map((artist: UserArtist) => (
<ArtistListItem key={artist.id} artist={artist} />
))}
</ul>
)}
</List>

{/* <Block>
Expand Down
1 change: 1 addition & 0 deletions src/components/PagesType/F7Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ const F7Page = forwardRef<{ el: HTMLElement | null }, F7PageProps>(
${searchBarEnabled ? 'with-appstore-searchbar-enabled' : ''}
`}
ptr={ref ? ptr : false}
ptrDistance={(ref && ptr && props.ptrDistance) || 128}
onPtrRefresh={onPullToRefresh}
{...props}
ref={pageRef}
Expand Down

0 comments on commit 817f44f

Please sign in to comment.