MESSENGER-5799 add settings alert save changes

This commit is contained in:
JanNiklas Grabowski
2024-04-17 12:54:22 +02:00
parent 015cc7bbc6
commit 331e033671
4 changed files with 65 additions and 0 deletions
@@ -890,6 +890,10 @@ SSOAuthenticationPresenterDelegate>
self.tableView.sectionFooterHeight = UITableViewAutomaticDimension;
self.tableView.estimatedSectionFooterHeight = 50;
// bwi: #5799 show alert if user has changed the avatar without saving it
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:[BWIL10n settingsCustomBackButton] style:UIBarButtonItemStylePlain target:self action:@selector(customBackButtonAction)];
MXWeakify(self);
// Add observer to handle removed accounts
@@ -5560,6 +5564,43 @@ SSOAuthenticationPresenterDelegate>
}
- (void) customBackButtonAction {
// bwi: #5799 show alert if user has changed the avatar without saving it
if ((nil != newAvatarImage || shouldRemoveAvatarImage) && !isSavingInProgress)
{
MXWeakify(self);
[currentAlert dismissViewControllerAnimated:NO completion:nil];
UIAlertController *saveChangesAlert = [UIAlertController alertControllerWithTitle:[BWIL10n settingsSaveChangesAlertTitle]
message:nil
preferredStyle:UIAlertControllerStyleAlert];
[saveChangesAlert addAction:[UIAlertAction actionWithTitle:[BWIL10n settingsSaveChangesAlertDoNotSaveButton] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
MXStrongifyAndReturnIfNil(self);
dispatch_async(dispatch_get_main_queue(), ^{
[self.navigationController popViewControllerAnimated:true];
});
self->currentAlert = nil;
}]];
[saveChangesAlert addAction:[UIAlertAction actionWithTitle:[BWIL10n settingsSaveChangesAlertSaveButton] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
MXStrongifyAndReturnIfNil(self);
dispatch_async(dispatch_get_main_queue(), ^{
[self onSave:nil];
});
self->currentAlert = nil;
}]];
[self presentViewController:saveChangesAlert animated:YES completion:nil];
currentAlert = saveChangesAlert;
}
else
{
[self.navigationController popViewControllerAnimated:true];
}
}
#pragma mark - ThreadsBetaCoordinatorBridgePresenterDelegate
- (void)threadsBetaCoordinatorBridgePresenterDelegateDidTapEnable:(ThreadsBetaCoordinatorBridgePresenter *)coordinatorBridgePresenter