fix: avoid note-window vault scans
This commit is contained in:
@@ -132,7 +132,13 @@ const relatedEntry = makeEntry({
|
|||||||
title: 'Software Development',
|
title: 'Software Development',
|
||||||
isA: 'Topic',
|
isA: 'Topic',
|
||||||
})
|
})
|
||||||
const entries = [activeEntry, relatedEntry]
|
const secondEntry = makeEntry({
|
||||||
|
path: '/vault/project/second.md',
|
||||||
|
filename: 'second.md',
|
||||||
|
title: 'Second Project',
|
||||||
|
isA: 'Project',
|
||||||
|
})
|
||||||
|
const entries = [activeEntry, relatedEntry, secondEntry]
|
||||||
const noteContent = '---\ntitle: Test Project\ntype: Project\n---\n\n# Test Project\n'
|
const noteContent = '---\ntitle: Test Project\ntype: Project\n---\n\n# Test Project\n'
|
||||||
const defaultVaultPath = DEFAULT_VAULTS[0].path || '/Users/mock/Documents/Getting Started'
|
const defaultVaultPath = DEFAULT_VAULTS[0].path || '/Users/mock/Documents/Getting Started'
|
||||||
|
|
||||||
@@ -215,7 +221,7 @@ describe('App note windows', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('passes the loaded vault index to the editor in note windows', async () => {
|
it('keeps note windows scoped to the active entry without loading the vault index', async () => {
|
||||||
renderApp(<App />)
|
renderApp(<App />)
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
@@ -224,18 +230,44 @@ describe('App note windows', () => {
|
|||||||
vaultPath: '/vault',
|
vaultPath: '/vault',
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
await waitFor(() => {
|
expect(commandResults.list_vault).not.toHaveBeenCalled()
|
||||||
expect(commandResults.list_vault).toHaveBeenCalledWith({ path: '/vault' })
|
|
||||||
})
|
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(screen.getByTestId('mock-editor-entry-titles')).toHaveTextContent(
|
expect(screen.getByTestId('mock-editor-entry-titles')).toHaveTextContent(
|
||||||
'Test Project|Software Development',
|
'Test Project',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
expect(editorSnapshots.at(-1)).toEqual({
|
expect(editorSnapshots.at(-1)).toEqual({
|
||||||
activeTabPath: activeEntry.path,
|
activeTabPath: activeEntry.path,
|
||||||
entryTitles: ['Test Project', 'Software Development'],
|
entryTitles: ['Test Project'],
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('opens repeated note windows without repeated full-vault scans', async () => {
|
||||||
|
const firstWindow = renderApp(<App />)
|
||||||
|
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(commandResults.reload_vault_entry).toHaveBeenCalledWith({
|
||||||
|
path: activeEntry.path,
|
||||||
|
vaultPath: '/vault',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
firstWindow.unmount()
|
||||||
|
|
||||||
|
window.history.replaceState(
|
||||||
|
{},
|
||||||
|
'',
|
||||||
|
'/?window=note&path=%2Fvault%2Fproject%2Fsecond.md&vault=%2Fvault&title=Second+Project',
|
||||||
|
)
|
||||||
|
renderApp(<App />)
|
||||||
|
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(commandResults.reload_vault_entry).toHaveBeenCalledWith({
|
||||||
|
path: secondEntry.path,
|
||||||
|
vaultPath: '/vault',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(commandResults.reload_vault_entry).toHaveBeenCalledTimes(2)
|
||||||
|
expect(commandResults.list_vault).not.toHaveBeenCalled()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -576,7 +576,7 @@ describe('App', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('opens a note window by loading the requested entry and vault index', async () => {
|
it('opens a note window by loading only the requested entry', async () => {
|
||||||
const listVault = vi.fn(() => mockEntries)
|
const listVault = vi.fn(() => mockEntries)
|
||||||
const reloadVaultEntry = vi.fn(({ path }: { path: string }) =>
|
const reloadVaultEntry = vi.fn(({ path }: { path: string }) =>
|
||||||
mockEntries.find((entry) => entry.path === path) ?? null,
|
mockEntries.find((entry) => entry.path === path) ?? null,
|
||||||
@@ -599,7 +599,7 @@ describe('App', () => {
|
|||||||
expect(getNoteContent).toHaveBeenCalledWith({ path: '/vault/project/test.md', vaultPath: '/vault' })
|
expect(getNoteContent).toHaveBeenCalledWith({ path: '/vault/project/test.md', vaultPath: '/vault' })
|
||||||
await waitFor(() => expect(window.__laputaTest?.activeTabPath).toBe('/vault/project/test.md'))
|
await waitFor(() => expect(window.__laputaTest?.activeTabPath).toBe('/vault/project/test.md'))
|
||||||
expect(screen.getByTestId('blocknote-view')).toHaveAttribute('data-editable', 'true')
|
expect(screen.getByTestId('blocknote-view')).toHaveAttribute('data-editable', 'true')
|
||||||
expect(listVault).toHaveBeenCalledWith({ path: '/vault' })
|
expect(listVault).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows keyboard shortcut hints', async () => {
|
it('shows keyboard shortcut hints', async () => {
|
||||||
|
|||||||
@@ -368,7 +368,7 @@ function App() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const vault = useVaultLoader(
|
const vault = useVaultLoader(
|
||||||
resolvedPath,
|
noteWindowParams ? '' : resolvedPath,
|
||||||
graphVaults,
|
graphVaults,
|
||||||
multiWorkspaceEnabled ? defaultWorkspacePath : null,
|
multiWorkspaceEnabled ? defaultWorkspacePath : null,
|
||||||
folderVaults,
|
folderVaults,
|
||||||
@@ -1687,7 +1687,7 @@ function App() {
|
|||||||
tabs={notes.tabs}
|
tabs={notes.tabs}
|
||||||
activeTabPath={notes.activeTabPath}
|
activeTabPath={notes.activeTabPath}
|
||||||
isVaultLoading={isVaultContentLoading}
|
isVaultLoading={isVaultContentLoading}
|
||||||
entries={visibleEntries}
|
entries={noteWindowParams && activeTab ? [activeTab.entry] : visibleEntries}
|
||||||
onNavigateWikilink={notes.handleNavigateWikilink}
|
onNavigateWikilink={notes.handleNavigateWikilink}
|
||||||
onLoadDiff={loadDiffForPath}
|
onLoadDiff={loadDiffForPath}
|
||||||
onLoadDiffAtCommit={loadDiffAtCommitForPath}
|
onLoadDiffAtCommit={loadDiffAtCommitForPath}
|
||||||
|
|||||||
Reference in New Issue
Block a user