Skip to content

Commit

Permalink
fix: bug when sequence units level appear after tapping on the Back b…
Browse files Browse the repository at this point in the history
…utton
  • Loading branch information
dixidroid committed Mar 19, 2024
1 parent beedcb3 commit 76b6615
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 18 deletions.
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 @@ -246,6 +246,7 @@ val screenModule = module {
get(),
get(),
get(),
get(),
)
}
viewModel { (courseId: String, handoutsType: String) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,26 @@ class CourseDatesFragment : Fragment() {
onItemClick = { blockId ->
if (blockId.isNotEmpty()) {
viewModel.getVerticalBlock(blockId)?.let { verticalBlock ->
viewModel.getSequentialBlock(verticalBlock.id)
?.let { sequentialBlock ->
router.navigateToCourseSubsections(
fm = requireActivity().supportFragmentManager,
subSectionId = sequentialBlock.id,
courseId = viewModel.courseId,
unitId = verticalBlock.id,
mode = CourseViewMode.FULL
)
}
if (viewModel.isCourseExpandableSectionsEnabled) {
router.navigateToCourseContainer(
fm = requireActivity().supportFragmentManager,
courseId = viewModel.courseId,
unitId = verticalBlock.id,
componentId = "",
mode = CourseViewMode.FULL
)
} else {
viewModel.getSequentialBlock(verticalBlock.id)
?.let { sequentialBlock ->
router.navigateToCourseSubsections(
fm = requireActivity().supportFragmentManager,
subSectionId = sequentialBlock.id,
courseId = viewModel.courseId,
unitId = verticalBlock.id,
mode = CourseViewMode.FULL
)
}
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import kotlinx.coroutines.launch
import org.openedx.core.BaseViewModel
import org.openedx.core.SingleEventLiveData
import org.openedx.core.UIMessage
import org.openedx.core.config.Config
import org.openedx.core.data.storage.CorePreferences
import org.openedx.core.domain.model.Block
import org.openedx.core.extension.getSequentialBlocks
Expand All @@ -37,6 +38,7 @@ class CourseDatesViewModel(
private val networkConnection: NetworkConnection,
private val resourceManager: ResourceManager,
private val corePreferences: CorePreferences,
private val config: Config,
) : BaseViewModel() {

private val _uiState = MutableLiveData<DatesUIState>(DatesUIState.Loading)
Expand Down Expand Up @@ -64,6 +66,8 @@ class CourseDatesViewModel(
val hasInternetConnection: Boolean
get() = networkConnection.isOnline()

val isCourseExpandableSectionsEnabled get() = config.isCourseNestedListEnabled()

init {
getCourseDates()
viewModelScope.launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,24 @@ class CourseOutlineFragment : Fragment() {
viewModel.resumeSectionBlock?.let { subSection ->
viewModel.resumeCourseTappedEvent(subSection.id)
viewModel.resumeVerticalBlock?.let { unit ->
router.navigateToCourseSubsections(
requireActivity().supportFragmentManager,
courseId = viewModel.courseId,
subSectionId = subSection.id,
mode = CourseViewMode.FULL,
unitId = unit.id,
componentId = componentId
)
if (viewModel.isCourseExpandableSectionsEnabled) {
router.navigateToCourseContainer(
fm = requireActivity().supportFragmentManager,
courseId = viewModel.courseId,
unitId = unit.id,
componentId = componentId,
mode = CourseViewMode.FULL
)
} else {
router.navigateToCourseSubsections(
requireActivity().supportFragmentManager,
courseId = viewModel.courseId,
subSectionId = subSection.id,
mode = CourseViewMode.FULL,
unitId = unit.id,
componentId = componentId
)
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class CourseOutlineViewModel(
val hasInternetConnection: Boolean
get() = networkConnection.isOnline()

val isCourseExpandableSectionsEnabled get() = config.isCourseNestedListEnabled()

private val courseSubSections = mutableMapOf<String, MutableList<Block>>()
private val subSectionsDownloadsCount = mutableMapOf<String, Int>()
val courseSubSectionUnit = mutableMapOf<String, Block?>()
Expand Down

0 comments on commit 76b6615

Please sign in to comment.