@ -18,13 +18,22 @@ class SafetyNumberConfirmationAlert: NSObject {
}
public class func presentAlertIfNecessary ( recipientId : String , confirmationText : String , contactsManager : OWSContactsManager , completion : @ escaping ( Bool ) -> Void ) -> Bool {
return self . presentAlertIfNecessary ( recipientIds : [ recipientId ] , confirmationText : confirmationText , contactsManager : contactsManager , completion : completion )
return self . presentAlertIfNecessary ( recipientIds : [ recipientId ] , confirmationText : confirmationText , contactsManager : contactsManager , completion : completion , beforePresentationHandler : nil )
}
public class func presentAlertIfNecessary ( recipientId : String , confirmationText : String , contactsManager : OWSContactsManager , completion : @ escaping ( Bool ) -> Void , beforePresentationHandler : ( ( ) -> Void ) ? = nil ) -> Bool {
return self . presentAlertIfNecessary ( recipientIds : [ recipientId ] , confirmationText : confirmationText , contactsManager : contactsManager , completion : completion , beforePresentationHandler : beforePresentationHandler )
}
public class func presentAlertIfNecessary ( recipientIds : [ String ] , confirmationText : String , contactsManager : OWSContactsManager , completion : @ escaping ( Bool ) -> Void ) -> Bool {
return self . presentAlertIfNecessary ( recipientIds : recipientIds , confirmationText : confirmationText , contactsManager : contactsManager , completion : completion , beforePresentationHandler : nil )
}
public class func presentAlertIfNecessary ( recipientIds : [ String ] , confirmationText : String , contactsManager : OWSContactsManager , completion : @ escaping ( Bool ) -> Void , beforePresentationHandler : ( ( ) -> Void ) ? = nil ) -> Bool {
return SafetyNumberConfirmationAlert ( contactsManager : contactsManager ) . presentIfNecessary ( recipientIds : recipientIds ,
confirmationText : confirmationText ,
completion : completion )
completion : completion ,
beforePresentationHandler : beforePresentationHandler )
}
/* *
@ -33,7 +42,7 @@ class SafetyNumberConfirmationAlert: NSObject {
* @ returns true if an alert was shown
* false if there were no unconfirmed identities
*/
public func presentIfNecessary ( recipientIds : [ String ] , confirmationText : String , completion : @ escaping ( Bool ) -> Void ) -> Bool {
public func presentIfNecessary ( recipientIds : [ String ] , confirmationText : String , completion : @ escaping ( Bool ) -> Void , beforePresentationHandler : ( ( ) -> Void ) ? = nil ) -> Bool {
guard let untrustedIdentity = untrustedIdentityForSending ( recipientIds : recipientIds ) else {
// N o i d e n t i t i e s t o c o n f i r m , n o a l e r t t o p r e s e n t .
@ -75,7 +84,15 @@ class SafetyNumberConfirmationAlert: NSObject {
}
actionSheetController . addAction ( showSafetyNumberAction )
actionSheetController . addAction ( OWSAlerts . cancelAction )
// W e c a n ' t u s e t h e d e f a u l t ` O W S A l e r t s . c a n c e l A c t i o n ` b e c a u s e w e n e e d t o s p e c i f y t h a t t h e c o m p l e t i o n
// h a n d l e r i s c a l l e d .
let cancelAction = UIAlertAction ( title : CommonStrings . cancelButton , style : . cancel ) { _ in
Logger . info ( " \( self . logTag ) user canceled. " )
completion ( false )
}
actionSheetController . addAction ( cancelAction )
beforePresentationHandler ? ( )
UIApplication . shared . frontmostViewController ? . present ( actionSheetController , animated : true )
return true