Skip to content

Commit 7680bb8

Browse files
committed
fix: Return full note metadata for pruned notes in paginated API
When no cursor is provided (last chunk or full refresh), the API was returning pruned notes with only the 'id' field, missing title, category, and other metadata. This caused Vue components to render "undefined" for all note titles after pagination. Fixed by using getNoteData() to return full metadata while still respecting the 'exclude' parameter. Also updated frontend to correctly read cursor from response headers instead of response body.
1 parent 0b24ad3 commit 7680bb8

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

lib/Controller/NotesApiController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ public function index(
7878
$data = $this->helper->getNotesAndCategories($pruneBefore, $exclude, $category, $chunkSize, $chunkCursor);
7979
$notesData = $data['notesData'];
8080
if (!$data['chunkCursor']) {
81-
// if last chunk, then send all notes (pruned)
82-
$notesData += array_map(function (MetaNote $m) {
83-
return [ 'id' => $m->note->getId() ];
81+
// if last chunk, then send all notes (pruned) with full metadata
82+
$notesData += array_map(function (MetaNote $m) use ($exclude) {
83+
return $this->helper->getNoteData($m->note, $exclude, $m->meta);
8484
}, $data['notesAll']);
8585
}
8686
$response = new JSONResponse(array_values($notesData));

src/NotesService.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,19 @@ export const fetchNotes = async (chunkSize = 50, chunkCursor = null) => {
115115

116116
console.log('[fetchNotes] Response received, status:', response.status)
117117
console.log('[fetchNotes] Response data type:', Array.isArray(response.data) ? 'array' : typeof response.data)
118-
console.log('[fetchNotes] Response data keys:', Object.keys(response.data || {}))
118+
console.log('[fetchNotes] Response headers:', response.headers)
119119

120-
const data = response.data
121-
const notes = data.notes || []
122-
const noteIds = data.noteIds || notes.map(note => note.id)
123-
const nextCursor = data.chunkCursor || null
120+
// Backend returns array of notes directly
121+
const notes = Array.isArray(response.data) ? response.data : []
122+
const noteIds = notes.map(note => note.id)
123+
124+
// Cursor is in response headers, not body
125+
const nextCursor = response.headers['x-notes-chunk-cursor'] || null
126+
const pendingCount = response.headers['x-notes-chunk-pending'] ? parseInt(response.headers['x-notes-chunk-pending']) : 0
124127
const isLastChunk = !nextCursor
125128

126-
console.log('[fetchNotes] Processed:', notes.length, 'notes, noteIds:', noteIds.length, 'nextCursor:', nextCursor, 'isLastChunk:', isLastChunk)
129+
console.log('[fetchNotes] Processed:', notes.length, 'notes, noteIds:', noteIds.length)
130+
console.log('[fetchNotes] Cursor:', nextCursor, 'Pending:', pendingCount, 'isLastChunk:', isLastChunk)
127131

128132
// Update notes incrementally
129133
if (chunkCursor) {

0 commit comments

Comments
 (0)