RoomVC: Add a re-request keys button on message unable to decrypt

#1879
This commit is contained in:
manuroe
2018-06-08 17:21:52 +02:00
parent 822a165b86
commit cfe867d991
4 changed files with 104 additions and 1 deletions
+46
View File
@@ -117,6 +117,8 @@
#import "WidgetPickerViewController.h"
#import "StickerPickerViewController.h"
#import "EventFormatter.h"
@interface RoomViewController ()
{
// The expanded header
@@ -2680,6 +2682,20 @@
NSString *fragment = [NSString stringWithFormat:@"/group/%@", [absoluteURLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[AppDelegate theDelegate] handleUniversalLinkFragment:fragment];
}
else if ([absoluteURLString hasPrefix:kEventFormatterOnReRequestKeysLinkAction])
{
NSArray<NSString*> *arguments = [absoluteURLString componentsSeparatedByString:kEventFormatterOnReRequestKeysLinkActionSeparator];
if (arguments.count > 1)
{
NSString *eventId = arguments[1];
MXEvent *event = [self.roomDataSource eventWithEventId:eventId];
if (event)
{
[self showRerequestConfirmationAlert:event];
}
}
}
}
return shouldDoAction;
@@ -4582,5 +4598,35 @@
[self presentViewController:currentAlert animated:YES completion:nil];
}
#pragma mark - Re-request encryption keys
- (void)showRerequestConfirmationAlert:(MXEvent*)event
{
currentAlert = [UIAlertController alertControllerWithTitle:NSLocalizedStringFromTable(@"rerequest_keys_alert_title", @"Vector", nil)
message:NSLocalizedStringFromTable(@"rerequest_keys_alert_message", @"Vector", nil)
preferredStyle:UIAlertControllerStyleAlert];
MXWeakify(self);
[currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
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];
}
@end