phanpy/src/pages/favourites.jsx
Lim Chee Aun aaeca7dd03 Refactor out a Timeline component
Also replace login() with createClient() for faster log in
2023-01-28 18:52:18 +08:00

27 lines
664 B
JavaScript

import { useRef } from 'preact/hooks';
import Timeline from '../components/timeline';
const LIMIT = 20;
function Favourites() {
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;