diff --git a/Signal/src/ViewControllers/NewGroupViewController.m b/Signal/src/ViewControllers/NewGroupViewController.m index 1dd609b1b..7af2fbaab 100644 --- a/Signal/src/ViewControllers/NewGroupViewController.m +++ b/Signal/src/ViewControllers/NewGroupViewController.m @@ -50,7 +50,6 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68; @property (nonatomic) NSMutableSet *memberRecipientIds; @property (nonatomic) BOOL hasUnsavedChanges; -@property (nonatomic) BOOL shouldIgnoreSavedChanges; @property (nonatomic) BOOL hasAppeared; @end @@ -552,7 +551,7 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68; { [self.groupNameTextField resignFirstResponder]; - if (!self.hasUnsavedChanges || self.shouldIgnoreSavedChanges) { + if (!self.hasUnsavedChanges) { // If user made no changes, return to conversation settings view. [self.navigationController popViewControllerAnimated:YES]; return; @@ -571,7 +570,6 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68; @"The label for the 'discard' button in alerts and action sheets.") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { - self.shouldIgnoreSavedChanges = YES; [self.navigationController popViewControllerAnimated:YES]; }]]; [controller addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"TXT_CANCEL_TITLE", nil) @@ -655,8 +653,8 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68; - (BOOL)shouldCancelNavigationBack { - BOOL result = self.hasUnsavedChanges && !self.shouldIgnoreSavedChanges; - if (result) { + BOOL result = self.hasUnsavedChanges; + if (self.hasUnsavedChanges) { [self backButtonPressed]; } return result; diff --git a/Signal/src/ViewControllers/OWSNavigationController.h b/Signal/src/ViewControllers/OWSNavigationController.h index a47b602df..26900edde 100644 --- a/Signal/src/ViewControllers/OWSNavigationController.h +++ b/Signal/src/ViewControllers/OWSNavigationController.h @@ -8,6 +8,8 @@ // presses and back gestures should implement this protocol. @protocol OWSNavigationView +// shouldCancelNavigationBack will be called if the back button was pressed or +// if a back gesture was performed but not if the view is popped programmatically. - (BOOL)shouldCancelNavigationBack; @end diff --git a/Signal/src/ViewControllers/OWSNavigationController.m b/Signal/src/ViewControllers/OWSNavigationController.m index b1fe079ab..0f21f71d0 100644 --- a/Signal/src/ViewControllers/OWSNavigationController.m +++ b/Signal/src/ViewControllers/OWSNavigationController.m @@ -37,6 +37,8 @@ OWSAssert(self.interactivePopGestureRecognizer.delegate == self); UIViewController *topViewController = self.topViewController; + // wasBackButtonClicked is YES if the back button was pressed but not + // if a back gesture was performed or if the view is popped programmatically. BOOL wasBackButtonClicked = topViewController.navigationItem == item; BOOL result = YES; if (wasBackButtonClicked) { diff --git a/Signal/src/ViewControllers/ProfileViewController.m b/Signal/src/ViewControllers/ProfileViewController.m index 40f0a7ce5..b48343bc9 100644 --- a/Signal/src/ViewControllers/ProfileViewController.m +++ b/Signal/src/ViewControllers/ProfileViewController.m @@ -44,8 +44,6 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat @property (nonatomic) BOOL hasUnsavedChanges; -@property (nonatomic) BOOL shouldIgnoreSavedChanges; - @property (nonatomic) ProfileViewMode profileViewMode; @property (nonatomic) YapDatabaseConnection *databaseConnection; @@ -209,7 +207,7 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat { [self.nameTextField resignFirstResponder]; - if (!self.hasUnsavedChanges || self.shouldIgnoreSavedChanges) { + if (!self.hasUnsavedChanges) { // If user made no changes, return to conversation settings view. [self profileCompletedOrSkipped]; return; @@ -228,7 +226,6 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat @"The label for the 'discard' button in alerts and action sheets.") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { - self.shouldIgnoreSavedChanges = YES; [self profileCompletedOrSkipped]; }]]; [controller addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"TXT_CANCEL_TITLE", nil) @@ -500,7 +497,7 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat - (BOOL)shouldCancelNavigationBack { - BOOL result = self.hasUnsavedChanges && !self.shouldIgnoreSavedChanges; + BOOL result = self.hasUnsavedChanges; if (result) { [self backOrSkipButtonPressed]; } diff --git a/Signal/src/ViewControllers/UpdateGroupViewController.m b/Signal/src/ViewControllers/UpdateGroupViewController.m index 27ad12c2c..384367ebc 100644 --- a/Signal/src/ViewControllers/UpdateGroupViewController.m +++ b/Signal/src/ViewControllers/UpdateGroupViewController.m @@ -50,7 +50,6 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic) NSMutableSet *memberRecipientIds; @property (nonatomic) BOOL hasUnsavedChanges; -@property (nonatomic) BOOL shouldIgnoreSavedChanges; @end @@ -414,7 +413,7 @@ NS_ASSUME_NONNULL_BEGIN { [self.groupNameTextField resignFirstResponder]; - if (!self.hasUnsavedChanges || self.shouldIgnoreSavedChanges) { + if (!self.hasUnsavedChanges) { // If user made no changes, return to conversation settings view. [self.navigationController popViewControllerAnimated:YES]; return; @@ -442,7 +441,6 @@ NS_ASSUME_NONNULL_BEGIN @"The label for the 'don't save' button in action sheets.") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { - self.shouldIgnoreSavedChanges = YES; [self.navigationController popViewControllerAnimated:YES]; }]]; [self presentViewController:controller animated:YES completion:nil]; @@ -534,7 +532,7 @@ NS_ASSUME_NONNULL_BEGIN - (BOOL)shouldCancelNavigationBack { - BOOL result = self.hasUnsavedChanges && !self.shouldIgnoreSavedChanges; + BOOL result = self.hasUnsavedChanges; if (result) { [self backButtonPressed]; }