2023-01-28 13:52:18 +03:00
|
|
|
import { useRef } from 'preact/hooks';
|
2023-01-20 19:23:59 +03:00
|
|
|
|
2023-01-28 13:52:18 +03:00
|
|
|
import Timeline from '../components/timeline';
|
2023-01-20 19:23:59 +03:00
|
|
|
|
2023-01-28 13:52:18 +03:00
|
|
|
const LIMIT = 20;
|
2023-01-20 19:23:59 +03:00
|
|
|
|
|
|
|
function Bookmarks() {
|
2023-01-21 15:21:16 +03:00
|
|
|
const bookmarksIterator = useRef();
|
2023-01-20 19:23:59 +03:00
|
|
|
async function fetchBookmarks(firstLoad) {
|
2023-01-21 15:21:16 +03:00
|
|
|
if (firstLoad || !bookmarksIterator.current) {
|
2023-01-20 19:23:59 +03:00
|
|
|
bookmarksIterator.current = masto.v1.bookmarks.list({ limit: LIMIT });
|
|
|
|
}
|
2023-01-28 13:52:18 +03:00
|
|
|
return await bookmarksIterator.current.next();
|
2023-01-20 19:23:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2023-01-28 13:52:18 +03:00
|
|
|
<Timeline
|
|
|
|
title="Bookmarks"
|
|
|
|
id="bookmarks"
|
|
|
|
emptyText="No bookmarks yet. Go bookmark something!"
|
|
|
|
errorText="Unable to load bookmarks"
|
|
|
|
fetchItems={fetchBookmarks}
|
|
|
|
/>
|
2023-01-20 19:23:59 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Bookmarks;
|