mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-12-30 06:08:14 +03:00
32 lines
837 B
JavaScript
32 lines
837 B
JavaScript
import { useRef } from 'preact/hooks';
|
|
|
|
import Timeline from '../components/timeline';
|
|
import { api } from '../utils/api';
|
|
import useTitle from '../utils/useTitle';
|
|
|
|
const LIMIT = 20;
|
|
|
|
function Favourites() {
|
|
useTitle('Favourites', '/f');
|
|
const { masto, instance } = api();
|
|
const favouritesIterator = useRef();
|
|
async function fetchFavourites(firstLoad) {
|
|
if (firstLoad || !favouritesIterator.current) {
|
|
favouritesIterator.current = masto.v1.favourites.list({ limit: LIMIT });
|
|
}
|
|
return await favouritesIterator.current.next();
|
|
}
|
|
|
|
return (
|
|
<Timeline
|
|
title="Favourites"
|
|
id="favourites"
|
|
emptyText="No favourites yet. Go favourite something!"
|
|
errorText="Unable to load favourites"
|
|
instance={instance}
|
|
fetchItems={fetchFavourites}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export default Favourites;
|