Skip to content

Commit

Permalink
Merge branch 'develop' into try/integrate-latest-wpkit-wpauth
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoreymendez committed Mar 4, 2020
2 parents 779c67e + 396c0d3 commit 1d1fa06
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 474 deletions.
11 changes: 11 additions & 0 deletions WordPress/Classes/Services/AccountSettingsService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,17 @@ class AccountSettingsService {
}
}

func updateDisplayName(_ displayName: String, finished: ((Bool, Error?) -> ())? = nil) {
remote.updateSetting(.displayName(displayName), success: {
finished?(true, nil)
}) { error in
DDLogError("Error saving account settings change \(error)")
NotificationCenter.default.post(name: NSNotification.Name.AccountSettingsServiceChangeSaveFailed, object: self, userInfo: [NSUnderlyingErrorKey: error])

finished?(false, error)
}
}

func updatePassword(_ password: String, finished: ((Bool, Error?) -> ())? = nil) {
remote.updatePassword(password, success: {
finished?(true, nil)
Expand Down
1 change: 0 additions & 1 deletion WordPress/Classes/System/WordPress-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#import "PostContentProvider.h"
#import "PostListFooterView.h"
#import "PostMetaButton.h"
#import "PostPreviewViewController.h"
#import "PostService.h"
#import "PostServiceOptions.h"
#import "PostSettingsViewController.h"
Expand Down
5 changes: 0 additions & 5 deletions WordPress/Classes/Utility/BuildInformation/FeatureFlag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
enum FeatureFlag: Int, CaseIterable {
case jetpackDisconnect
case debugMenu
case postPreview
case postReblogging
case unifiedAuth
case quickActions
Expand All @@ -23,8 +22,6 @@ enum FeatureFlag: Int, CaseIterable {
case .debugMenu:
return BuildConfiguration.current ~= [.localDeveloper,
.a8cBranchTest]
case .postPreview:
return true
case .postReblogging:
return true
case .unifiedAuth:
Expand Down Expand Up @@ -57,8 +54,6 @@ extension FeatureFlag: OverrideableFlag {
return "Jetpack disconnect"
case .debugMenu:
return "Debug menu"
case .postPreview:
return "Post preview redesign"
case .postReblogging:
return "Post Reblogging"
case .unifiedAuth:
Expand Down
43 changes: 14 additions & 29 deletions WordPress/Classes/Utility/Spotlight/SearchManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -475,51 +475,36 @@ fileprivate extension SearchManager {
WPTabBarController.sharedInstance().showMySitesTab()
closePreviewIfNeeded(for: apost)

if FeatureFlag.postPreview.enabled {
let controller = PreviewWebKitViewController(post: apost)
controller.trackOpenEvent()
let navWrapper = LightNavigationController(rootViewController: controller)
WPTabBarController.sharedInstance().present(navWrapper, animated: true)
} else {
let controller = PostPreviewViewController(post: apost)
controller.hidesBottomBarWhenPushed = true
let navWrapper = UINavigationController(rootViewController: controller)
controller.onClose = {
navWrapper.dismiss(animated: true) {}
}
WPTabBarController.sharedInstance().present(navWrapper, animated: true)
}
let controller = PreviewWebKitViewController(post: apost)
controller.trackOpenEvent()
let navWrapper = LightNavigationController(rootViewController: controller)
WPTabBarController.sharedInstance().present(navWrapper, animated: true)

openListView(for: apost)
}

/// If there is a PostPreviewViewController window open and it is already displaying the provided
/// If there is a post preview window open and it is already displaying the provided
/// AbstractPost, leave it open, otherwise close it.
///
func closePreviewIfNeeded(for apost: AbstractPost) {
guard let navController = WPTabBarController.sharedInstance().presentedViewController as? UINavigationController else {
return
}
if FeatureFlag.postPreview.enabled {
guard let previewVC = navController.topViewController as? PreviewWebKitViewController,
previewVC.post != apost else {
// Do nothing — post is already loaded or PostPreviewViewController isn't visible
return
}
} else {
guard let previewVC = navController.topViewController as? PostPreviewViewController,
previewVC.apost != apost else {
// Do nothing — post is already loaded or PostPreviewViewController isn't visible
return
}

guard let previewVC = navController.topViewController as? PreviewWebKitViewController,
previewVC.post != apost else {
// Do nothing — post is already loaded or the post preview view controller isn't visible
return
}

navController.dismiss(animated: true)
}

/// If there is any PostPreviewViewController window open, close it.
/// If there is any post preview window open, close it.
///
func closeAnyOpenPreview() {
guard let navController = WPTabBarController.sharedInstance().presentedViewController as? UINavigationController,
navController.topViewController is PostPreviewViewController || navController.topViewController is PreviewWebKitViewController else {
navController.topViewController is PreviewWebKitViewController else {
return
}
navController.dismiss(animated: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,24 +212,19 @@ private extension SignupEpilogueViewController {
}

func changeDisplayName(to newDisplayName: String, finished: @escaping (() -> Void)) {

let context = ContextManager.sharedInstance().mainContext

guard let defaultAccount = AccountService(managedObjectContext: context).defaultWordPressComAccount(),
let restApi = defaultAccount.wordPressComRestApi else {
finished()
return
let restApi = defaultAccount.wordPressComRestApi else {
finished()
return
}

let accountSettingService = AccountSettingsService(userID: defaultAccount.userID.intValue, api: restApi)
let accountSettingsChange = AccountSettingsChange.displayName(newDisplayName)

accountSettingService.saveChange(accountSettingsChange) { success in
if success {
WordPressAuthenticator.track(.signupEpilogueDisplayNameUpdateSucceeded, properties: self.tracksProperties())
} else {
WordPressAuthenticator.track(.signupEpilogueDisplayNameUpdateFailed, properties: self.tracksProperties())
}
accountSettingService.updateDisplayName(newDisplayName) { (success, _) in
let event: WPAnalyticsStat = success ? .signupEpilogueDisplayNameUpdateSucceeded : .signupEpilogueDisplayNameUpdateFailed
WordPressAuthenticator.track(event, properties: self.tracksProperties())

finished()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -940,22 +940,13 @@ class AbstractPostListViewController: UIViewController,

let post = apost.hasRevision() ? apost.revision! : apost

if FeatureFlag.postPreview.enabled {
let controller = PreviewWebKitViewController(post: post)
controller.trackOpenEvent()
// NOTE: We'll set the title to match the title of the View action button.
// If the button title changes we should also update the title here.
controller.navigationItem.title = NSLocalizedString("View", comment: "Verb. The screen title shown when viewing a post inside the app.")
let navWrapper = LightNavigationController(rootViewController: controller)
navigationController?.present(navWrapper, animated: true)
} else {
let controller = PostPreviewViewController(post: post)
// NOTE: We'll set the title to match the title of the View action button.
// If the button title changes we should also update the title here.
controller.navigationItem.title = NSLocalizedString("View", comment: "Verb. The screen title shown when viewing a post inside the app.")
controller.hidesBottomBarWhenPushed = true
navigationController?.pushViewController(controller, animated: true)
}
let controller = PreviewWebKitViewController(post: post)
controller.trackOpenEvent()
// NOTE: We'll set the title to match the title of the View action button.
// If the button title changes we should also update the title here.
controller.navigationItem.title = NSLocalizedString("View", comment: "Verb. The screen title shown when viewing a post inside the app.")
let navWrapper = LightNavigationController(rootViewController: controller)
navigationController?.present(navWrapper, animated: true)
}

@objc func deletePost(_ apost: AbstractPost) {
Expand Down
18 changes: 4 additions & 14 deletions WordPress/Classes/ViewRelated/Post/EditPostViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -236,20 +236,10 @@ class EditPostViewController: UIViewController {
return
}

if FeatureFlag.postPreview.enabled {
let controller = PreviewWebKitViewController(post: post)
controller.trackOpenEvent()
let navWrapper = LightNavigationController(rootViewController: controller)
postPost.present(navWrapper, animated: true) {}
} else {
let controller = PostPreviewViewController(post: post)
controller.hidesBottomBarWhenPushed = true
controller.onClose = {
self.dismiss(animated: true) {}
}
let navWrapper = UINavigationController(rootViewController: controller)
postPost.present(navWrapper, animated: true) {}
}
let controller = PreviewWebKitViewController(post: post)
controller.trackOpenEvent()
let navWrapper = LightNavigationController(rootViewController: controller)
postPost.present(navWrapper, animated: true) {}
}

@objc func closePostPost(animated: Bool) {
Expand Down
38 changes: 11 additions & 27 deletions WordPress/Classes/ViewRelated/Post/PostEditor+MoreOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,36 +77,20 @@ extension PostEditor where Self: UIViewController {
return
}

if FeatureFlag.postPreview.enabled {
let previewController: PreviewWebKitViewController
if let previewURLString = previewURLString, let previewURL = URL(string: previewURLString) {
previewController = PreviewWebKitViewController(post: self.post, previewURL: previewURL)
} else {
if self.post.permaLink == nil {
DDLogError("displayPreview: Post permalink is unexpectedly nil")
self.displayPreviewNotAvailable(title: NSLocalizedString("Preview Unavailable", comment: "Title on display preview error" ))
return
}
previewController = PreviewWebKitViewController(post: self.post)
}
previewController.trackOpenEvent()
let navWrapper = LightNavigationController(rootViewController: previewController)
self.navigationController?.present(navWrapper, animated: true)
let previewController: PreviewWebKitViewController
if let previewURLString = previewURLString, let previewURL = URL(string: previewURLString) {
previewController = PreviewWebKitViewController(post: self.post, previewURL: previewURL)
} else {
var previewController: PostPreviewViewController
if let previewURLString = previewURLString, let previewURL = URL(string: previewURLString) {
previewController = PostPreviewViewController(post: self.post, previewURL: previewURL)
} else {
if self.post.permaLink == nil {
DDLogError("displayPreview: Post permalink is unexpectedly nil")
self.displayPreviewNotAvailable(title: NSLocalizedString("Preview Unavailable", comment: "Title on display preview error" ))
return
}
previewController = PostPreviewViewController(post: self.post)
if self.post.permaLink == nil {
DDLogError("displayPreview: Post permalink is unexpectedly nil")
self.displayPreviewNotAvailable(title: NSLocalizedString("Preview Unavailable", comment: "Title on display preview error" ))
return
}
previewController.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(previewController, animated: true)
previewController = PreviewWebKitViewController(post: self.post)
}
previewController.trackOpenEvent()
let navWrapper = LightNavigationController(rootViewController: previewController)
self.navigationController?.present(navWrapper, animated: true)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,13 @@ class PostNoticeNavigationCoordinator {
return
}

if FeatureFlag.postPreview.enabled {
let controller = PostPreviewViewController(post: page)
controller.navigationItem.title = NSLocalizedString("View", comment: "Verb. The screen title shown when viewing a post inside the app.")
controller.hidesBottomBarWhenPushed = true
let controller = PreviewWebKitViewController(post: page)
controller.trackOpenEvent()
controller.navigationItem.title = NSLocalizedString("View", comment: "Verb. The screen title shown when viewing a post inside the app.")

let navigationController = UINavigationController(rootViewController: controller)
navigationController.modalPresentationStyle = .formSheet
presenter.present(navigationController, animated: true)
} else {
let controller = PreviewWebKitViewController(post: page)
controller.trackOpenEvent()
controller.navigationItem.title = NSLocalizedString("View", comment: "Verb. The screen title shown when viewing a post inside the app.")

let navigationController = UINavigationController(rootViewController: controller)
navigationController.modalPresentationStyle = .formSheet
presenter.present(navigationController, animated: true)
}
let navigationController = UINavigationController(rootViewController: controller)
navigationController.modalPresentationStyle = .formSheet
presenter.present(navigationController, animated: true)
}

private static func presentPostEpilogue(for post: Post) {
Expand Down
21 changes: 0 additions & 21 deletions WordPress/Classes/ViewRelated/Post/PostPreviewViewController.h

This file was deleted.

Loading

0 comments on commit 1d1fa06

Please sign in to comment.