import { coverBackground } from "../../ui/constants.jsx"; import { I } from "../../ui/icons.jsx"; import { NotebookCover } from "../../ui/NotebookCover.jsx"; import { fmtDate } from "../../ui/format"; import { FONT_SERIF, FONT_UI } from "../../ui/theme"; const RECENT_COUNT = 6; /** Landing view: every notebook as a cover, plus the notes touched most recently. */ /** * The six most recently edited, whatever order the list arrives in. * * `activeNotes` carries whichever arrangement the notebook it came from was in — * a hand-made order, or a title sort — and under this heading that is simply the * wrong list: "Recent" is a question about time, and it must answer it even when * every notebook is arranged by hand. */ const byLastEdited = (notes, count) => [...notes].sort((a, b) => String(b.updatedAt || "").localeCompare(String(a.updatedAt || ""))).slice(0, count); export function Dashboard({ T, isMobile, notebooks, activeNotes, activeFolder, onToggleSidebar, onOpenNotebook, onOpenNote, onNewNotebook, onNotebookContextMenu, dnd, }) { const recentlyEdited = byLastEdited(activeNotes, RECENT_COUNT); return (

Dashboard

Recent Notes

{recentlyEdited.map((note) => { const nb = notebooks.find((b) => b.id === note.folderId); return ( ); })}
{/* The covers come second now. What you were last writing is what you usually came back for; the shelf is for choosing where to go next. */}

My Notebooks

{notebooks.map((nb) => ( n.folderId === nb.id).length} onClick={() => onOpenNotebook(nb.id)} onContextMenu={(e) => onNotebookContextMenu(e, nb)} isActive={activeFolder === nb.id} isDragOver={dnd.overId === nb.id} draggable={!isMobile} onDragStart={(e) => dnd.onDragStart(e, nb.id)} onDragEnd={dnd.onDragEnd} onDragOver={(e) => dnd.onDragOver(e, nb.id)} onDrop={(e) => dnd.onDrop(e, nb.id)} /> ))}
); }