The courseRepository.getCourseActivities() method has if(_sessions == null){ await getSessions(); }.
Except it never enters this if statement because _sessions is not null, but has 0 elements when the sessions aren't cached.
This results in looping through 0 elements (sessions) so obviously there won't be a schedule.
The following methods end up calling courseRepository.getSessions() one way or another:
futureToRunSessionProgress()
futureToRunGrades()
futureToRunSchedule()
Because of the asynchronous operations, _sessions actually gets populated with the correct values right after getCourseActivities() loops through an empty _sessions array.
I decided to change the condition to also check if the array is empty.
It's not my favourite implementation but I noticed that we're already doing a similar thing in futureToRunGrades().
if (_sessions == null || _sessions!.isEmpty) {
await getSessions();
}
🧪 How Has This Been Tested?
I tested manually by reinstall the application/clearing the cache.
☑️ Checklist before requesting a review
[x] I have performed a self-review of my code.
[ ] If it is a core feature, I have added thorough tests.
[ ] If needed, I added analytics.
[x] Make sure to add either one of the following labels: version: Major,version: Minor or version: Patch.
[ ] Make sure golden files changes were reviewed and approved.
⁉️ Related Issue
957
📖 Description
The
courseRepository.getCourseActivities()
method hasif(_sessions == null){ await getSessions(); }
. Except it never enters thisif
statement because_sessions
is notnull
, but has 0 elements when the sessions aren't cached. This results in looping through 0 elements (sessions) so obviously there won't be a schedule.The following methods end up calling
courseRepository.getSessions()
one way or another:futureToRunSessionProgress()
futureToRunGrades()
futureToRunSchedule()
Because of the asynchronous operations,
_sessions
actually gets populated with the correct values right aftergetCourseActivities()
loops through an empty_sessions
array.I decided to change the condition to also check if the array is empty. It's not my favourite implementation but I noticed that we're already doing a similar thing in
futureToRunGrades()
.🧪 How Has This Been Tested?
I tested manually by reinstall the application/clearing the cache.
☑️ Checklist before requesting a review
version: Major
,version: Minor
orversion: Patch
.🖼️ Screenshots (if useful):