Repository navigation
fix: show error widget when content fails to load #84 - #651
AzazelSensei wants to merge 1 commit into
Conversation
API screens now show CVException instead of an empty view when a fetch fails.
❌ Deploy Preview for cv-mobile-app-web failed.
|
WalkthroughAdded the public Merge Risk: 🟡 Moderate · up to Failed network loads now display error states, but some screens can still show stale or unrelated content, and the affected test currently expects a single error while producing two. The PR is not merge-ready until these bounded rendering and test issues are corrected. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Linked Issues checkExplanation The changes satisfy issue Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (12 skipped: 12 unsupported.) ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Team
Run ID: d91aa05b-bc3b-4e48-aed2-8c9e27e396e7
📒 Files selected for processing (12)
lib/ui/components/cv_exception.dartlib/ui/views/groups/assignment_details_view.dartlib/ui/views/groups/group_details_view.dartlib/ui/views/groups/my_groups_view.dartlib/ui/views/ib/ib_landing_view.dartlib/ui/views/notifications/notifications_view.dartlib/ui/views/profile/user_favourites_view.dartlib/ui/views/profile/user_projects_view.dartlib/ui/views/projects/featured_projects_view.dartlib/ui/views/projects/project_details_view.darttest/ui_tests/components/cv_exception_test.darttest/ui_tests/projects/featured_projects_view_test.dart
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.
| if (_model.isError(_model.FETCH_GROUP_DETAILS)) { | ||
| _items.add( | ||
| CVException( | ||
| _model.errorMessageFor(_model.FETCH_GROUP_DETAILS), | ||
| ), | ||
| ); | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Render the fetch error before the empty group sections.
When FETCH_GROUP_DETAILS fails, _items already contains the group header, three section headers, and their spacers. The new CVException is therefore below the initial content, while the screen can show empty sections instead of the error. Build the error-state content before adding the fetched-data sections.
| if (model.isError(model.FETCH_FEATURED_PROJECTS)) { | ||
| _items.add( | ||
| CVException(model.errorMessageFor(model.FETCH_FEATURED_PROJECTS)), | ||
| ); | ||
| _projects = _items; | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Make the active request error state exclusive.
When featured loading has already succeeded, model.isSuccess(model.FETCH_FEATURED_PROJECTS) remains true. If the first search then fails, FeaturedProjectsViewModel.searchProjects leaves _showSearchedResult false, so model.projects still returns the featured projects. The success block adds those unrelated cards before this branch adds the search error.
A stale featured error can also remain after a successful search. Render the active request as an exclusive loading, success, or error state, and reset the inactive request status when switching modes.
Also applies to: 111-114
| when(model.SEARCH_PROJECTS).thenAnswer((_) => 'search_projects'); | ||
| when(model.isBusy(any)).thenAnswer((_) => false); | ||
| when(model.isSuccess(any)).thenAnswer((_) => false); | ||
| when(model.isError(any)).thenAnswer((_) => true); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Limit the error stub to the featured-project request.
when(model.isError(any)).thenAnswer((_) => true) marks both FETCH_FEATURED_PROJECTS and SEARCH_PROJECTS as errors. The two independent branches in lib/ui/views/projects/featured_projects_view.dart then add two CVException widgets, so find.byType(CVException), findsOneWidget fails.
Stub FETCH_FEATURED_PROJECTS as true and SEARCH_PROJECTS as false.
Proposed test fix
- when(model.isError(any)).thenAnswer((_) => true);
+ when(
+ model.isError(model.FETCH_FEATURED_PROJECTS),
+ ).thenAnswer((_) => true);
+ when(
+ model.isError(model.SEARCH_PROJECTS),
+ ).thenAnswer((_) => false);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| when(model.isError(any)).thenAnswer((_) => true); | |
| when( | |
| model.isError(model.FETCH_FEATURED_PROJECTS), | |
| ).thenAnswer((_) => true); | |
| when( | |
| model.isError(model.SEARCH_PROJECTS), | |
| ).thenAnswer((_) => false); |
Fixes #84
Describe the changes you have made in this PR -
Added a CVException widget and wired it into the screens that fetch over the network. When a load fails (no internet, API error, etc.) those views now show the error message instead of looking empty.
Screenshots of the changes (If any) -
Note: Please check Allow edits from maintainers. if you would like us to assist in the PR.
Summary by CodeRabbit
New Features
Bug Fixes
Tests