-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11171 from wordpress-mobile/issue/11035-replace-a…
…nnoying-alerts Offline: Replace disruptive Alerts with Notices
- Loading branch information
Showing
15 changed files
with
209 additions
and
71 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
import Foundation | ||
import WordPressFlux | ||
|
||
extension WPError { | ||
private static let noticeTag = "WPError.Networking" | ||
|
||
/// Show a Notice with the message taken from the given `error` | ||
/// | ||
/// This is similar to `showNetworkingAlertWithError` except this uses a Notice instead of | ||
/// an Alert. | ||
/// | ||
/// - parameter error: Assumed to be an error from a networking call | ||
static func showNetworkingNotice(title: String, error: NSError) { | ||
if showWPComSigninIfErrorIsInvalidAuth(error) { | ||
return | ||
} | ||
|
||
let titleAndMessage = self.titleAndMessage(fromNetworkingError: error, desiredTitle: title) | ||
|
||
let notice = Notice(title: titleAndMessage["title"] ?? "", | ||
message: titleAndMessage["message"], | ||
tag: noticeTag) | ||
ActionDispatcher.dispatch(NoticeAction.post(notice)) | ||
} | ||
|
||
/// Dismiss the currently shown Notice if it was created using showNetworkingNotice() | ||
static func dismissNetworkingNotice() { | ||
noticePresenter?.dismissCurrentNotice(tagged: noticeTag) | ||
} | ||
|
||
private static var noticePresenter: NoticePresenter? { | ||
return (UIApplication.shared.delegate as? WordPressAppDelegate)?.noticePresenter | ||
} | ||
} |
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
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
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
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
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
Oops, something went wrong.