Skip to content

fix(departments): don't show empty sections in departments detail view#1121

Merged
odominiak merged 3 commits intomainfrom
1118-fixdepartments-dont-show-empty-sections-in-departments-detail-view
Mar 26, 2026
Merged

fix(departments): don't show empty sections in departments detail view#1121
odominiak merged 3 commits intomainfrom
1118-fixdepartments-dont-show-empty-sections-in-departments-detail-view

Conversation

@odominiak
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@simon-the-shark
Copy link
Copy Markdown
Member

@greptile

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 26, 2026

Greptile Summary

This PR fixes the department detail view so that empty sections (fields of study, science clubs) are no longer displayed when there is no data. It does this by introducing a new departmentDetailService Riverpod provider that combines DepartmentDetails with a pre-filtered IList<ScienceClub> into a DepartmentWithSciClubs named record, which is then used in the view with isNotEmpty guards before rendering each optional section.\n\n- New service layer (department_detail_service.dart): a single @riverpod provider that combines the two existing data sources and filters science clubs by department ID, following the project's named-record, IList, and Riverpod codegen conventions.\n- Simplified presentation (department_detail_view.dart): if (value.department.fieldsOfStudy.isNotEmpty) and if (value.sciclubs.isNotEmpty) guards prevent rendering empty sections.\n- Simplified DepartmentScienceClubsSection: the widget no longer owns its own async data loading; it now receives pre-fetched data, eliminating the inline AsyncError/AsyncLoading states and the duplicate filtering logic that was previously duplicated between the widget and the repository layer.

Confidence Score: 5/5

Safe to merge — clean, focused fix with no logic errors or rule violations.

The change is well-scoped: a new service layer absorbs filtering logic, the view adds simple isEmpty guards, and the child widget is simplified. All project conventions (IList, named records, Riverpod codegen, no StatefulWidget) are respected. No critical bugs, security issues, or regressions were found.

No files require special attention.

Important Files Changed

Filename Overview
lib/features/departments/department_detail_view/business/department_detail_service.dart New service layer that combines DepartmentDetails with filtered ScienceClubs into a DepartmentWithSciClubs named record; follows IList, Riverpod codegen, and named-record conventions.
lib/features/departments/department_detail_view/presentation/department_detail_view.dart Switched to departmentDetailServiceProvider and added isNotEmpty guards to conditionally render the fields-of-study and science-clubs sections.
lib/features/departments/department_detail_view/presentation/widgets/science_clubs_section.dart Simplified by removing its own async provider watch; now receives pre-filtered DepartmentWithSciClubs from the parent and renders synchronously.

Sequence Diagram

sequenceDiagram
    participant View as DepartmentDetailView
    participant Svc as departmentDetailServiceProvider
    participant DRepo as departmentDetailsRepositoryProvider
    participant SCRepo as scienceClubsRepositoryProvider

    View->>Svc: watch(id)
    Svc->>DRepo: watch(id).future
    DRepo-->>Svc: DepartmentDetails
    Svc->>SCRepo: watch().future
    SCRepo-->>Svc: IList of ScienceClub
    Svc->>Svc: filter sciclubs where department.id == id
    Svc-->>View: DepartmentWithSciClubs
    View->>View: if fieldsOfStudy.isNotEmpty show FieldsOfStudySection
    View->>View: if sciclubs.isNotEmpty show DepartmentScienceClubsSection
Loading

Reviews (3): Last reviewed commit: "refactor(departments): introduce service..." | Re-trigger Greptile

@simon-the-shark
Copy link
Copy Markdown
Member

@greptile

@odominiak odominiak enabled auto-merge (squash) March 26, 2026 20:01
@odominiak odominiak merged commit af64cbe into main Mar 26, 2026
8 checks passed
@odominiak odominiak deleted the 1118-fixdepartments-dont-show-empty-sections-in-departments-detail-view branch March 26, 2026 20:13
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.

fix(departments): don't show empty sections in departments detail view

2 participants