A chapter you can see, in the colour you chose
A chapter did not show until the notebook had a note in it. "Nothing here" was asked of the notes alone, so a notebook whose only contents were chapters showed the empty-list panel with the chapters hidden behind it — making a chapter in a fresh notebook appeared to do nothing at all. It is asked of every row now, and a notebook with chapters but no loose notes says so in one line rather than looking like a list that failed to load. The colour is chosen while the chapter is being made, in the dialog that asks for its name. It is what tells one chapter from the next, and having to right-click a fresh one to say which it is meant two visits for one decision. Renaming and recolouring afterwards are one entry in its menu and one write; the server already took the colour on create, the client simply never sent it. The word "here" is gone. The line along the top of the pane says which of the two places you are in, and saying it twice was noise. Thirteen suites green: 338 browser checks, 241 unit tests. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ebf1f1bc62
commit
165ccf3cf7
8 files changed
+197
-66
No files matched your search
@@ -52,9 +52,9 @@ export interface NoteData {
|
||||
createNotebook: (fields: { name: string; cover: number }) => Promise<Notebook>;
|
||||
updateNotebook: (id: string, updates: Partial<Notebook>) => Promise<void>;
|
||||
chapters: Chapter[];
|
||||
createChapter: (notebookId: string, name: string) => Promise<Chapter>;
|
||||
renameChapter: (id: string, name: string) => Promise<void>;
|
||||
recolourChapter: (id: string, color: string | null) => Promise<void>;
|
||||
createChapter: (notebookId: string, name: string, color?: string | null) => Promise<Chapter>;
|
||||
/** Name, colour, or both — one write for one decision. */
|
||||
editChapter: (id: string, updates: { name?: string; color?: string | null }) => Promise<void>;
|
||||
deleteChapter: (id: string) => Promise<void>;
|
||||
deleteNotebook: (id: string) => Promise<void>;
|
||||
reorderNotebooks: (dragId: string, targetId: string) => void;
|
||||
@@ -356,20 +356,23 @@ export function useNoteData(user: User | null, activeNote: string | null): NoteD
|
||||
* having the removal applied by hand here.
|
||||
*/
|
||||
|
||||
const createChapter = useCallback(async (notebookId: string, name: string) => {
|
||||
const chapter = await sync.createChapter(notebookId, name);
|
||||
setChapters((p) => [...p, chapter]);
|
||||
return chapter;
|
||||
}, []);
|
||||
const createChapter = useCallback(
|
||||
async (notebookId: string, name: string, color: string | null = null) => {
|
||||
const chapter = await sync.createChapter(notebookId, name, color);
|
||||
setChapters((p) => [...p, chapter]);
|
||||
return chapter;
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const renameChapter = useCallback(async (id: string, name: string) => {
|
||||
setChapters((p) => p.map((c) => (c.id === id ? { ...c, name } : c)));
|
||||
await sync.updateChapter(id, { name });
|
||||
}, []);
|
||||
|
||||
const recolourChapter = useCallback(async (id: string, color: string | null) => {
|
||||
setChapters((p) => p.map((c) => (c.id === id ? { ...c, color } : c)));
|
||||
await sync.updateChapter(id, { color });
|
||||
/* Name and colour go the same way, in one write.
|
||||
*
|
||||
* They used to be two calls because they came from two places — a dialog and
|
||||
* a submenu — and renaming a chapter while recolouring it then meant two
|
||||
* requests for one decision. */
|
||||
const editChapter = useCallback(async (id: string, updates: { name?: string; color?: string | null }) => {
|
||||
setChapters((p) => p.map((c) => (c.id === id ? { ...c, ...updates } : c)));
|
||||
await sync.updateChapter(id, updates);
|
||||
}, []);
|
||||
|
||||
const deleteChapter = useCallback(
|
||||
@@ -434,8 +437,7 @@ export function useNoteData(user: User | null, activeNote: string | null): NoteD
|
||||
updateNotebook,
|
||||
chapters,
|
||||
createChapter,
|
||||
renameChapter,
|
||||
recolourChapter,
|
||||
editChapter,
|
||||
deleteChapter,
|
||||
deleteNotebook,
|
||||
reorderNotebooks,
|
||||
|
||||
Reference in new issue
Block a user