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

feat: Calendar deep link to course component #381

Merged
merged 2 commits into from
Apr 3, 2024
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
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 @@ -268,6 +273,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 @@ -378,7 +392,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 @@ -121,7 +126,8 @@ extension Router: DeepLinkRouter {
.discussions,
.courseHandout,
.courseAnnouncement,
.courseDashboard:
.courseDashboard,
.courseComponent:
popToCourseContainerView(animated: false)
default:
break
Expand All @@ -133,7 +139,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 @@ -326,6 +332,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
Loading