Respond to CR.

// FREEBIE
pull/1/head
Matthew Chen 9 years ago
parent dd3d63623a
commit 2f3831e04b

@ -150,7 +150,8 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
[OWSSyncPushTokensJob runWithPushManager:[PushManager sharedManager] [OWSSyncPushTokensJob runWithPushManager:[PushManager sharedManager]
accountManager:[Environment getCurrent].accountManager accountManager:[Environment getCurrent].accountManager
preferences:[Environment preferences]]; preferences:[Environment preferences]
showAlerts:NO];
// Clean up any messages that expired since last launch. // Clean up any messages that expired since last launch.
[[[OWSDisappearingMessagesJob alloc] initWithStorageManager:[TSStorageManager sharedManager]] run]; [[[OWSDisappearingMessagesJob alloc] initWithStorageManager:[TSStorageManager sharedManager]] run];

@ -11,15 +11,17 @@ class SyncPushTokensJob: NSObject {
let pushManager: PushManager let pushManager: PushManager
let accountManager: AccountManager let accountManager: AccountManager
let preferences: PropertyListPreferences let preferences: PropertyListPreferences
let showAlerts: Bool
required init(pushManager: PushManager, accountManager: AccountManager, preferences: PropertyListPreferences) { required init(pushManager: PushManager, accountManager: AccountManager, preferences: PropertyListPreferences, showAlerts: Bool) {
self.pushManager = pushManager self.pushManager = pushManager
self.accountManager = accountManager self.accountManager = accountManager
self.preferences = preferences self.preferences = preferences
self.showAlerts = showAlerts
} }
@objc class func run(pushManager: PushManager, accountManager: AccountManager, preferences: PropertyListPreferences) { @objc class func run(pushManager: PushManager, accountManager: AccountManager, preferences: PropertyListPreferences, showAlerts: Bool = false) {
let job = self.init(pushManager: pushManager, accountManager: accountManager, preferences: preferences) let job = self.init(pushManager: pushManager, accountManager: accountManager, preferences: preferences, showAlerts:showAlerts)
job.run() job.run()
} }
@ -42,8 +44,15 @@ class SyncPushTokensJob: NSObject {
} }
}.then { }.then {
Logger.debug("\(self.TAG) Successfully ran syncPushTokensJob.") Logger.debug("\(self.TAG) Successfully ran syncPushTokensJob.")
if self.showAlerts {
OWSAlerts.showAlert(withTitle:NSLocalizedString("PUSH_REGISTER_SUCCESS", comment: "Title of alert shown when push tokens sync job succeeds."))
}
return Promise(value: ())
}.catch { error in }.catch { error in
Logger.error("\(self.TAG) Failed to run syncPushTokensJob with error: \(error).") Logger.error("\(self.TAG) Failed to run syncPushTokensJob with error: \(error).")
if self.showAlerts {
OWSAlerts.showAlert(withTitle:NSLocalizedString("REGISTRATION_BODY", comment: "Title of alert shown when push tokens sync job fails."))
}
} }
runPromise.retainUntilComplete() runPromise.retainUntilComplete()

@ -131,7 +131,8 @@ typedef NS_ENUM(NSInteger, AdvancedSettingsTableViewControllerSection) {
} else if ([tableView cellForRowAtIndexPath:indexPath] == self.registerPushCell) { } else if ([tableView cellForRowAtIndexPath:indexPath] == self.registerPushCell) {
[OWSSyncPushTokensJob runWithPushManager:[PushManager sharedManager] [OWSSyncPushTokensJob runWithPushManager:[PushManager sharedManager]
accountManager:[Environment getCurrent].accountManager accountManager:[Environment getCurrent].accountManager
preferences:[Environment preferences]]; preferences:[Environment preferences]
showAlerts:YES];
} else { } else {
DDLogDebug(@"%@ Ignoring cell selection at indexPath: %@", self.tag, indexPath); DDLogDebug(@"%@ Ignoring cell selection at indexPath: %@", self.tag, indexPath);
} }

@ -338,7 +338,8 @@ NSString *const SignalsViewControllerSegueShowIncomingCall = @"ShowIncomingCallS
{ {
[OWSSyncPushTokensJob runWithPushManager:[PushManager sharedManager] [OWSSyncPushTokensJob runWithPushManager:[PushManager sharedManager]
accountManager:self.accountManager accountManager:self.accountManager
preferences:[Environment preferences]]; preferences:[Environment preferences]
showAlerts:NO];
} }
- (void)tableViewSetUp { - (void)tableViewSetUp {

@ -24,17 +24,20 @@ import Foundation
} }
public class func showAlert(withTitle title: String) { public class func showAlert(withTitle title: String) {
self.showAlert(withTitle: title, message: nil, buttonTitle: NSLocalizedString("OK", comment: "")) self.showAlert(withTitle: title, message: nil, buttonTitle: nil)
} }
public class func showAlert(withTitle title: String, message: String) { public class func showAlert(withTitle title: String, message: String) {
self.showAlert(withTitle: title, message: message, buttonTitle: NSLocalizedString("OK", comment: "")) self.showAlert(withTitle: title, message: message, buttonTitle: nil)
} }
public class func showAlert(withTitle title: String, message: String?, buttonTitle: String) { public class func showAlert(withTitle title: String, message: String? = nil, buttonTitle: String? = nil) {
assert(title.characters.count > 0) assert(title.characters.count > 0)
let actionTitle = (buttonTitle != nil ? buttonTitle : NSLocalizedString("OK", comment: ""))
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert) let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: buttonTitle, style: .default, handler: nil)) alert.addAction(UIAlertAction(title: actionTitle, style: .default, handler: nil))
UIApplication.shared.frontmostViewController?.present(alert, animated: true, completion: nil) UIApplication.shared.frontmostViewController?.present(alert, animated: true, completion: nil)
} }
} }

Loading…
Cancel
Save