2022-08-02 06:20:07 -07:00
|
|
|
import { useQuery } from '@tanstack/react-query';
|
|
|
|
|
2022-08-09 08:24:43 -07:00
|
|
|
import { useApi } from 'soapbox/hooks';
|
2022-08-02 06:20:07 -07:00
|
|
|
|
|
|
|
type Avatar = {
|
|
|
|
account_id: string
|
|
|
|
account_avatar: string
|
|
|
|
username: string
|
|
|
|
}
|
|
|
|
|
2022-08-08 12:53:21 -07:00
|
|
|
export default function useCarouselAvatars() {
|
2022-08-09 08:24:43 -07:00
|
|
|
const api = useApi();
|
|
|
|
|
|
|
|
const getCarouselAvatars = async() => {
|
|
|
|
const { data } = await api.get('/api/v1/truth/carousels/avatars');
|
|
|
|
return data;
|
|
|
|
};
|
|
|
|
|
2022-08-08 12:53:21 -07:00
|
|
|
const result = useQuery<Avatar[]>(['carouselAvatars'], getCarouselAvatars, {
|
2022-08-02 06:20:07 -07:00
|
|
|
placeholderData: [],
|
|
|
|
});
|
|
|
|
|
2022-08-08 12:53:21 -07:00
|
|
|
const avatars = result.data;
|
2022-08-02 06:20:07 -07:00
|
|
|
|
|
|
|
return {
|
2022-08-08 12:53:21 -07:00
|
|
|
...result,
|
|
|
|
data: avatars || [],
|
2022-08-02 06:20:07 -07:00
|
|
|
};
|
|
|
|
}
|