chore: load public courses repeatedly (#5205)

This commit is contained in:
ggurdin 2026-01-15 14:51:24 -05:00 committed by GitHub
parent 5b2482feed
commit 7fb8e44206
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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(