Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Belouosv <aleksey@maps.me>2019-08-22 14:00:24 +0300
committerZoia <niakris90@gmail.com>2019-08-22 15:42:41 +0300
commit2878efc99841b9dd5f4d0e963c42aa5b8e744707 (patch)
tree97da5fa580ca07299d639cdd215c952094a7f0b7
parent6f042beb65146e22ff63727b0051249aa4b72cf8 (diff)
[iOS] restore all subsriptions from settingsios-release-923-2
https://jira.mail.ru/browse/MAPSME-11572
-rw-r--r--iphone/Maps/Categories/UIViewController+Authorization.swift2
-rw-r--r--iphone/Maps/UI/Settings/MWMSettingsViewController.mm64
2 files changed, 44 insertions, 22 deletions
diff --git a/iphone/Maps/Categories/UIViewController+Authorization.swift b/iphone/Maps/Categories/UIViewController+Authorization.swift
index 6df2a35080..67e2981345 100644
--- a/iphone/Maps/Categories/UIViewController+Authorization.swift
+++ b/iphone/Maps/Categories/UIViewController+Authorization.swift
@@ -1,5 +1,5 @@
extension UIViewController {
- func signup(anchor: UIView, onComplete: @escaping (Bool) -> Void) {
+ @objc func signup(anchor: UIView, onComplete: @escaping (Bool) -> Void) {
if MWMAuthorizationViewModel.isAuthenticated() {
onComplete(true)
} else {
diff --git a/iphone/Maps/UI/Settings/MWMSettingsViewController.mm b/iphone/Maps/UI/Settings/MWMSettingsViewController.mm
index fe086a8b52..7b48af0d2f 100644
--- a/iphone/Maps/UI/Settings/MWMSettingsViewController.mm
+++ b/iphone/Maps/UI/Settings/MWMSettingsViewController.mm
@@ -369,29 +369,11 @@ using namespace power_management;
else if (cell == self.restoreSubscriptionCell)
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
- [self.restoreSubscriptionCell.progress startAnimating];
- self.restoringSubscription = YES;
__weak auto s = self;
- [[InAppPurchase adsRemovalSubscriptionManager] restore:^(MWMValidationResult result) {
- __strong auto self = s;
- self.restoringSubscription = NO;
- [self.restoreSubscriptionCell.progress stopAnimating];
- NSString *alertText;
- switch (result)
- {
- case MWMValidationResultValid:
- alertText = L(@"restore_success_alert");
- break;
- case MWMValidationResultNotValid:
- alertText = L(@"restore_no_subscription_alert");
- break;
- case MWMValidationResultServerError:
- case MWMValidationResultAuthError:
- alertText = L(@"restore_error_alert");
- break;
+ [self signupWithAnchor:self.restoreSubscriptionCell.progress onComplete:^(BOOL success) {
+ if (success) {
+ [s restoreSubscription];
}
- [MWMAlertViewController.activeAlertController presentInfoAlert:L(@"restore_subscription")
- text:alertText];
}];
}
else if (cell == self.manageSubscriptionsCell)
@@ -451,4 +433,44 @@ using namespace power_management;
}];
}
+#pragma mark - RestoreSubscription
+
+- (void)restoreSubscription {
+ dispatch_group_t dispatchGroup = dispatch_group_create();
+
+ [self.restoreSubscriptionCell.progress startAnimating];
+ self.restoringSubscription = YES;
+ __block MWMValidationResult adsResult;
+ __block MWMValidationResult bookmarksResult;
+
+ dispatch_group_enter(dispatchGroup);
+ [[InAppPurchase adsRemovalSubscriptionManager] restore:^(MWMValidationResult result) {
+ adsResult = result;
+ dispatch_group_leave(dispatchGroup);
+ }];
+
+ dispatch_group_enter(dispatchGroup);
+ [[InAppPurchase bookmarksSubscriptionManager] restore:^(MWMValidationResult result) {
+ bookmarksResult = result;
+ dispatch_group_leave(dispatchGroup);
+ }];
+
+ __weak auto s = self;
+ dispatch_group_notify(dispatchGroup, dispatch_get_main_queue(), ^{
+ __strong auto self = s;
+ self.restoringSubscription = NO;
+ [self.restoreSubscriptionCell.progress stopAnimating];
+ NSString *alertText;
+ if (adsResult == MWMValidationResultNotValid && bookmarksResult == MWMValidationResultNotValid) {
+ alertText = L(@"restore_no_subscription_alert");
+ } else if (adsResult == MWMValidationResultValid || bookmarksResult == MWMValidationResultValid) {
+ alertText = L(@"restore_success_alert");
+ } else {
+ alertText = L(@"restore_error_alert");
+ }
+ [MWMAlertViewController.activeAlertController presentInfoAlert:L(@"restore_subscription")
+ text:alertText];
+ });
+}
+
@end