refactor(course-outline): improve query cache handling and remove redux thunks (#2884)

- Centralizes and reuses query cache handling logic:
Introduces a `ParentIds` type (src/generic/types.ts) and standardizes its use across data/API hooks for updating or invalidating parent/child query caches.
- Ensures cache coherence using `cancelQueries` before updating query data:
Before calling `setQueryData` for any block, any inflight queries are cancelled to prevent race conditions and stale UI.
- Simplifies post-sync/invalidation flows:
Removes Redux thunk usages in favor of direct query invalidations using React Query APIs within course outline cards, sidebars, publish modal, and `unlinkmodal`.
- Refactors data types for clarity:
Splits XBlock into `XBlockBase` and derived interfaces so the presence of `childInfo` is explicit.
- Cleans up redundant code and props:
Removes unnecessary `memoization`, `useDispatch` imports, and duplicate logic in React components.
This commit is contained in:
Navin Karkera
2026-02-20 23:40:28 +05:30
committed by GitHub
parent 8f8c6d8dd2
commit ee6006e0e3
16 changed files with 141 additions and 105 deletions

View File

@@ -70,7 +70,7 @@ export interface UpstreamInfo {
isReadyToSyncIndividually?: boolean,
}
export interface XBlock {
export interface XBlockBase {
id: string;
locator: string;
usageKey: string;
@@ -102,7 +102,6 @@ export interface XBlock {
highlightsEnabled: boolean;
highlightsPreviewOnly: boolean;
highlightsDocUrl: string;
childInfo: XblockChildInfo;
ancestorHasStaffLock: boolean;
staffOnlyMessage: boolean;
hasPartitionGroupComponents: boolean;
@@ -127,7 +126,11 @@ export interface XBlock {
upstreamInfo?: UpstreamInfo;
}
export type UnitXBlock = Omit<XBlock, 'childInfo'>;
export interface XBlock extends XBlockBase {
childInfo: XblockChildInfo;
}
export interface UnitXBlock extends XBlockBase {}
interface OutlineError {
data?: string;