CR: extract method for readability

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent 5b2428c8a5
commit 022292e2e5

@ -45,81 +45,75 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(flippedKey.length == currentKey.length);
[identityManager saveRemoteIdentity:flippedKey recipientId:recipientId];
}],
[OWSTableItem
itemWithTitle:@"Set Verification State"
[OWSTableItem itemWithTitle:@"Set Verification State"
actionBlock:^{
[self presentVerificationStatePickerForContactThread:contactThread];
}],
[OWSTableItem itemWithTitle:@"Delete session"
actionBlock:^{
dispatch_async([OWSDispatch sessionStoreQueue], ^{
[[TSStorageManager sharedManager]
deleteAllSessionsForContact:contactThread.contactIdentifier];
});
}],
[OWSTableItem itemWithTitle:@"Send session reset"
actionBlock:^{
[OWSSessionResetJob
runWithContactThread:contactThread
messageSender:[Environment getCurrent].messageSender
storageManager:[TSStorageManager sharedManager]];
}]
]];
}
+ (void)presentVerificationStatePickerForContactThread:(TSContactThread *)contactThread
{
DDLogError(@"%@ Choosing verification state.", self.tag);
NSString *title = [NSString
stringWithFormat:@"Choose verification state for %@", contactThread.name];
NSString *title = [NSString stringWithFormat:@"Choose verification state for %@", contactThread.name];
UIAlertController *alertController =
[UIAlertController alertControllerWithTitle:title
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
[UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleActionSheet];
NSString *recipientId = [contactThread contactIdentifier];
OWSIdentityManager *identityManger = [OWSIdentityManager sharedManager];
[alertController
addAction:[UIAlertAction
actionWithTitle:@"Default"
[alertController addAction:[UIAlertAction actionWithTitle:@"Default"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
NSData *identityKey = [identityManger
identityKeyForRecipientId:recipientId];
NSData *identityKey =
[identityManger identityKeyForRecipientId:recipientId];
[[OWSIdentityManager sharedManager]
setVerificationState:OWSVerificationStateDefault
identityKey:identityKey
recipientId:recipientId
sendSyncMessage:NO];
}]];
[alertController
addAction:[UIAlertAction
actionWithTitle:@"Verified"
[alertController addAction:[UIAlertAction actionWithTitle:@"Verified"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
NSData *identityKey = [identityManger
identityKeyForRecipientId:recipientId];
NSData *identityKey =
[identityManger identityKeyForRecipientId:recipientId];
[[OWSIdentityManager sharedManager]
setVerificationState:OWSVerificationStateVerified
identityKey:identityKey
recipientId:recipientId
sendSyncMessage:NO];
}]];
[alertController
addAction:[UIAlertAction actionWithTitle:@"No Longer Verified"
[alertController addAction:[UIAlertAction actionWithTitle:@"No Longer Verified"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
NSData *identityKey = [identityManger
identityKeyForRecipientId:recipientId];
NSData *identityKey =
[identityManger identityKeyForRecipientId:recipientId];
[[OWSIdentityManager sharedManager]
setVerificationState:
OWSVerificationStateNoLongerVerified
setVerificationState:OWSVerificationStateNoLongerVerified
identityKey:identityKey
recipientId:recipientId
sendSyncMessage:NO];
}]];
[[UIApplication sharedApplication].frontmostViewController
presentViewController:alertController
[[UIApplication sharedApplication].frontmostViewController presentViewController:alertController
animated:YES
completion:nil];
}],
[OWSTableItem itemWithTitle:@"Delete session"
actionBlock:^{
dispatch_async([OWSDispatch sessionStoreQueue], ^{
[[TSStorageManager sharedManager]
deleteAllSessionsForContact:contactThread.contactIdentifier];
});
}],
[OWSTableItem itemWithTitle:@"Send session reset"
actionBlock:^{
[OWSSessionResetJob
runWithContactThread:contactThread
messageSender:[Environment getCurrent].messageSender
storageManager:[TSStorageManager sharedManager]];
}]
]];
}
#pragma mark - Logging

Loading…
Cancel
Save