@ -1146,18 +1146,31 @@ extension ConversationVC {
guard ! contact . isApproved else { return Promise . value ( ( ) ) }
guard ! contact . isApproved else { return Promise . value ( ( ) ) }
return Promise . value ( ( ) )
return Promise . value ( ( ) )
. then { _ -> Promise < Void > in
. then { [ weak self ] _ -> Promise < Void > in
guard ! isNewThread else { return Promise . value ( ( ) ) }
guard ! isNewThread else { return Promise . value ( ( ) ) }
guard let strongSelf = self else { return Promise ( error : MessageSender . Error . noThread ) }
// I f w e a r e n ' t c r e a t i n g a n e w t h r e a d ( i e . s e n d i n g a m e s s a g e r e q u e s t ) t h e n s e n d a
// I f w e a r e n ' t c r e a t i n g a n e w t h r e a d ( i e . s e n d i n g a m e s s a g e r e q u e s t ) t h e n s e n d a
// m e s s a g e R e q u e s t R e s p o n s e b a c k t o t h e s e n d e r ( t h i s a l l o w s t h e s e n d e r t o k n o w t h a t
// m e s s a g e R e q u e s t R e s p o n s e b a c k t o t h e s e n d e r ( t h i s a l l o w s t h e s e n d e r t o k n o w t h a t
// t h e y h a v e b e e n a p p r o v e d a n d c a n n o w u s e t h i s c o n t a c t i n c l o s e d g r o u p s )
// t h e y h a v e b e e n a p p r o v e d a n d c a n n o w u s e t h i s c o n t a c t i n c l o s e d g r o u p s )
let ( promise , seal ) = Promise < Void > . pending ( )
let messageRequestResponse : MessageRequestResponse = MessageRequestResponse (
let messageRequestResponse : MessageRequestResponse = MessageRequestResponse (
isApproved : true
isApproved : true
)
)
messageRequestResponse . sentTimestamp = timestamp
messageRequestResponse . sentTimestamp = timestamp
return MessageSender . sendNonDurably ( messageRequestResponse , in : contactThread , using : transaction )
// S h o w a l o a d i n g i n d i c a t o r
ModalActivityIndicatorViewController . present ( fromViewController : strongSelf , canCancel : false ) { _ in
seal . fulfill ( ( ) )
}
return promise
. then { MessageSender . sendNonDurably ( messageRequestResponse , in : contactThread , using : transaction ) }
. map { _ in
if self ? . presentedViewController is ModalActivityIndicatorViewController {
self ? . dismiss ( animated : true , completion : nil ) // D i s m i s s t h e l o a d e r
}
}
}
}
. map { _ in
. map { _ in
// D e f a u l t ' d i d A p p r o v e M e ' t o t r u e f o r t h e p e r s o n a p p r o v i n g t h e m e s s a g e r e q u e s t
// D e f a u l t ' d i d A p p r o v e M e ' t o t r u e f o r t h e p e r s o n a p p r o v i n g t h e m e s s a g e r e q u e s t