File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -118,8 +118,19 @@ export function useNotes() {
118118 foldersResponse . total / foldersResponse . limit
119119 ) ;
120120 hasMorePages = page < totalPages ;
121+
122+ // Also check if we received fewer folders than the limit, which means we're on the last page
123+ if ( convertedFolders . length < foldersResponse . limit ) {
124+ hasMorePages = false ;
125+ }
126+
121127 page ++ ;
122128
129+ // Safety break to prevent infinite loops
130+ if ( page > 50 ) {
131+ hasMorePages = false ;
132+ }
133+
123134 // Add small delay between requests to avoid rate limiting
124135 if ( hasMorePages ) {
125136 await new Promise ( ( resolve ) => setTimeout ( resolve , 100 ) ) ;
@@ -220,8 +231,19 @@ export function useNotes() {
220231 // Check if we have more pages
221232 const totalPages = Math . ceil ( notesResponse . total / notesResponse . limit ) ;
222233 hasMorePages = page < totalPages ;
234+
235+ // Also check if we received fewer notes than the limit, which means we're on the last page
236+ if ( convertedNotes . length < notesResponse . limit ) {
237+ hasMorePages = false ;
238+ }
239+
223240 page ++ ;
224241
242+ // Safety break to prevent infinite loops
243+ if ( page > 50 ) {
244+ hasMorePages = false ;
245+ }
246+
225247 // Add small delay between requests to avoid rate limiting
226248 if ( hasMorePages ) {
227249 await new Promise ( ( resolve ) => setTimeout ( resolve , 100 ) ) ;
You can’t perform that action at this time.
0 commit comments