openedx / frontend-app-authoring

Front-end for the Open edX Studio experience, implemented in React and Paragon.
GNU Affero General Public License v3.0
13 stars 75 forks source link

Excessive calls to the clipboard API endpoint #1304

Open ormsbee opened 1 month ago

ormsbee commented 1 month ago

I have a course outline page for a very large course, and it looks like it's making a call to GET /api/content-staging/v1/clipboard/ for every subsection in the course. This particular course has 82 subsections, so it makes this call 82 times, noticeably slowing down the processing for this page.

bradenmacdonald commented 1 month ago

Yeah, I guess when the frontend was implemented the developers didn't know about react query yet, so they implemented it with Redux. My preferred fix is to update the useCopyToClipboard hook to use react query, which has automatic request deduplication.

I actually tried to do this as a drive-by refactor during a recent PR, but it was non-trivial because of interactions with other components that are also using redux. It's still very doable though.