File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
course/src/main/java/org/openedx/course/presentation/offline Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,6 @@ import org.openedx.core.extension.safeDivBy
1818import org.openedx.core.module.DownloadWorkerController
1919import org.openedx.core.module.db.DownloadDao
2020import org.openedx.core.module.db.DownloadModel
21- import org.openedx.core.module.db.DownloadedState
2221import org.openedx.core.module.db.FileType
2322import org.openedx.core.module.download.BaseDownloadViewModel
2423import org.openedx.core.module.download.DownloadHelper
@@ -171,10 +170,13 @@ class CourseOfflineViewModel(
171170 val downloadedBlocks = courseStructure.blockData.filter {
172171 it.id in completedDownloads.map { it.id }
173172 }
174- val isAllDownloaded =
175- courseDownloadModels.all { it.downloadedState == DownloadedState .DOWNLOADED } &&
176- courseDownloadModels.isNotEmpty()
177- val isHaveDownloadableBlocks = courseStructure.blockData.any { it.isDownloadable }
173+ val allDownloadableBlocks = courseStructure.blockData.filter { it.isDownloadable }
174+ val courseDownloadModelsMap = courseDownloadModels.associateBy { it.id }
175+ val isAllDownloaded = allDownloadableBlocks.isNotEmpty() &&
176+ allDownloadableBlocks.all { block ->
177+ courseDownloadModelsMap[block.id]?.downloadedState?.isDownloaded == true
178+ }
179+ val isHaveDownloadableBlocks = allDownloadableBlocks.isNotEmpty()
178180
179181 updateUIState(
180182 totalDownloadableSize,
You can’t perform that action at this time.
0 commit comments