phanpy/src/pages/bookmarks.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

28 lines
650 B
JavaScript

import { useRef } from 'preact/hooks';
import Timeline from '../components/timeline';
const LIMIT = 20;
function Bookmarks() {
const bookmarksIterator = useRef();
async function fetchBookmarks(firstLoad) {
if (firstLoad || !bookmarksIterator.current) {
bookmarksIterator.current = masto.v1.bookmarks.list({ limit: LIMIT });
}
return await bookmarksIterator.current.next();
}
return (
<Timeline
title="Bookmarks"
id="bookmarks"
emptyText="No bookmarks yet. Go bookmark something!"
errorText="Unable to load bookmarks"
fetchItems={fetchBookmarks}
/>
);
}
export default Bookmarks;