From eddd54b357e6d0da4ccd1dc2d3df5832212600f7 Mon Sep 17 00:00:00 2001 From: Igor Date: Mon, 7 Oct 2024 11:14:39 +0200 Subject: [PATCH] fix: bug when unable to see new loaded items on the All Courses screen (#382) --- .../openedx/courses/presentation/AllEnrolledCoursesView.kt | 3 ++- .../courses/presentation/AllEnrolledCoursesViewModel.kt | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dashboard/src/main/java/org/openedx/courses/presentation/AllEnrolledCoursesView.kt b/dashboard/src/main/java/org/openedx/courses/presentation/AllEnrolledCoursesView.kt index ef583112b..de5d80b0c 100644 --- a/dashboard/src/main/java/org/openedx/courses/presentation/AllEnrolledCoursesView.kt +++ b/dashboard/src/main/java/org/openedx/courses/presentation/AllEnrolledCoursesView.kt @@ -20,6 +20,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.lazy.grid.GridCells +import androidx.compose.foundation.lazy.grid.GridItemSpan import androidx.compose.foundation.lazy.grid.LazyVerticalGrid import androidx.compose.foundation.lazy.grid.items import androidx.compose.foundation.lazy.grid.rememberLazyGridState @@ -329,7 +330,7 @@ private fun AllEnrolledCoursesView( } ) } - item { + item(span = { GridItemSpan(columns) }) { if (state.canLoadMore) { Box( modifier = Modifier diff --git a/dashboard/src/main/java/org/openedx/courses/presentation/AllEnrolledCoursesViewModel.kt b/dashboard/src/main/java/org/openedx/courses/presentation/AllEnrolledCoursesViewModel.kt index 6f3f96ebf..d52475eca 100644 --- a/dashboard/src/main/java/org/openedx/courses/presentation/AllEnrolledCoursesViewModel.kt +++ b/dashboard/src/main/java/org/openedx/courses/presentation/AllEnrolledCoursesViewModel.kt @@ -83,7 +83,7 @@ class AllEnrolledCoursesViewModel( } coursesList.clear() coursesList.addAll(response.courses) - _uiState.update { it.copy(courses = coursesList) } + _uiState.update { it.copy(courses = coursesList.toList()) } } catch (e: Exception) { if (e.isInternetError()) { _uiMessage.emit(UIMessage.SnackBarMessage(resourceManager.getString(R.string.core_error_no_connection))) @@ -125,7 +125,7 @@ class AllEnrolledCoursesViewModel( page = -1 coursesList.addAll(cachedList) } - _uiState.update { it.copy(courses = coursesList) } + _uiState.update { it.copy(courses = coursesList.toList()) } } catch (e: Exception) { if (e.isInternetError()) { _uiMessage.emit(UIMessage.SnackBarMessage(resourceManager.getString(R.string.core_error_no_connection)))