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

Function load

apps/desktop/src/renderer/export-window.tsx:231–267  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

229 let cancelled = false
230
231 const load = async (): Promise<void> => {
232 try {
233 const [vault, notes, assetFiles, noteContent] = await Promise.all([
234 window.zen.getCurrentVault(),
235 window.zen.listNotes(),
236 window.zen.listAssets(),
237 window.zen.readNote(notePath)
238 ])
239 if (cancelled) return
240 if (!vault) {
241 throw new Error('No active vault was available for PDF export.')
242 }
243
244 // A custom theme's CSS lives on disk, not in index.css — inject it (and
245 // finalize its light/dark mode) before rendering so printToPDF captures
246 // the themed styles. Built-ins and the light default are already applied.
247 if (prefs.pdfExportUseTheme && isCustomThemeId(prefs.themeId)) {
248 await applyCustomExportTheme(prefs)
249 if (cancelled) return
250 }
251
252 useStore.setState({
253 vault: vault as VaultInfo,
254 notes: notes as NoteMeta[],
255 assetFiles: assetFiles as AssetMeta[],
256 selectedPath: noteContent.path,
257 activeNote: noteContent
258 })
259 document.title = noteContent.title
260 setNote(noteContent)
261 } catch (err) {
262 if (cancelled) return
263 const message = err instanceof Error ? err.message : String(err)
264 setError(message)
265 setExportState('error', message)
266 }
267 }
268
269 void load()
270

Callers 1

ExportNoteWindowFunction · 0.70

Calls 7

isCustomThemeIdFunction · 0.90
applyCustomExportThemeFunction · 0.85
setExportStateFunction · 0.85
getCurrentVaultMethod · 0.65
listNotesMethod · 0.65
listAssetsMethod · 0.65
readNoteMethod · 0.65

Tested by

no test coverage detected