|
31 | 31 |
|
32 | 32 | import { goto } from '$app/navigation'; |
33 | 33 | import { WEBUI_NAME, config, prompts as _prompts, user } from '$lib/stores'; |
34 | | - import { createNewNote, deleteNoteById, getNoteList, searchNotes } from '$lib/apis/notes'; |
| 34 | + import { createNewNote, deleteNoteById, getNoteById, getNoteList, searchNotes } from '$lib/apis/notes'; |
35 | 35 | import { capitalizeFirstLetter, copyToClipboard, getTimeRange } from '$lib/utils'; |
36 | 36 | import { downloadPdf, createNoteHandler } from './utils'; |
37 | 37 |
|
|
73 | 73 | let allItemsLoaded = false; |
74 | 74 |
|
75 | 75 | const downloadHandler = async (type) => { |
| 76 | + // Fetch the full note since the list response may not contain full content |
| 77 | + const note = await getNoteById(localStorage.token, selectedNote.id).catch((error) => { |
| 78 | + toast.error(`${error}`); |
| 79 | + return null; |
| 80 | + }); |
| 81 | +
|
| 82 | + if (!note) return; |
| 83 | +
|
76 | 84 | if (type === 'txt') { |
77 | | - const blob = new Blob([selectedNote.data.content.md], { type: 'text/plain' }); |
78 | | - saveAs(blob, `${selectedNote.title}.txt`); |
| 85 | + const blob = new Blob([note.data.content.md], { type: 'text/plain' }); |
| 86 | + saveAs(blob, `${note.title}.txt`); |
79 | 87 | } else if (type === 'md') { |
80 | | - const blob = new Blob([selectedNote.data.content.md], { type: 'text/markdown' }); |
81 | | - saveAs(blob, `${selectedNote.title}.md`); |
| 88 | + const blob = new Blob([note.data.content.md], { type: 'text/markdown' }); |
| 89 | + saveAs(blob, `${note.title}.md`); |
82 | 90 | } else if (type === 'pdf') { |
83 | 91 | try { |
84 | | - await downloadPdf(selectedNote); |
| 92 | + await downloadPdf(note); |
85 | 93 | } catch (error) { |
86 | 94 | toast.error(`${error}`); |
87 | 95 | } |
|
0 commit comments