phanpy/src/pages/bookmarks.jsx

32 lines
786 B
React
Raw Normal View History

import { useRef } from 'preact/hooks';
import Timeline from '../components/timeline';
import { api } from '../utils/api';
2023-02-03 16:08:08 +03:00
import useTitle from '../utils/useTitle';
const LIMIT = 20;
function Bookmarks() {
2023-02-03 16:08:08 +03:00
useTitle('Bookmarks', '/b');
const { masto } = api();
2023-01-21 15:21:16 +03:00
const bookmarksIterator = useRef();
async function fetchBookmarks(firstLoad) {
2023-01-21 15:21:16 +03:00
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;