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

Commit

Permalink
refactor: moving what's new call at more relevant place
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedbashir committed Aug 16, 2023
1 parent e9886da commit e422549
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
12 changes: 0 additions & 12 deletions Source/CourseDashboardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class CourseDashboardViewController: UITabBarController, InterfaceOrientationOve
private var navigationItems: [UIBarButtonItem] = []

fileprivate let courseStream = BackedStream<UserCourseEnrollment>()
private var whatsNewShown: Bool = false
init(environment: Environment, courseID: String) {
self.environment = environment
self.courseID = courseID
Expand Down Expand Up @@ -197,17 +196,6 @@ class CourseDashboardViewController: UITabBarController, InterfaceOrientationOve
loadStateController.loadController.state = .Loaded
prepareTabViewData(withCourse: course)
addNavigationItems(withCourse: course)
showWhatsNewIfNeeded()
}
}

private func showWhatsNewIfNeeded() {
guard let enrollment = environment.interface?.enrollmentForCourse(withID: course?.course_id), enrollment.isUpgradeable && !whatsNewShown else { return}


if WhatsNewViewController.canShowWhatsNew(environment: environment as? RouterEnvironment), environment.serverConfig.iapConfig?.enabledforUser ?? false {
whatsNewShown = true
environment.router?.showWhatsNew(fromController: self)
}
}

Expand Down
13 changes: 13 additions & 0 deletions Source/CourseOutlineViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public class CourseOutlineViewController :
return environment.dataManager.enrollmentManager.enrolledCourseWithID(courseID: courseID)?.course
}

private var whatsNewShown: Bool = false

public init(environment: Environment, courseID : String, rootID : CourseBlockID?, forMode mode: CourseOutlineMode?) {
self.rootID = rootID
self.environment = environment
Expand Down Expand Up @@ -201,6 +203,7 @@ public class CourseOutlineViewController :
if self?.courseOutlineMode == .full {
self?.courseOutlineLoaded = true
self?.handleNavigationIfNeeded()
self?.showWhatsNewIfNeeded()
self?.environment.analytics.trackScreen(withName: OEXAnalyticsScreenCourseOutline, courseID: self?.courseID, value: nil)
}
else {
Expand Down Expand Up @@ -336,6 +339,16 @@ public class CourseOutlineViewController :
)
}

private func showWhatsNewIfNeeded() {
guard let enrollment = environment.interface?.enrollmentForCourse(withID: course?.course_id), enrollment.isUpgradeable && !whatsNewShown else { return}


if WhatsNewViewController.canShowWhatsNew(environment: environment as? RouterEnvironment), environment.serverConfig.iapConfig?.enabledforUser ?? false {
whatsNewShown = true
environment.router?.showWhatsNew(fromController: self)
}
}

private func handleNavigationIfNeeded() {
if let courseUpgradeModel = courseUpgradeHelper.courseUpgradeModel {
courseUpgradeHelper.resetUpgradeModel()
Expand Down
1 change: 1 addition & 0 deletions Source/OEXConfig+AppFeatures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ extension OEXConfig {
}

var isWhatsNewEnabled: Bool {
return true
return bool(forKey: "WHATS_NEW_ENABLED")
}

Expand Down
Binary file modified Source/Resources/WhatsNew/screen_1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e422549

Please sign in to comment.