MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / scheduleSearchPaletteModuleWarmup

Function scheduleSearchPaletteModuleWarmup

packages/app-core/src/App.tsx:71–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

69}
70
71function scheduleSearchPaletteModuleWarmup(): () => void {
72 let cancelled = false
73 let delayId: number | null = null
74 let frameId: number | null = null
75 let idleId: number | null = null
76
77 const warmup = (): void => {
78 if (!cancelled) void loadSearchPaletteModule()
79 }
80
81 delayId = window.setTimeout(() => {
82 delayId = null
83 if (typeof window.requestIdleCallback === 'function') {
84 idleId = window.requestIdleCallback(
85 () => {
86 idleId = null
87 warmup()
88 },
89 { timeout: 300 }
90 )
91 return
92 }
93 frameId = window.requestAnimationFrame(() => {
94 frameId = null
95 warmup()
96 })
97 }, SEARCH_PALETTE_MODULE_WARMUP_DELAY_MS)
98
99 return () => {
100 cancelled = true
101 if (delayId !== null) window.clearTimeout(delayId)
102 if (frameId !== null) window.cancelAnimationFrame(frameId)
103 if (idleId !== null && typeof window.cancelIdleCallback === 'function') {
104 window.cancelIdleCallback(idleId)
105 }
106 }
107}
108
109function isUndoShortcut(e: KeyboardEvent): boolean {
110 return (

Callers 1

AppFunction · 0.85

Calls 1

warmupFunction · 0.85

Tested by

no test coverage detected