Skip to content

Commit 6333891

Browse files
fix: remove course during downloading
1 parent 794efab commit 6333891

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

downloads/src/main/java/org/openedx/downloads/presentation/download/DownloadsViewModel.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,12 @@ class DownloadsViewModel(
227227
logEvent(DownloadsAnalyticsEvent.REMOVE_DOWNLOAD_CLICKED)
228228
viewModelScope.launch {
229229
val downloadModels = interactor.getDownloadModels().first().filter {
230-
it.courseId == courseId && it.downloadedState == DownloadedState.DOWNLOADED
230+
it.courseId == courseId
231231
}
232-
val totalSize = downloadModels.sumOf { it.size }
232+
val downloadedModels = downloadModels.filter {
233+
it.downloadedState == DownloadedState.DOWNLOADED
234+
}
235+
val totalSize = downloadedModels.sumOf { it.size }
233236
val title = getCoursePreview(courseId)?.name.orEmpty()
234237
val downloadDialogItem = DownloadDialogItem(
235238
title = title,

downloads/src/test/java/org/openedx/downloads/DownloadsViewModelTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class DownloadsViewModelTest {
235235
}
236236

237237
@Test
238-
fun `downloadCourse should update courseDownloadState and show download dialog`() = runTest {
238+
fun `downloadCourse should show download dialog`() = runTest {
239239
val viewModel = DownloadsViewModel(
240240
downloadsRouter,
241241
networkConnection,

0 commit comments

Comments
 (0)