Open
Description
Describe the problem
Pagination must be used when retrieving the sketches. This has been added in #875, but the proposed code does one extra fetch when all sketches have been loaded.
For example, when I have one single sketch, I will see two HTTP GETs:
HTTP GET: https://api-dev.arduino.cc/create/v2/sketches?user_id=me&limit=50&offset=0
HTTP GET: https://api-dev.arduino.cc/create/v2/sketches?user_id=me&limit=50&offset=50
To reproduce
Start IDE 2.0.3, log into the cloud, open dev tools, switch to the network tab, enable XHR/Fetch, reload the browser window, and see the unnecessary fetch with 50 offsets. I have one single sketch.
The second fetch response body is empty.
The other problem is that IDE2 runs the sketches fetch twice, and IDE2 runs the same fetches in every opened browser window.
Expected behavior
There are fewer number of remote fetches to the server.
Arduino IDE version
2.0.3
Operating system
macOS
Operating system version
12.5.1
Additional context
No response
Issue checklist
- I searched for previous reports in the issue tracker
- I verified the problem still occurs when using the latest nightly build
- My report contains all necessary details