@@ -113,14 +113,20 @@ export function useNotes() {
113113 const convertedFolders = foldersResponse . folders . map ( convertApiFolder ) ;
114114 allFolders = [ ...allFolders , ...convertedFolders ] ;
115115
116- // Check if we have more pages
117- const totalPages = Math . ceil (
118- foldersResponse . total / foldersResponse . limit
119- ) ;
120- hasMorePages = page < totalPages ;
116+ // Check if we have more pages - handle different API response structures
117+ if ( foldersResponse . total !== undefined && foldersResponse . limit !== undefined ) {
118+ // Use API total if available
119+ const totalPages = Math . ceil (
120+ foldersResponse . total / foldersResponse . limit
121+ ) ;
122+ hasMorePages = page < totalPages ;
123+ } else {
124+ // Fallback - assume more pages if we got a full page
125+ hasMorePages = convertedFolders . length >= 50 ;
126+ }
121127
122128 // Also check if we received fewer folders than the limit, which means we're on the last page
123- if ( convertedFolders . length < foldersResponse . limit ) {
129+ if ( convertedFolders . length < 50 ) {
124130 hasMorePages = false ;
125131 }
126132
@@ -228,12 +234,18 @@ export function useNotes() {
228234 const convertedNotes = notesResponse . notes . map ( convertApiNote ) ;
229235 allNotes = [ ...allNotes , ...convertedNotes ] ;
230236
231- // Check if we have more pages
232- const totalPages = Math . ceil ( notesResponse . total / notesResponse . limit ) ;
233- hasMorePages = page < totalPages ;
237+ // Check if we have more pages - handle different API response structures
238+ if ( notesResponse . total !== undefined && notesResponse . limit !== undefined ) {
239+ // Use API total if available
240+ const totalPages = Math . ceil ( notesResponse . total / notesResponse . limit ) ;
241+ hasMorePages = page < totalPages ;
242+ } else {
243+ // Fallback - assume more pages if we got a full page
244+ hasMorePages = convertedNotes . length >= 50 ;
245+ }
234246
235247 // Also check if we received fewer notes than the limit, which means we're on the last page
236- if ( convertedNotes . length < notesResponse . limit ) {
248+ if ( convertedNotes . length < 50 ) {
237249 hasMorePages = false ;
238250 }
239251
0 commit comments