Post React Query migration improvements#802
Closed
arbrandes wants to merge 23 commits intoopenedx:frontend-basefrom
Closed
Post React Query migration improvements#802arbrandes wants to merge 23 commits intoopenedx:frontend-basefrom
arbrandes wants to merge 23 commits intoopenedx:frontend-basefrom
Conversation
Co-authored-by: Adolfo R. Brandes <adolfo@axim.org>
Co-authored-by: Deborah Kaplan <deborahgu@users.noreply.github.com> Co-authored-by: Adolfo R. Brandes <adolfo@axim.org>
…extra repositories (openedx#752) Co-authored-by: Adolfo R. Brandes <adolfo@axim.org>
Co-authored-by: Adolfo R. Brandes <adolfo@axim.org>
Co-authored-by: Adolfo R. Brandes <adolfo@axim.org>
Co-authored-by: Adolfo R. Brandes <adolfo@axim.org>
Use 'test' string literal instead of EnvironmentTypes.TEST and import only the type to avoid circular dependency when mocking @openedx/frontend-base itself. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## frontend-base #802 +/- ##
================================================
Coverage ? 90.33%
================================================
Files ? 152
Lines ? 1283
Branches ? 266
================================================
Hits ? 1159
Misses ? 119
Partials ? 5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Remove all Redux files and packages. Add React Query hooks, Context providers, typed API layer, data transformers, and tests. Migrate all components including CourseCard, CourseCardBanners, CourseFilterControls, CoursesPanel, Dashboard, modals, and remaining widgets. Reconcile masquerade implementations with frontend-base providers.ts architecture. Co-Authored-By: Jacobo Dominguez <jacobo.dominguez@wgu.edu> Co-Authored-By: Claude <noreply@anthropic.com>
useInitializeLearnerHome() is consumed by 15+ components, and with staleTime defaulting to 0, every mount and window focus triggered a redundant background refetch. Set staleTime to 5 minutes since dashboard data rarely changes while the user is viewing it. Co-Authored-By: Claude <noreply@anthropic.com>
The useUnenrollFromCourse mutation already calls invalidateQueries on success, which triggers a refetch automatically. The manual refetch() call in closeAndRefresh caused the API to be called twice. Co-Authored-By: Claude <noreply@anthropic.com>
The fallback enrollment date was frozen when the module first loaded. If the app stayed open across midnight, courses with null lastEnrolled would get a stale timestamp. Co-Authored-By: Claude <noreply@anthropic.com>
Previously, modals closed immediately after firing mutations via mutate(), giving no feedback on failure. Now the close action is passed as an onSuccess callback so the modal stays open if the mutation fails. Co-Authored-By: Claude <noreply@anthropic.com>
Auto-fixed stylistic issues (indentation, semicolons, brace style, type→interface, Array<T>→T[]) and manually fixed display-name errors (named wrapper functions), @ts-ignore→@ts-expect-error, and Function→explicit signature. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Convert GlobalDataContext.jsx to .tsx with proper interface so setEmailConfirmation and setPlatformSettings are typed as Dispatch<SetStateAction<T>> | null instead of literal null. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The tsconfig declares "types": ["jest"] but @types/jest was not installed, so TypeScript treated jest as a namespace rather than a value. Adding the matching type definitions lets the webpack type-checker process test files without errors. Also bump frontend-base to fix the @src alias in jest config. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Previously, each useCourseData(cardId) call independently transformed the full course list via getTransformedCourseDataList just to find one item. With N course cards, this ran N times per render cycle. Now the transformation runs once in the queryFn, stored as coursesByCardId on the cached data. useCourseData does an O(1) lookup and CoursesPanel reads directly from the pre-transformed data. Co-Authored-By: Claude <noreply@anthropic.com>
The masquerade fallback data was maintained in a separate context provider, duplicating what React Query already caches. Now when masquerading fails, the normal user's data is read directly from the query cache via queryClient.getQueryData(). This eliminates BackedDataProvider and its associated useEffect sync. Co-Authored-By: Claude <noreply@anthropic.com>
Mutations were invalidating with initialize() which produces a key with trailing undefined, relying on React Query implementation details for prefix matching. Added initializeBase() that produces a clean prefix key ['learner-dashboard', 'initialize'] for unambiguous invalidation of all initialize queries regardless of masquerade user. Co-Authored-By: Claude <noreply@anthropic.com>
769494c to
276b45f
Compare
… errors Client errors (4xx) won't resolve on retry, so skip them. Server errors (5xx) and network failures get up to 3 retries with React Query's default exponential backoff. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Split learnerDashboardQueryKeys into distinct query and mutation key factories for clearer semantics. Mutation keys now live in learnerDashboardMutationKeys while query invalidation still uses learnerDashboardQueryKeys. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
MasqueradeProvider and FiltersProvider used useReducer with action type enums for what are simple value states. Replaced with useState for less boilerplate while preserving the same public API. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verifies the basic flow: API is called without masquerade user, data is returned with coursesByCardId transformation applied. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
276b45f to
1f109e1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up improvements to the ports from master (including but not limited to the big React Query migration) in #801: