✨ new poem button
This commit is contained in:
@@ -40,6 +40,18 @@ export function PoemSidebar(): JSX.Element {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function createPoem(): Promise<void> {
|
||||||
|
const name = `untitled-${Date.now()}`
|
||||||
|
const { path, id } = await window.api.createPoem(name)
|
||||||
|
const refreshed = await window.api.listPoems()
|
||||||
|
setPoems(refreshed)
|
||||||
|
const content = await window.api.readPoem(path)
|
||||||
|
setActivePoem(path, id, content)
|
||||||
|
await saveSession()
|
||||||
|
setRenaming(id)
|
||||||
|
setRenameValue(name)
|
||||||
|
}
|
||||||
|
|
||||||
async function commitRename(id: string): Promise<void> {
|
async function commitRename(id: string): Promise<void> {
|
||||||
const poem = poems.find(p => p.id === id)
|
const poem = poems.find(p => p.id === id)
|
||||||
if (!poem || !renameValue.trim() || renameValue === id) { setRenaming(null); return }
|
if (!poem || !renameValue.trim() || renameValue === id) { setRenaming(null); return }
|
||||||
@@ -53,6 +65,7 @@ export function PoemSidebar(): JSX.Element {
|
|||||||
<>
|
<>
|
||||||
<div className="sidebar-header">
|
<div className="sidebar-header">
|
||||||
<span className="sidebar-title">Poems</span>
|
<span className="sidebar-title">Poems</span>
|
||||||
|
<button className="chat-new-btn" onClick={createPoem} title="New poem">+</button>
|
||||||
</div>
|
</div>
|
||||||
<div className="sidebar-search">
|
<div className="sidebar-search">
|
||||||
<input
|
<input
|
||||||
|
|||||||
Reference in New Issue
Block a user