Temp(?) note refactors
This commit is contained in:
@@ -10,12 +10,28 @@ import ListItem from "./ListItem"
|
||||
import { useNote } from "../contexts/ActiveNoteContext"
|
||||
import { useNotesStore } from "../contexts/NotesStore"
|
||||
import { useTheme } from "../contexts/ThemeContext"
|
||||
import { ReactNode } from "react"
|
||||
|
||||
function AppSidebar() {
|
||||
const { notes, createNote } = useNotesStore()
|
||||
const { setCurrentNote } = useNote()
|
||||
const { setCurrentNoteId } = useNote()
|
||||
const { theme, toggleTheme } = useTheme()
|
||||
|
||||
const buildNoteListItems = () => {
|
||||
const out: ReactNode[] = []
|
||||
notes.forEach((note, key, _) => {
|
||||
out.push(
|
||||
<ListItem
|
||||
key={key}
|
||||
id={note.id}
|
||||
label={note.title}
|
||||
onSelect={() => setCurrentNoteId(note.id)}
|
||||
/>
|
||||
)
|
||||
})
|
||||
return out;
|
||||
}
|
||||
|
||||
return (
|
||||
<Sidebar>
|
||||
|
||||
@@ -32,14 +48,7 @@ function AppSidebar() {
|
||||
<SidebarContent>
|
||||
<ScrollArea className="h-full px-2 py-2">
|
||||
<div className="space-y-1 py-2">
|
||||
{notes.map((note) => (
|
||||
<ListItem
|
||||
key={note.id}
|
||||
id={note.id}
|
||||
label={note.title}
|
||||
onSelect={() => setCurrentNote(note)}
|
||||
/>
|
||||
))}
|
||||
{buildNoteListItems()}
|
||||
</div>
|
||||
|
||||
<Button
|
||||
|
||||
Reference in New Issue
Block a user