diff --git a/src/App.tsx b/src/App.tsx
index 992dd283..759af138 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -500,7 +500,7 @@ function App() {
{sidebarVisible && (
<>
-
+
>
diff --git a/src/hooks/useEntryActions.test.ts b/src/hooks/useEntryActions.test.ts
index da4b863e..bf82b312 100644
--- a/src/hooks/useEntryActions.test.ts
+++ b/src/hooks/useEntryActions.test.ts
@@ -289,4 +289,42 @@ describe('useEntryActions', () => {
expect(updateEntry).not.toHaveBeenCalled()
})
})
+
+ describe('handleToggleTypeVisibility', () => {
+ it('sets visible to false when currently visible (null/default)', async () => {
+ const typeEntry = makeEntry({ isA: 'Type', title: 'Journal', path: '/vault/type/journal.md', visible: null })
+ const { result } = setup([typeEntry])
+
+ await act(async () => {
+ await result.current.handleToggleTypeVisibility('Journal')
+ })
+
+ expect(handleUpdateFrontmatter).toHaveBeenCalledWith('/vault/type/journal.md', 'visible', false)
+ expect(updateEntry).toHaveBeenCalledWith('/vault/type/journal.md', { visible: false })
+ })
+
+ it('sets visible to true (deletes property) when currently hidden', async () => {
+ const typeEntry = makeEntry({ isA: 'Type', title: 'Journal', path: '/vault/type/journal.md', visible: false })
+ const { result } = setup([typeEntry])
+
+ await act(async () => {
+ await result.current.handleToggleTypeVisibility('Journal')
+ })
+
+ expect(handleDeleteProperty).toHaveBeenCalledWith('/vault/type/journal.md', 'visible')
+ expect(updateEntry).toHaveBeenCalledWith('/vault/type/journal.md', { visible: null })
+ })
+
+ it('auto-creates type entry when not found', async () => {
+ const { result } = setup([])
+
+ await act(async () => {
+ await result.current.handleToggleTypeVisibility('Journal')
+ })
+
+ expect(createTypeEntry).toHaveBeenCalledWith('Journal')
+ expect(handleUpdateFrontmatter).toHaveBeenCalledWith('/vault/type/journal.md', 'visible', false)
+ expect(updateEntry).toHaveBeenCalledWith('/vault/type/journal.md', { visible: false })
+ })
+ })
})
diff --git a/src/hooks/useEntryActions.ts b/src/hooks/useEntryActions.ts
index b91572d4..0d8efa20 100644
--- a/src/hooks/useEntryActions.ts
+++ b/src/hooks/useEntryActions.ts
@@ -80,5 +80,17 @@ export function useEntryActions({
}
}, [entries, handleUpdateFrontmatter, handleDeleteProperty, updateEntry])
- return { handleTrashNote, handleRestoreNote, handleArchiveNote, handleUnarchiveNote, handleCustomizeType, handleReorderSections, handleUpdateTypeTemplate, handleRenameSection }
+ const handleToggleTypeVisibility = useCallback(async (typeName: string) => {
+ let typeEntry = findTypeEntry(entries, typeName)
+ if (!typeEntry) typeEntry = await createTypeEntry(typeName)
+ if (typeEntry.visible === false) {
+ updateEntry(typeEntry.path, { visible: null })
+ await handleDeleteProperty(typeEntry.path, 'visible')
+ } else {
+ updateEntry(typeEntry.path, { visible: false })
+ await handleUpdateFrontmatter(typeEntry.path, 'visible', false)
+ }
+ }, [entries, handleUpdateFrontmatter, handleDeleteProperty, updateEntry, createTypeEntry])
+
+ return { handleTrashNote, handleRestoreNote, handleArchiveNote, handleUnarchiveNote, handleCustomizeType, handleReorderSections, handleUpdateTypeTemplate, handleRenameSection, handleToggleTypeVisibility }
}