@@ -192,7 +192,7 @@ extension ConversationVC:
192
192
threadVariant: SessionThread . Variant ,
193
193
messageText: String ?
194
194
) {
195
- sendMessage ( text: ( messageText ?? " " ) , attachments: attachments, using : viewModel . dependencies )
195
+ sendMessage ( text: ( messageText ?? " " ) , attachments: attachments)
196
196
resetMentions ( )
197
197
198
198
dismiss ( animated: true ) { [ weak self] in
@@ -222,7 +222,7 @@ extension ConversationVC:
222
222
threadVariant: SessionThread . Variant ,
223
223
messageText: String ?
224
224
) {
225
- sendMessage ( text: ( messageText ?? " " ) , attachments: attachments, using : viewModel . dependencies )
225
+ sendMessage ( text: ( messageText ?? " " ) , attachments: attachments)
226
226
resetMentions ( )
227
227
228
228
dismiss ( animated: true ) { [ weak self] in
@@ -298,7 +298,7 @@ extension ConversationVC:
298
298
let threadId : String = self . viewModel. threadData. threadId
299
299
let threadVariant : SessionThread . Variant = self . viewModel. threadData. threadVariant
300
300
301
- Permissions . requestLibraryPermissionIfNeeded { [ weak self, dependencies = viewModel. dependencies] in
301
+ Permissions . requestLibraryPermissionIfNeeded ( isSavingMedia : false ) { [ weak self, dependencies = viewModel. dependencies] in
302
302
DispatchQueue . main. async {
303
303
let sendMediaNavController = SendMediaNavigationController . showingMediaLibraryFirst (
304
304
threadId: threadId,
@@ -467,8 +467,7 @@ extension ConversationVC:
467
467
attachments: [ SignalAttachment ] = [ ] ,
468
468
linkPreviewDraft: LinkPreviewDraft ? = nil ,
469
469
quoteModel: QuotedReplyModel ? = nil ,
470
- hasPermissionToSendSeed: Bool = false ,
471
- using dependencies: Dependencies = Dependencies ( )
470
+ hasPermissionToSendSeed: Bool = false
472
471
) {
473
472
guard !showBlockedModalIfNeeded( ) else { return }
474
473
@@ -539,17 +538,14 @@ extension ConversationVC:
539
538
quoteModel: quoteModel
540
539
)
541
540
542
- sendMessage ( optimisticData: optimisticData, using : dependencies )
541
+ sendMessage ( optimisticData: optimisticData)
543
542
}
544
543
545
- private func sendMessage(
546
- optimisticData: ConversationViewModel . OptimisticMessageData ,
547
- using dependencies: Dependencies
548
- ) {
544
+ private func sendMessage( optimisticData: ConversationViewModel . OptimisticMessageData ) {
549
545
let threadId : String = self . viewModel. threadData. threadId
550
546
let threadVariant : SessionThread . Variant = self . viewModel. threadData. threadVariant
551
547
552
- DispatchQueue . global ( qos: . userInitiated) . async ( using: dependencies) {
548
+ DispatchQueue . global ( qos: . userInitiated) . async ( using: viewModel . dependencies) { [ dependencies = viewModel . dependencies ] in
553
549
// Generate the quote thumbnail if needed (want this to happen outside of the DBWrite thread as
554
550
// this can take up to 0.5s
555
551
let quoteThumbnailAttachment : Attachment ? = optimisticData. quoteModel? . attachment? . cloneAsQuoteThumbnail ( )
@@ -902,8 +898,22 @@ extension ConversationVC:
902
898
903
899
// For call info messages show the "call missed" modal
904
900
guard cellViewModel. variant != . infoCall else {
905
- let callMissedTipsModal : CallMissedTipsModal = CallMissedTipsModal ( caller: cellViewModel. authorName)
906
- present ( callMissedTipsModal, animated: true , completion: nil )
901
+ // If the failure was due to the mic permission being denied then we want to show the permission modal,
902
+ // otherwise we want to show the call missed tips modal
903
+ guard
904
+ let infoMessageData: Data = ( cellViewModel. rawBody ?? " " ) . data ( using: . utf8) ,
905
+ let messageInfo: CallMessage . MessageInfo = try ? JSONDecoder ( ) . decode (
906
+ CallMessage . MessageInfo. self,
907
+ from: infoMessageData
908
+ ) ,
909
+ messageInfo. state == . permissionDeniedMicrophone
910
+ else {
911
+ let callMissedTipsModal : CallMissedTipsModal = CallMissedTipsModal ( caller: cellViewModel. authorName)
912
+ present ( callMissedTipsModal, animated: true , completion: nil )
913
+ return
914
+ }
915
+
916
+ Permissions . requestMicrophonePermissionIfNeeded ( presentingViewController: self )
907
917
return
908
918
}
909
919
@@ -1891,7 +1901,7 @@ extension ConversationVC:
1891
1901
}
1892
1902
1893
1903
// Try to send the optimistic message again
1894
- sendMessage ( optimisticData: optimisticMessageData, using : dependencies )
1904
+ sendMessage ( optimisticData: optimisticMessageData)
1895
1905
return
1896
1906
}
1897
1907
@@ -2326,30 +2336,35 @@ extension ConversationVC:
2326
2336
2327
2337
guard !mediaAttachments. isEmpty else { return }
2328
2338
2329
- mediaAttachments. forEach { attachment, originalFilePath in
2330
- PHPhotoLibrary . shared ( ) . performChanges (
2331
- {
2332
- if attachment. isImage || attachment. isAnimated {
2333
- PHAssetChangeRequest . creationRequestForAssetFromImage (
2334
- atFileURL: URL ( fileURLWithPath: originalFilePath)
2335
- )
2336
- }
2337
- else if attachment. isVideo {
2338
- PHAssetChangeRequest . creationRequestForAssetFromVideo (
2339
- atFileURL: URL ( fileURLWithPath: originalFilePath)
2340
- )
2341
- }
2342
- } ,
2343
- completionHandler: { _, _ in }
2344
- )
2345
- }
2346
-
2347
- // Send a 'media saved' notification if needed
2348
- guard self . viewModel. threadData. threadVariant == . contact, cellViewModel. variant == . standardIncoming else {
2349
- return
2339
+ Permissions . requestLibraryPermissionIfNeeded (
2340
+ isSavingMedia: true ,
2341
+ presentingViewController: self
2342
+ ) { [ weak self] in
2343
+ mediaAttachments. forEach { attachment, originalFilePath in
2344
+ PHPhotoLibrary . shared ( ) . performChanges (
2345
+ {
2346
+ if attachment. isImage || attachment. isAnimated {
2347
+ PHAssetChangeRequest . creationRequestForAssetFromImage (
2348
+ atFileURL: URL ( fileURLWithPath: originalFilePath)
2349
+ )
2350
+ }
2351
+ else if attachment. isVideo {
2352
+ PHAssetChangeRequest . creationRequestForAssetFromVideo (
2353
+ atFileURL: URL ( fileURLWithPath: originalFilePath)
2354
+ )
2355
+ }
2356
+ } ,
2357
+ completionHandler: { _, _ in }
2358
+ )
2359
+ }
2360
+
2361
+ // Send a 'media saved' notification if needed
2362
+ guard self ? . viewModel. threadData. threadVariant == . contact, cellViewModel. variant == . standardIncoming else {
2363
+ return
2364
+ }
2365
+
2366
+ self ? . sendDataExtraction ( kind: . mediaSaved( timestamp: UInt64 ( cellViewModel. timestampMs) ) )
2350
2367
}
2351
-
2352
- sendDataExtraction ( kind: . mediaSaved( timestamp: UInt64 ( cellViewModel. timestampMs) ) )
2353
2368
}
2354
2369
2355
2370
func ban( _ cellViewModel: MessageViewModel , using dependencies: Dependencies ) {
@@ -2598,7 +2613,7 @@ extension ConversationVC:
2598
2613
}
2599
2614
2600
2615
// Send attachment
2601
- sendMessage ( text: " " , attachments: [ attachment] , using : dependencies )
2616
+ sendMessage ( text: " " , attachments: [ attachment] )
2602
2617
}
2603
2618
2604
2619
func cancelVoiceMessageRecording( ) {
0 commit comments