Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
fix: fix course loading after enrolling a course (#1801)
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad Umer authored Sep 21, 2023
1 parent c127244 commit 099c86e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 8 additions & 2 deletions Source/NewCourseDashboardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,12 @@ class NewCourseDashboardViewController: UIViewController, InterfaceOrientationOv
private let environment: Environment
let courseID: String
private let screen: CourseUpgradeScreen = .courseDashboard
private let newEnrollment: Bool

init(environment: Environment, courseID: String) {
init(environment: Environment, courseID: String, newEnrollment: Bool = false) {
self.environment = environment
self.courseID = courseID
self.newEnrollment = newEnrollment
self.courseStream = BackedStream<UserCourseEnrollment>()
self.loadStateController = LoadStateViewController()
super.init(nibName: nil, bundle: nil)
Expand All @@ -103,7 +105,11 @@ class NewCourseDashboardViewController: UIViewController, InterfaceOrientationOv

navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
addSubviews()
loadCourseStream()

let delay = newEnrollment ? 0.5 : 0
DispatchQueue.main.asyncAfter(deadline: .now() + delay) { [weak self] in
self?.loadCourseStream()
}
}

override func viewWillAppear(_ animated: Bool) {
Expand Down
8 changes: 4 additions & 4 deletions Source/OEXRouter+Swift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,11 @@ extension OEXRouter {
let learnController = controller.children.flatMap { $0.children }.compactMap { $0 as? LearnContainerViewController } .first
showContentStack(withRootController: controller, animated: animated)
if let courseID = courseID, let learnController = learnController {
showCourseWithID(courseID: courseID, fromController: learnController, animated: false)
showCourseWithID(courseID: courseID, fromController: learnController, animated: false, newEnrollment: true)
}
}

@objc func showEnrolledTabBarView() {
@objc func showEnrolledTabBarView() {
let controller = EnrolledTabBarViewController(environment: environment)
showContentStack(withRootController: controller, animated: false)
}
Expand Down Expand Up @@ -560,9 +560,9 @@ extension OEXRouter {
c.loadRequest(request: URLRequest(url: url as URL) as NSURLRequest)
}

func showCourseWithID(courseID: String, fromController: UIViewController, animated: Bool = true, completion: ((UIViewController) -> Void)? = nil) {
func showCourseWithID(courseID: String, fromController: UIViewController, animated: Bool = true, newEnrollment: Bool = false, completion: ((UIViewController) -> Void)? = nil) {
if environment.config.isNewDashboardEnabled {
let courseDashboardViewController = NewCourseDashboardViewController(environment: environment, courseID: courseID)
let courseDashboardViewController = NewCourseDashboardViewController(environment: environment, courseID: courseID, newEnrollment: newEnrollment)
let controller = ForwardingNavigationController(rootViewController: courseDashboardViewController)
controller.navigationController?.setNavigationBarHidden(true, animated: false)
controller.modalPresentationStyle = .fullScreen
Expand Down

0 comments on commit 099c86e

Please sign in to comment.