Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/main/java/org/openedx/app/di/ScreenModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ val screenModule = module {
get(),
get(),
get(),
get()
)
}
viewModel { (courseId: String) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import org.openedx.core.presentation.CoreAnalytics
import org.openedx.core.presentation.dialog.downloaddialog.DownloadDialogItem
import org.openedx.core.presentation.dialog.downloaddialog.DownloadDialogManager
import org.openedx.core.system.connection.NetworkConnection
import org.openedx.core.system.notifier.CourseNotifier
import org.openedx.core.system.notifier.CourseStructureGot
import org.openedx.course.domain.interactor.CourseInteractor
import org.openedx.foundation.extension.toFileSize
import org.openedx.foundation.utils.FileUtil
Expand All @@ -37,6 +39,7 @@ class CourseOfflineViewModel(
private val downloadDialogManager: DownloadDialogManager,
private val fileUtil: FileUtil,
private val networkConnection: NetworkConnection,
private val courseNotifier: CourseNotifier,
coreAnalytics: CoreAnalytics,
downloadDao: DownloadDao,
workerController: DownloadWorkerController,
Expand Down Expand Up @@ -71,11 +74,7 @@ class CourseOfflineViewModel(
_uiState.update { it.copy(isDownloading = isDownloading) }
}
}

viewModelScope.launch {
async { initDownloadFragment() }.await()
getOfflineData()
}
collectCourseNotifier()
}

fun downloadAllBlocks(fragmentManager: FragmentManager) {
Expand Down Expand Up @@ -224,4 +223,17 @@ class CourseOfflineViewModel(
}
}
}

private fun collectCourseNotifier() {
viewModelScope.launch {
courseNotifier.notifier.collect { event ->
when (event) {
is CourseStructureGot -> {
async { initDownloadFragment() }.await()
getOfflineData()
}
}
}
}
}
}
Loading