-
Notifications
You must be signed in to change notification settings - Fork 18
fix: implement offline caching for schedule, exams, and profile (#1714) #1739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1739 +/- ##
=======================================
Coverage 60% 60%
=======================================
Files 2 2
Lines 81 81
=======================================
Hits 48 48
Misses 33 33 🚀 New features to boost your workflow:
|
|
The lecture provider seems to be working, but the following ones return a
|
…background (found issue(not loading))
|
Added the final offline caching fixes for:
Fix for Faculty Locations (Map): All offline scenarios (Exams, Profile, Schedule, Library, Restaurants, Map) are now fully covered and tested. |
…to fix/offline-caching-1714
|
👋 hey! why isn't this done at a higher level? it would cover every case and avoid so many lines added. |
the problem here is not the empty list in the cached data. the problem is how can we differentiate a correct empty list (empty cache or empty remote response), from a list that is not loaded yet by remote |
packages/uni_app/lib/model/providers/riverpod/faculty_locations_provider.dart
Show resolved
Hide resolved
|
Refactored based on feedback to avoid code duplication (DRY):
|
pedroafmonteiro
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work on this, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request implements offline caching improvements to prevent the app from crashing when refreshing without an internet connection. The main changes introduce error handling with fallback to cached data when network requests fail.
Key Changes
- Modified
CachedAsyncNotifierto add try-catch blocks around remote data fetching, with fallback to local cached data when network requests fail - Removed error suppression in
LectureNotifierto allow proper error handling by the base class - Fixed
FacultyLocationsNotifierto properly fetch from assets instead of returning stale state
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
packages/uni_app/lib/model/providers/riverpod/cached_async_notifier.dart |
Added try-catch error handling with local data fallback for build() and refreshRemote() methods |
packages/uni_app/lib/model/providers/riverpod/lecture_provider.dart |
Removed .catchError() to allow base class error handling |
packages/uni_app/lib/model/providers/riverpod/exam_provider.dart |
Formatting cleanup (removed blank lines) |
packages/uni_app/lib/model/providers/riverpod/profile_provider.dart |
Added clarifying comments for data fetching flow |
packages/uni_app/lib/model/providers/riverpod/restaurant_provider.dart |
Added clarifying comments for data fetching flow |
packages/uni_app/lib/model/providers/riverpod/library_occupation_provider.dart |
Added clarifying comments for data fetching flow |
packages/uni_app/lib/model/providers/riverpod/faculty_locations_provider.dart |
Fixed to fetch from assets instead of returning cached state |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/uni_app/lib/model/providers/riverpod/faculty_locations_provider.dart
Show resolved
Hide resolved
packages/uni_app/lib/model/providers/riverpod/cached_async_notifier.dart
Show resolved
Hide resolved
packages/uni_app/lib/model/providers/riverpod/library_occupation_provider.dart
Show resolved
Hide resolved
packages/uni_app/lib/model/providers/riverpod/library_occupation_provider.dart
Show resolved
Hide resolved
DGoiana
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be aware of the empty list problem, as it can cause unexpected crashes. Come up with a good solution to that!
DGoiana
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be aware of the empty list problem, as it can cause unexpected crashes. Come up with a good solution to that!
Closes #1714
Description
Fixed a critical bug where the app would crash or clear the user's cached data (Schedule, Exams, Profile) when refreshing without an internet connection.
Changes Implemented
try-catchblocks to handleSocketException. If the network fails, the app now gracefully falls back to the local database instead of crashing or showing an empty list._invalidLocalDatato treat empty lists as valid cached data. This prevents the app from forcing a network refresh for students who genuinely have empty schedules/exams.Steps to Replicate
Review checklist
View Changes
Performance