Created
May 25, 2018 19:05
-
-
Save frosty/489b29c5f9cf7632ee31ed4697008805 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/WordPress/Classes/ViewRelated/Aztec/Helpers/AztecVerificationPromptHelper.swift b/WordPress/Classes/ViewRelated/Aztec/Helpers/AztecVerificationPromptHelper.swift | |
index 222f0e4267..062894902b 100644 | |
--- a/WordPress/Classes/ViewRelated/Aztec/Helpers/AztecVerificationPromptHelper.swift | |
+++ b/WordPress/Classes/ViewRelated/Aztec/Helpers/AztecVerificationPromptHelper.swift | |
@@ -18,8 +18,7 @@ class AztecVerificationPromptHelper: NSObject { | |
accountService = AccountService(managedObjectContext: managedObjectContext) | |
- guard accountService.isDefaultWordPressComAccount(passedAccount), | |
- passedAccount.needsEmailVerification else { | |
+ guard accountService.isDefaultWordPressComAccount(passedAccount) else { | |
// if the post the user is trying to compose isn't on a WP.com account, | |
// or they're already verified, then the verification prompt is irrelevant. | |
return nil | |
@@ -40,11 +39,12 @@ class AztecVerificationPromptHelper: NSObject { | |
} | |
func needsVerification(before action: PostEditorAction) -> Bool { | |
- guard action == .publish else { | |
- return false | |
- } | |
- | |
- return wpComAccount.needsEmailVerification | |
+// guard action == .publish else { | |
+// return false | |
+// } | |
+// | |
+// return wpComAccount.needsEmailVerification | |
+ return true | |
} | |
/// - parameter presentingViewController: UIViewController that the prompt should be presented from. | |
@@ -54,8 +54,8 @@ class AztecVerificationPromptHelper: NSObject { | |
then: AztecVerificationPromptCompletion?) { | |
let fancyAlert = FancyAlertViewController.verificationPromptController { [weak self] in | |
- let needsVerification = self?.wpComAccount.needsEmailVerification ?? true | |
- then?(!needsVerification) | |
+// let needsVerification = self?.wpComAccount.needsEmailVerification ?? true | |
+// then?(!needsVerification) | |
} | |
fancyAlert.modalPresentationStyle = .custom | |
@@ -68,24 +68,24 @@ class AztecVerificationPromptHelper: NSObject { | |
// call the completion block and let caller handle the new situation. | |
displayedAlert = fancyAlert | |
- completionBlock = then | |
+// completionBlock = then | |
} | |
@objc func updateVerificationStatus() { | |
- accountService.updateUserDetails(for: wpComAccount, | |
- success: { [weak self] in | |
- | |
- // Let's make sure the alert is still on the screen and | |
- // the verification status has changed, before we call the callback. | |
- guard let displayedAlert = self?.displayedAlert, | |
- let updatedAccount = self?.accountService.defaultWordPressComAccount(), | |
- !updatedAccount.needsEmailVerification else { | |
- return | |
- } | |
- | |
- displayedAlert.dismiss(animated: true, completion: nil) | |
- self?.completionBlock?(!updatedAccount.needsEmailVerification) | |
- }, failure: nil) | |
+// accountService.updateUserDetails(for: wpComAccount, | |
+// success: { [weak self] in | |
+// | |
+// // Let's make sure the alert is still on the screen and | |
+// // the verification status has changed, before we call the callback. | |
+// guard let displayedAlert = self?.displayedAlert, | |
+// let updatedAccount = self?.accountService.defaultWordPressComAccount(), | |
+// !updatedAccount.needsEmailVerification else { | |
+// return | |
+// } | |
+// | |
+// displayedAlert.dismiss(animated: true, completion: nil) | |
+// self?.completionBlock?(!updatedAccount.needsEmailVerification) | |
+// }, failure: nil) | |
} | |
} | |
diff --git a/WordPress/Classes/ViewRelated/Aztec/ViewControllers/AztecPostViewController.swift b/WordPress/Classes/ViewRelated/Aztec/ViewControllers/AztecPostViewController.swift | |
index 25f22a1273..02cb703caf 100644 | |
--- a/WordPress/Classes/ViewRelated/Aztec/ViewControllers/AztecPostViewController.swift | |
+++ b/WordPress/Classes/ViewRelated/Aztec/ViewControllers/AztecPostViewController.swift | |
@@ -33,6 +33,8 @@ class AztecPostViewController: UIViewController, PostEditor { | |
return self.createToolbar() | |
}() | |
+ var showOnce = false | |
+ | |
private let errorDomain = "AztecPostViewController.errorDomain" | |
private enum ErrorCode: Int { | |
@@ -1162,7 +1164,8 @@ extension AztecPostViewController { | |
} | |
// If the user is trying to publish to WP.com and they haven't verified their account, prompt them to do so. | |
- if let verificationHelper = verificationPromptHelper, verificationHelper.needsVerification(before: postEditorStateContext.action) { | |
+ if let verificationHelper = verificationPromptHelper, showOnce == false { | |
+ showOnce = true | |
verificationHelper.displayVerificationPrompt(from: self) { [unowned self] verifiedInBackground in | |
// User could've been plausibly silently verified in the background. | |
// If so, proceed to publishing the post as normal, otherwise save it as a draft. | |
diff --git a/WordPress/Classes/ViewRelated/System/FancyAlerts+VerificationPrompt.swift b/WordPress/Classes/ViewRelated/System/FancyAlerts+VerificationPrompt.swift | |
index b6041bf807..815915bf05 100644 | |
--- a/WordPress/Classes/ViewRelated/System/FancyAlerts+VerificationPrompt.swift | |
+++ b/WordPress/Classes/ViewRelated/System/FancyAlerts+VerificationPrompt.swift | |
@@ -34,6 +34,9 @@ extension FancyAlertViewController { | |
// if it was a generic failure (probably bad network), show a different message. | |
controller.setViewConfiguration(failureSendingVerificationEmailConfig(with: localError), animated: true) | |
+ DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 2.0, execute: { | |
+ controller.setViewConfiguration(myFakeConfiguration(), animated: true) | |
+ }) | |
}) | |
} | |
@@ -71,6 +74,26 @@ extension FancyAlertViewController { | |
dismissAction: nil) | |
} | |
+ private static func myFakeConfiguration() -> FancyAlertViewController.Config { | |
+ let okButton = FancyAlertViewController.Config.ButtonConfig(Strings.ok) { controller, _ in | |
+ controller.dismiss(animated: true, completion: nil) | |
+ } | |
+ | |
+ let otherButton = FancyAlertViewController.Config.ButtonConfig("Howdy") { controller, _ in | |
+ controller.dismiss(animated: true, completion: nil) | |
+ } | |
+ | |
+ return FancyAlertViewController.Config(titleText: Strings.titleText, | |
+ bodyText: Strings.emailSentSuccesfully, | |
+ headerImage: #imageLiteral(resourceName: "wp-illustration-hand-write"), | |
+ dividerPosition: .bottom, | |
+ defaultButton: okButton, | |
+ cancelButton: nil, | |
+ moreInfoButton: nil, | |
+ titleAccessoryButton: otherButton, | |
+ dismissAction: nil) | |
+ } | |
+ | |
private static func failureSendingVerificationEmailConfig(with error: VerificationFailureError) -> FancyAlertViewController.Config { | |
let okButton = FancyAlertViewController.Config.ButtonConfig(Strings.ok) { controller, _ in | |
controller.dismiss(animated: true, completion: nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment