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-02-05 19:17:19 +03:00
|
|
|
import { api } from '../utils/api';
|
2023-02-03 16:08:08 +03:00
|
|
|
import useTitle from '../utils/useTitle';
|
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-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();
|
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"
|
2023-02-18 19:05:46 +03:00
|
|
|
instance={instance}
|
2023-01-28 13:52:18 +03:00
|
|
|
fetchItems={fetchBookmarks}
|
|
|
|
/>
|
2023-01-20 19:23:59 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Bookmarks;
|