chore: load public courses repeatedly (#5205)
This commit is contained in:
parent
5b2482feed
commit
7fb8e44206
1 changed files with 18 additions and 8 deletions
|
|
@ -53,10 +53,10 @@ class PublicCoursesPageState extends State<PublicCoursesPage> {
|
|||
_loadCourses();
|
||||
}
|
||||
|
||||
void setTargetLanguageFilter(LanguageModel? language, {bool reload = true}) {
|
||||
void setTargetLanguageFilter(LanguageModel? language) {
|
||||
if (targetLanguageFilter?.langCodeShort == language?.langCodeShort) return;
|
||||
setState(() => targetLanguageFilter = language);
|
||||
if (reload) _loadCourses();
|
||||
_loadCourses();
|
||||
}
|
||||
|
||||
List<PublicCoursesChunk> get filteredCourses {
|
||||
|
|
@ -95,13 +95,8 @@ class PublicCoursesPageState extends State<PublicCoursesPage> {
|
|||
return filtered;
|
||||
}
|
||||
|
||||
Future<void> _loadCourses() async {
|
||||
Future<void> _loadPublicSpaces() async {
|
||||
try {
|
||||
setState(() {
|
||||
loading = true;
|
||||
error = null;
|
||||
});
|
||||
|
||||
final resp = await Matrix.of(context).client.requestPublicCourses(
|
||||
since: nextBatch,
|
||||
);
|
||||
|
|
@ -123,6 +118,21 @@ class PublicCoursesPageState extends State<PublicCoursesPage> {
|
|||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _loadCourses() async {
|
||||
setState(() {
|
||||
loading = true;
|
||||
error = null;
|
||||
});
|
||||
|
||||
await _loadPublicSpaces();
|
||||
|
||||
int timesLoaded = 0;
|
||||
while (error == null && timesLoaded < 5 && nextBatch != null) {
|
||||
await _loadPublicSpaces();
|
||||
timesLoaded++;
|
||||
}
|
||||
|
||||
try {
|
||||
final resp = await CoursePlansRepo.search(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue