CR: extract method for readability

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

@ -45,81 +45,75 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(flippedKey.length == currentKey.length); OWSAssert(flippedKey.length == currentKey.length);
[identityManager saveRemoteIdentity:flippedKey recipientId:recipientId]; [identityManager saveRemoteIdentity:flippedKey recipientId:recipientId];
}], }],
[OWSTableItem [OWSTableItem itemWithTitle:@"Set Verification State"
itemWithTitle:@"Set Verification State"
actionBlock:^{ 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); DDLogError(@"%@ Choosing verification state.", self.tag);
NSString *title = [NSString NSString *title = [NSString stringWithFormat:@"Choose verification state for %@", contactThread.name];
stringWithFormat:@"Choose verification state for %@", contactThread.name];
UIAlertController *alertController = UIAlertController *alertController =
[UIAlertController alertControllerWithTitle:title [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleActionSheet];
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
NSString *recipientId = [contactThread contactIdentifier]; NSString *recipientId = [contactThread contactIdentifier];
OWSIdentityManager *identityManger = [OWSIdentityManager sharedManager]; OWSIdentityManager *identityManger = [OWSIdentityManager sharedManager];
[alertController [alertController addAction:[UIAlertAction actionWithTitle:@"Default"
addAction:[UIAlertAction
actionWithTitle:@"Default"
style:UIAlertActionStyleDefault style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) { handler:^(UIAlertAction *_Nonnull action) {
NSData *identityKey = [identityManger NSData *identityKey =
identityKeyForRecipientId:recipientId]; [identityManger identityKeyForRecipientId:recipientId];
[[OWSIdentityManager sharedManager] [[OWSIdentityManager sharedManager]
setVerificationState:OWSVerificationStateDefault setVerificationState:OWSVerificationStateDefault
identityKey:identityKey identityKey:identityKey
recipientId:recipientId recipientId:recipientId
sendSyncMessage:NO]; sendSyncMessage:NO];
}]]; }]];
[alertController [alertController addAction:[UIAlertAction actionWithTitle:@"Verified"
addAction:[UIAlertAction
actionWithTitle:@"Verified"
style:UIAlertActionStyleDefault style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) { handler:^(UIAlertAction *_Nonnull action) {
NSData *identityKey = [identityManger NSData *identityKey =
identityKeyForRecipientId:recipientId]; [identityManger identityKeyForRecipientId:recipientId];
[[OWSIdentityManager sharedManager] [[OWSIdentityManager sharedManager]
setVerificationState:OWSVerificationStateVerified setVerificationState:OWSVerificationStateVerified
identityKey:identityKey identityKey:identityKey
recipientId:recipientId recipientId:recipientId
sendSyncMessage:NO]; sendSyncMessage:NO];
}]]; }]];
[alertController [alertController addAction:[UIAlertAction actionWithTitle:@"No Longer Verified"
addAction:[UIAlertAction actionWithTitle:@"No Longer Verified"
style:UIAlertActionStyleDefault style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) { handler:^(UIAlertAction *_Nonnull action) {
NSData *identityKey = [identityManger NSData *identityKey =
identityKeyForRecipientId:recipientId]; [identityManger identityKeyForRecipientId:recipientId];
[[OWSIdentityManager sharedManager] [[OWSIdentityManager sharedManager]
setVerificationState: setVerificationState:OWSVerificationStateNoLongerVerified
OWSVerificationStateNoLongerVerified
identityKey:identityKey identityKey:identityKey
recipientId:recipientId recipientId:recipientId
sendSyncMessage:NO]; sendSyncMessage:NO];
}]]; }]];
[[UIApplication sharedApplication].frontmostViewController [[UIApplication sharedApplication].frontmostViewController presentViewController:alertController
presentViewController:alertController
animated:YES animated:YES
completion:nil]; 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 #pragma mark - Logging

Loading…
Cancel
Save