feat: fast note open — use allContent cache to skip IPC disk reads
handleSelectNote and handleReplaceActiveTab now check the in-memory allContent cache before issuing a Tauri IPC call. Cache hits open the tab synchronously (zero latency). Cache misses fall back to the disk read and populate allContent via onContentLoaded so subsequent opens of the same note are instant. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -36,6 +36,8 @@ export interface NoteActionsConfig {
|
||||
markContentPending?: (path: string, content: string) => void
|
||||
/** Called after a new note is persisted to disk (e.g. to refresh git status for Changes view). */
|
||||
onNewNotePersisted?: () => void
|
||||
/** Return cached content for a path (from allContent), or undefined on cache miss. */
|
||||
getCachedContent?: (path: string) => string | undefined
|
||||
}
|
||||
|
||||
async function performRename(
|
||||
@@ -326,7 +328,10 @@ async function runFrontmatterAndApply(
|
||||
|
||||
export function useNoteActions(config: NoteActionsConfig) {
|
||||
const { addEntry, removeEntry, updateContent, entries, setToastMessage, updateEntry, addPendingSave, removePendingSave } = config
|
||||
const tabMgmt = useTabManagement()
|
||||
const tabMgmt = useTabManagement({
|
||||
getCachedContent: config.getCachedContent,
|
||||
onContentLoaded: updateContent,
|
||||
})
|
||||
const { setTabs, handleSelectNote, openTabWithContent, handleCloseTab, handleCloseTabRef, activeTabPathRef, handleSwitchTab } = tabMgmt
|
||||
const tabsRef = useRef(tabMgmt.tabs)
|
||||
// eslint-disable-next-line react-hooks/refs
|
||||
|
||||
Reference in New Issue
Block a user