11typealias HomepageEditorCompletion = ( ) -> Void
22
33class SiteAssemblyCompletionHelper {
4- static func completeSiteCreation( for blog: Blog , quickStartSettings: QuickStartSettings ) {
5- // branch here for explat variation
6- if ABTest . landInTheEditorPhase1. variation == . control {
7- showMySitesScreen ( for: blog, quickStartSettings: quickStartSettings)
8- } else {
9- landInTheEditor ( for: blog, quickStartSettings: quickStartSettings)
10- }
11- }
12-
13- static func completeSiteCreationFromAuthenticationScreen( for blog: Blog , quickStartSettings: QuickStartSettings , navigationController: UINavigationController , completion: @escaping HomepageEditorCompletion ) {
4+ /// Land in the editor, or continue as usual for the control group - Used to branch on the ExPlat experiment for landing in the editor from the site creation flow
5+ /// - Parameter blog: Blog (which was just created) for which to show the home page editor
6+ /// - Parameter navigationController: UINavigationController used to present the home page editor
7+ /// - Parameter completion: HomepageEditorCompletion callback to be invoked after the user finishes editing the home page, or immediately in the control group case
8+ static func landInTheEditorOrContinue( for blog: Blog , navigationController: UINavigationController , completion: @escaping HomepageEditorCompletion ) {
149 // branch here for explat variation
1510 if ABTest . landInTheEditorPhase1. variation == . control {
1611 completion ( )
1712 } else {
18- landInTheEditor ( for: blog, quickStartSettings : quickStartSettings , navigationController: navigationController, completion: completion)
13+ landInTheEditor ( for: blog, navigationController: navigationController, completion: completion)
1914 }
20-
21- }
22-
23- private static func landInTheEditor( for blog: Blog , quickStartSettings: QuickStartSettings ) {
24- fetchAllPages ( for: blog, success: { _ in
25- DispatchQueue . main. async {
26- WPTabBarController . sharedInstance ( ) ? . showHomePageEditor ( forBlog: blog) {
27- showMySitesScreen ( for: blog, quickStartSettings: quickStartSettings)
28- }
29- }
30- WPAnalytics . track ( . landingEditorShown)
31- } , failure: { _ in
32- NSLog ( " Fetching all pages failed after site creation! " )
33- } )
3415 }
3516
36- private static func landInTheEditor( for blog: Blog , quickStartSettings : QuickStartSettings , navigationController: UINavigationController , completion: @escaping HomepageEditorCompletion ) {
17+ private static func landInTheEditor( for blog: Blog , navigationController: UINavigationController , completion: @escaping HomepageEditorCompletion ) {
3718 fetchAllPages ( for: blog, success: { _ in
3819 DispatchQueue . main. async {
3920 if let homepage = blog. homepage {
4021 let editorViewController = EditPageViewController ( homepage: homepage, completion: completion)
4122 navigationController. present ( editorViewController, animated: false )
23+ WPAnalytics . track ( . landingEditorShown)
4224 }
43- WPAnalytics . track ( . landingEditorShown)
4425 }
4526 } , failure: { _ in
4627 NSLog ( " Fetching all pages failed after site creation! " )
4728 } )
4829 }
4930
50- private static func showMySitesScreen( for blog: Blog , quickStartSettings: QuickStartSettings ) {
51- WPTabBarController . sharedInstance ( ) ? . mySitesCoordinator. showBlogDetails ( for: blog)
52- showQuickStartPrompt ( for: blog, quickStartSettings: quickStartSettings)
53- }
54-
5531 // This seems to be necessary before casting `AbstractPost` to `Page`.
5632 private static func fetchAllPages( for blog: Blog , success: @escaping PostServiceSyncSuccess , failure: @escaping PostServiceSyncFailure ) {
5733 let options = PostServiceSyncOptions ( )
@@ -60,22 +36,4 @@ class SiteAssemblyCompletionHelper {
6036 let postService = PostService ( managedObjectContext: context)
6137 postService. syncPosts ( ofType: . page, with: options, for: blog, success: success, failure: failure)
6238 }
63-
64- private static func showQuickStartPrompt( for blog: Blog , quickStartSettings: QuickStartSettings ) {
65- guard !quickStartSettings. promptWasDismissed ( for: blog) else {
66- return
67- }
68-
69- guard let tabBar = WPTabBarController . sharedInstance ( ) else {
70- return
71- }
72-
73- let quickstartPrompt = QuickStartPromptViewController ( blog: blog)
74- quickstartPrompt. onDismiss = { blog, showQuickStart in
75- if showQuickStart {
76- QuickStartTourGuide . shared. setupWithDelay ( for: blog)
77- }
78- }
79- tabBar. present ( quickstartPrompt, animated: true )
80- }
8139}
0 commit comments