Skip to content

Commit

Permalink
feat: Calendar deep link to course component
Browse files Browse the repository at this point in the history
  • Loading branch information
shafqat-muneer authored Apr 3, 2024
1 parent 3e632e8 commit 0f00f73
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
34 changes: 32 additions & 2 deletions OpenEdX/Managers/DeepLinkManager/DeepLinkManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ public class DeepLinkManager {
type == .courseHandout ||
type == .courseAnnouncement
}

private func isCourseComponent(type: DeepLinkType) -> Bool {
type == .courseComponent
}

@MainActor
private func navigateToScreen(
Expand All @@ -191,7 +195,8 @@ public class DeepLinkManager {
.courseAnnouncement,
.discussionTopic,
.discussionPost,
.discussionComment:
.discussionComment,
.courseComponent:
await showCourseScreen(with: type, link: link)
case .program, .programDetail:
guard config.program.enabled else { return }
Expand Down Expand Up @@ -277,6 +282,15 @@ public class DeepLinkManager {
}
return
}

if self.isCourseComponent(type: type) {
self.router.showProgress()
Task {
await self.showCourseComponent(link: link, courseDetails: courseDetails)
self.router.dismissProgress()
}
return
}
}
} catch {
router.dismissProgress()
Expand Down Expand Up @@ -394,7 +408,23 @@ public class DeepLinkManager {
break
}
}


@MainActor
private func showCourseComponent(
link: DeepLink,
courseDetails: CourseDetails
) async {
guard let courseID = link.courseID else { return }
guard let courseStructure = try? await courseInteractor.getCourseBlocks(courseID: courseID) else {
return
}
router.showCourseComponent(
componentID: link.componentID ?? "",
courseStructure: courseStructure,
blockLink: ""
)
}

@MainActor
private func showEditProfile() async {
guard let userProfile = try? await profileInteractor.getMyProfile() else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public protocol DeepLinkRouter: BaseRouter {
courseDetails: CourseDetails,
completion: @escaping () -> Void
)
func showCourseComponent(
componentID: String,
courseStructure: CourseStructure,
blockLink: String
)
func showAnnouncement(
courseDetails: CourseDetails,
updates: [CourseUpdate]
Expand Down Expand Up @@ -124,7 +129,8 @@ extension Router: DeepLinkRouter {
.discussions,
.courseHandout,
.courseAnnouncement,
.courseDashboard:
.courseDashboard,
.courseComponent:
popToCourseContainerView(animated: false)
default:
break
Expand All @@ -136,7 +142,7 @@ extension Router: DeepLinkRouter {
self.hostCourseContainerView?.rootView.viewModel.selection = CourseTab.course.rawValue
case .courseVideos:
self.hostCourseContainerView?.rootView.viewModel.selection = CourseTab.videos.rawValue
case .courseDates:
case .courseDates, .courseComponent:
self.hostCourseContainerView?.rootView.viewModel.selection = CourseTab.dates.rawValue
case .discussions, .discussionTopic, .discussionPost, .discussionComment:
self.hostCourseContainerView?.rootView.viewModel.selection = CourseTab.discussion.rawValue
Expand Down Expand Up @@ -335,6 +341,11 @@ public class DeepLinkRouterMock: BaseRouterMock, DeepLinkRouter {
courseDetails: CourseDetails,
completion: @escaping () -> Void
) {}
public func showCourseComponent(
componentID: String,
courseStructure: CourseStructure,
blockLink: String
) {}
public func showAnnouncement(
courseDetails: CourseDetails,
updates: [CourseUpdate]
Expand Down

0 comments on commit 0f00f73

Please sign in to comment.