mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-16 04:40:01 +02:00
RoomVC: Add a re-request keys button on message unable to decrypt
The flow has changed a bit. #1879
This commit is contained in:
@@ -2692,7 +2692,7 @@
|
||||
|
||||
if (event)
|
||||
{
|
||||
[self showRerequestConfirmationAlert:event];
|
||||
[self reRequestKeysAndShowExplanationAlert:event];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4600,31 +4600,51 @@
|
||||
|
||||
#pragma mark - Re-request encryption keys
|
||||
|
||||
- (void)showRerequestConfirmationAlert:(MXEvent*)event
|
||||
- (void)reRequestKeysAndShowExplanationAlert:(MXEvent*)event
|
||||
{
|
||||
currentAlert = [UIAlertController alertControllerWithTitle:NSLocalizedStringFromTable(@"rerequest_keys_alert_title", @"Vector", nil)
|
||||
MXWeakify(self);
|
||||
__block UIAlertController *alert;
|
||||
|
||||
// Make the re-request
|
||||
[self.mainSession.crypto reRequestRoomKeyForEvent:event];
|
||||
|
||||
// Observe kMXEventDidDecryptNotification to remove automatically the dialog
|
||||
// if the user has shared the keys from another device
|
||||
id didDecryptObserver;
|
||||
didDecryptObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXEventDidDecryptNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
|
||||
|
||||
MXEvent *decryptedEvent = notif.object;
|
||||
|
||||
if ([decryptedEvent.eventId isEqualToString:event.eventId])
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:didDecryptObserver];
|
||||
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
if (self->currentAlert == alert)
|
||||
{
|
||||
[self->currentAlert dismissViewControllerAnimated:YES completion:nil];
|
||||
self->currentAlert = nil;
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
// Show the explanation dialog
|
||||
alert = [UIAlertController alertControllerWithTitle:NSLocalizedStringFromTable(@"rerequest_keys_alert_title", @"Vector", nil)
|
||||
message:NSLocalizedStringFromTable(@"rerequest_keys_alert_message", @"Vector", nil)
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
currentAlert = alert;
|
||||
|
||||
MXWeakify(self);
|
||||
[currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"]
|
||||
|
||||
[alert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"ok"]
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction * action)
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:didDecryptObserver];
|
||||
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
self->currentAlert = nil;
|
||||
}]];
|
||||
|
||||
[currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"rerequest_keys_alert_button", @"Vector", nil)
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction * action)
|
||||
{
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
self->currentAlert = nil;
|
||||
|
||||
[self.mainSession.crypto reRequestRoomKeyForEvent:event];
|
||||
}]];
|
||||
|
||||
[self presentViewController:currentAlert animated:YES completion:nil];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user