2023-01-28 13:52:18 +03:00
|
|
|
import { useRef } from 'preact/hooks';
|
|
|
|
|
|
|
|
import Timeline from '../components/timeline';
|
2023-02-03 16:08:08 +03:00
|
|
|
import useTitle from '../utils/useTitle';
|
2023-01-28 13:52:18 +03:00
|
|
|
|
|
|
|
const LIMIT = 20;
|
|
|
|
|
|
|
|
function Favourites() {
|
2023-02-03 16:08:08 +03:00
|
|
|
useTitle('Favourites', '/f');
|
2023-01-28 13:52:18 +03:00
|
|
|
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"
|
|
|
|
fetchItems={fetchFavourites}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Favourites;
|