2022-12-18 14:51:47 +00:00
|
|
|
import "./Root.css";
|
|
|
|
import { useSelector } from "react-redux";
|
2022-12-29 22:23:41 +00:00
|
|
|
import Note from "../element/Note";
|
|
|
|
import useTimelineFeed from "../feed/TimelineFeed";
|
|
|
|
import { NoteCreator } from "../element/NoteCreator";
|
2022-12-18 14:51:47 +00:00
|
|
|
|
|
|
|
export default function RootPage() {
|
2022-12-28 16:29:42 +00:00
|
|
|
const pubKey = useSelector(s => s.login.publicKey);
|
2023-01-01 19:57:27 +00:00
|
|
|
const follows = useSelector(a => a.login.follows);
|
2022-12-29 22:23:41 +00:00
|
|
|
const { notes } = useTimelineFeed(follows);
|
2022-12-28 22:09:39 +00:00
|
|
|
|
2022-12-29 22:23:41 +00:00
|
|
|
function followHints() {
|
|
|
|
if (follows?.length === 0 && pubKey) {
|
2023-01-01 19:57:27 +00:00
|
|
|
return <>Hmm nothing here..</>
|
2022-12-29 22:23:41 +00:00
|
|
|
}
|
2022-12-18 14:51:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2022-12-29 22:23:41 +00:00
|
|
|
{pubKey ? <NoteCreator /> : null}
|
|
|
|
{followHints()}
|
|
|
|
<div className="timeline">
|
|
|
|
{notes?.sort((a, b) => b.created_at - a.created_at).map(e => <Note key={e.id} data={e} />)}
|
|
|
|
</div>
|
2022-12-18 14:51:47 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|