fix: customize icon & color works for types without Type entry (#173)
Types without a dedicated Type definition note in the vault silently failed to save icon/color customizations. Both applyCustomization (Sidebar) and handleCustomizeType (useEntryActions) returned early when no Type entry existed. Also fixed a race condition where two concurrent handleUpdateFrontmatter calls could overwrite each other. Changes: - useNoteActions: add createTypeEntrySilent for headless Type file creation - useEntryActions: auto-create Type entry when missing, serialize writes - Sidebar: applyCustomization proceeds with defaults when no Type entry - App: wire createTypeEntrySilent into useEntryActions config Co-authored-by: Test <test@test.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -389,6 +389,14 @@ export function useNoteActions(config: NoteActionsConfig) {
|
||||
|
||||
const handleCreateType = useCallback((typeName: string) => persistNew(resolveNewType(typeName)), [persistNew])
|
||||
|
||||
/** Create a Type entry file silently (no tab opened). Adds to state and persists to disk. */
|
||||
const createTypeEntrySilent = useCallback(async (typeName: string): Promise<VaultEntry> => {
|
||||
const resolved = resolveNewType(typeName)
|
||||
addEntryWithMock(resolved.entry, resolved.content, addEntry)
|
||||
await persistNewNote(resolved.entry.path, resolved.content)
|
||||
return resolved.entry
|
||||
}, [addEntry])
|
||||
|
||||
const fmCallbacks = { updateTab: updateTabContent, updateEntry, toast: setToastMessage }
|
||||
|
||||
const runFrontmatterOp = useCallback(
|
||||
@@ -426,6 +434,7 @@ export function useNoteActions(config: NoteActionsConfig) {
|
||||
handleCreateNoteImmediate,
|
||||
handleOpenDailyNote,
|
||||
handleCreateType,
|
||||
createTypeEntrySilent,
|
||||
handleUpdateFrontmatter: useCallback((path: string, key: string, value: FrontmatterValue) => runFrontmatterOp('update', path, key, value), [runFrontmatterOp]),
|
||||
handleDeleteProperty: useCallback((path: string, key: string) => runFrontmatterOp('delete', path, key), [runFrontmatterOp]),
|
||||
handleAddProperty: useCallback((path: string, key: string, value: FrontmatterValue) => runFrontmatterOp('update', path, key, value), [runFrontmatterOp]),
|
||||
|
||||
Reference in New Issue
Block a user