phanpy/src/pages/bookmarks.jsx

33 lines
822 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');
2023-02-18 19:05:46 +03:00
const { masto, instance } = 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"
2023-02-18 19:05:46 +03:00
instance={instance}
fetchItems={fetchBookmarks}
/>
);
}
export default Bookmarks;