2023-01-28 11:52:18 +01:00
|
|
|
import { useEffect, useRef, useState } from 'preact/hooks';
|
|
|
|
import { useParams } from 'react-router-dom';
|
|
|
|
|
|
|
|
import Timeline from '../components/timeline';
|
2023-02-03 14:08:08 +01:00
|
|
|
import useTitle from '../utils/useTitle';
|
2023-01-28 11:52:18 +01:00
|
|
|
|
|
|
|
const LIMIT = 20;
|
|
|
|
|
|
|
|
function Lists() {
|
|
|
|
const { id } = useParams();
|
|
|
|
const listsIterator = useRef();
|
|
|
|
async function fetchLists(firstLoad) {
|
|
|
|
if (firstLoad || !listsIterator.current) {
|
|
|
|
listsIterator.current = masto.v1.timelines.listList(id, {
|
|
|
|
limit: LIMIT,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return await listsIterator.current.next();
|
|
|
|
}
|
|
|
|
|
|
|
|
const [title, setTitle] = useState(`List ${id}`);
|
2023-02-03 14:08:08 +01:00
|
|
|
useTitle(title, `/l/${id}`);
|
2023-01-28 11:52:18 +01:00
|
|
|
useEffect(() => {
|
|
|
|
(async () => {
|
|
|
|
try {
|
|
|
|
const list = await masto.v1.lists.fetch(id);
|
|
|
|
setTitle(list.title);
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
}, [id]);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Timeline
|
|
|
|
title={title}
|
|
|
|
id="lists"
|
|
|
|
emptyText="Nothing yet."
|
|
|
|
errorText="Unable to load posts."
|
|
|
|
fetchItems={fetchLists}
|
2023-02-03 14:08:08 +01:00
|
|
|
boostsCarousel
|
2023-01-28 11:52:18 +01:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Lists;
|