Skip to content

refactor: use loading property from useQuery instead of loading state (#3135) - #3200

Closed
eyad-hazem wants to merge 1 commit into
OWASP:mainfrom
eyad-hazem:feature/refactor-usequery-loading
Closed

eyad-hazem wants to merge 1 commit into
OWASP:mainfrom
eyad-hazem:feature/refactor-usequery-loading

Conversation

@eyad-hazem

Copy link
Copy Markdown
Contributor

STOP AND READ BEFORE SUBMITTING! REMOVE THIS PARAGRAPH BEFORE OPENING THE PR

Thank you for your interest in contributing to OWASP Nest!

Before starting any work, all external contributors must first be assigned to an issue in the repository.
This is a mandatory step in the OWASP Nest workflow and ensures that effort is coordinated, approved, and tracked properly.

Exception: OWASP leaders are not required to follow this rule —- just make sure your username is included in the exception list.

If you were not assigned to the issue you are trying to resolve, stop right now and do NOT create this PR.
Unassigned pull requests are automatically closed by our workflows — please don't waste your time.

If you want to be assigned on any available issue, comment on it and wait for confirmation from the maintainers or project leads.

Proposed change

Resolves #(put the issue number here)

Add the PR description here.

Checklist

  • Required: I read and followed the contributing guidelines
  • Required: I ran make check-test locally and all tests passed
  • I used AI for code, documentation, or tests in this PR

@coderabbitai

coderabbitai Bot commented Jan 5, 2026 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Summary by CodeRabbit

  • Refactor
    • Optimized internal state management patterns across multiple components for improved code maintainability and reduced complexity.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

This PR consolidates loading state management across 13 frontend pages by removing local isLoading state and using Apollo Client's built-in loading flag from useQuery hooks. Most changes eliminate manual state toggling; some files also refactor data derivation to flow directly from GraphQL responses.

Changes

Cohort / File(s) Summary
Loading state replacement
frontend/src/app/committees/[committeeKey]/page.tsx, frontend/src/app/community/snapshots/[id]/page.tsx, frontend/src/app/community/snapshots/page.tsx, frontend/src/app/members/[memberKey]/page.tsx, frontend/src/app/mentorship/programs/[programKey]/modules/[moduleKey]/page.tsx, frontend/src/app/my/mentorship/programs/.../mentees/[menteeKey]/page.tsx, frontend/src/app/my/mentorship/programs/[programKey]/modules/[moduleKey]/page.tsx, frontend/src/app/organizations/[organizationKey]/repositories/[repositoryKey]/page.tsx, frontend/src/app/projects/[projectKey]/page.tsx, frontend/src/app/projects/dashboard/page.tsx
Removes local isLoading state and setIsLoading calls; aliases loading as isLoading from useQuery to drive LoadingSpinner rendering. Eliminates manual state updates in data/error handlers.
Data-driven refactoring
frontend/src/app/chapters/[chapterKey]/page.tsx
Derives chapter and topContributors directly from graphQLData via optional chaining instead of state; simplifies effect dependencies to only graphQLRequestError and chapterKey.
Complex state consolidation
frontend/src/app/organizations/[organizationKey]/page.tsx
Removes multiple local state variables (organization, issues, milestones, pullRequests, releases, repositories, topContributors, isLoading); extracts all entities directly from graphQLData; adjusts conditional rendering logic and updates data formatting (wraps followersCount in String(...)).
Home page refactoring
frontend/src/app/page.tsx
Removes local data state and replaces with direct graphQLData reference; eliminates effect that mirrored data into state; updates loading condition to rely on isLoading and presence of graphQLData.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

frontend

Suggested reviewers

  • kasya
  • arkid15r
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f3e017d and 4507b56.

📒 Files selected for processing (13)
  • frontend/src/app/chapters/[chapterKey]/page.tsx
  • frontend/src/app/committees/[committeeKey]/page.tsx
  • frontend/src/app/community/snapshots/[id]/page.tsx
  • frontend/src/app/community/snapshots/page.tsx
  • frontend/src/app/members/[memberKey]/page.tsx
  • frontend/src/app/mentorship/programs/[programKey]/modules/[moduleKey]/page.tsx
  • frontend/src/app/my/mentorship/programs/[programKey]/modules/[moduleKey]/mentees/[menteeKey]/page.tsx
  • frontend/src/app/my/mentorship/programs/[programKey]/modules/[moduleKey]/page.tsx
  • frontend/src/app/organizations/[organizationKey]/page.tsx
  • frontend/src/app/organizations/[organizationKey]/repositories/[repositoryKey]/page.tsx
  • frontend/src/app/page.tsx
  • frontend/src/app/projects/[projectKey]/page.tsx
  • frontend/src/app/projects/dashboard/page.tsx

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jan 5, 2026

Copy link
Copy Markdown

PR validation failed: No linked issue and no valid closing issue reference in PR description

@github-actions github-actions Bot closed this Jan 5, 2026
@sonarqubecloud

sonarqubecloud Bot commented Jan 5, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
11.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant