Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Handle units with no descendants #29

Merged
merged 3 commits into from
Aug 12, 2024
Merged

Conversation

omerhabib26
Copy link

Description:

  • Handle UI if an unit has zero descendant
  • show unit list if a subsection have more then 1 units.

- Handle UI if an unit has zero descendant
- show unit list if a subsection have more then 1 units.
@@ -852,7 +852,7 @@ fun SubSectionUnitsTitle(
onUnitsClick: () -> Unit,
) {
val textStyle = MaterialTheme.appTypography.titleMedium
val hasUnits = unitsCount > 0
val hasUnits = unitsCount > 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to rename this with hasMultipleUnits.

Comment on lines +265 to +282
if (unitBlocks.size > 1) {
val selectedUnitIndex = unitBlocks.indexOfFirst { it.id == viewModel.unitId }
OpenEdXTheme {
SubSectionUnitsList(
unitBlocks = unitBlocks,
selectedUnitIndex = selectedUnitIndex
) { index, unit ->
if (index != selectedUnitIndex) {
router.navigateToCourseContainer(
fm = requireActivity().supportFragmentManager,
courseId = viewModel.courseId,
unitId = unit.id,
mode = requireArguments().serializable(ARG_MODE)!!
)

} else {
handleUnitsClick()
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this code-change we can achieve the required error screen.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code change restricts this view to trigger only when it has multiple units.

Copy link
Member

@farhan-arshad-dev farhan-arshad-dev Aug 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition deserves some doc string.

@omerhabib26 omerhabib26 merged commit dd757fe into 2U/develop Aug 12, 2024
4 checks passed
@HamzaIsrar12 HamzaIsrar12 deleted the 2U/omer/release_fixes branch August 26, 2024 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants