Skip to content

Simplify refresh handling by removing DataContext fetch abstraction#165

Open
hemannt003 wants to merge 1 commit intoc2siorg:mainfrom
hemannt003:gdb02
Open

Simplify refresh handling by removing DataContext fetch abstraction#165
hemannt003 wants to merge 1 commit intoc2siorg:mainfrom
hemannt003:gdb02

Conversation

@hemannt003
Copy link
Copy Markdown

Fixws issue #163

Description

This PR removes misleading refresh logic from DataContext and makes refresh-triggered API fetching local to each consumer component.

What changed

  • Removed fetchData from DataContext (it did not fetch anything and only reset refresh).

  • Removed useEffect/useCallback in DataContext that were tied to that function.

  • Kept refresh and setRefresh as the shared signal mechanism.

  • Updated refresh consumers to own their own refresh fetch logic:
    - Stack
    - BreakPoints
    - Functions
    - MemoryMap

  • Standardized each component to:

  • early-return when refresh is false

  • perform existing API call locally

  • reset refresh in finally to avoid stuck refresh state

  • Removed dead/unused imports related to the old abstraction.

Additional context

  • UI behavior is unchanged: Save/refresh still triggers data reloads.
  • This reduces unnecessary indirection and avoids the impression that DataContext is responsible for data fetching.
  • Added safe reset behavior (setRefresh(prev => prev ? false : prev)) to prevent conflicts when multiple components complete around the same time.

…owns fake fetch logic, and each data panel now fetches locally when refresh is triggered.

What changed
In webapp/src/context/DataContext.jsx:

Removed the context-level fetchData function entirely.
Removed useCallback/useEffect tied to that function.
Removed now-dead helper runCommandInTerminal.
Kept refresh + setRefresh as shared signal state (along with existing app state already used elsewhere, to avoid UI regressions).
In refresh-driven components:

webapp/src/components/Stack/Stack.jsx
webapp/src/components/GdbComponents/BreakPoints/BreakPoints.jsx
webapp/src/components/Functions/Functions.jsx
webapp/src/components/GdbComponents/MemoryMap/MemoryMap.jsx
Each now follows the same pattern:

Guard early: if (!refresh) return;
Run API call in local fetchData inside useEffect.
Keep existing API endpoint/state updates.
Reset refresh in finally with a safe functional guard:
setRefresh((prev) => (prev ? false : prev));
Cleanup:

Removed unused useState import in BreakPoints.
Behavior and safety
No central fake fetch/reset abstraction remains.
Refresh-triggered data loading still works from each component.
No infinite loop introduced (useEffect exits when refresh is false).
Added safe reset guard so multiple components trying to reset won’t conflict.
@hemannt003
Copy link
Copy Markdown
Author

Hi @Shubh942 Could you please review the PR whenever you get time and let me know for any changes to be made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant