@@ -105,12 +105,7 @@ class ConversationViewController: UIViewController {
105
105
private( set) lazy var imagePickerController = ImagePickerController ( initialCameraPosition: . rear, cropImageAfterPicked: false , parent: self , delegate: self )
106
106
107
107
private lazy var userHandleViewController = R . storyboard. chat. user_handle ( ) !
108
- private lazy var multipleSelectionActionView : MultipleSelectionActionView = {
109
- let view = R . nib. multipleSelectionActionView ( owner: self ) !
110
- view. delegate = self
111
- view. showCancelButton = false
112
- return view
113
- } ( )
108
+ private lazy var multipleSelectionActionView = R . nib. multipleSelectionActionView ( owner: self ) !
114
109
private lazy var announcementBadgeContentView = R . nib. announcementBadgeContentView ( owner: self ) !
115
110
116
111
private lazy var strangerHintView : StrangerHintView = {
@@ -521,6 +516,51 @@ class ConversationViewController: UIViewController {
521
516
}
522
517
}
523
518
519
+ @IBAction func multipleSelectionAction( _ sender: Any ) {
520
+ switch multipleSelectionActionView. intent {
521
+ case . forward:
522
+ let messages = dataSource. selectedViewModels. values
523
+ . map ( { $0. message } )
524
+ . sorted ( by: { $0. createdAt < $1. createdAt } )
525
+ let containsTranscriptMessage = messages. contains {
526
+ $0. category. hasSuffix ( " _TRANSCRIPT " )
527
+ }
528
+ if messages. count == 1 || containsTranscriptMessage {
529
+ let vc = MessageReceiverViewController . instance ( content: . messages( messages) )
530
+ navigationController? . pushViewController ( vc, animated: true )
531
+ } else {
532
+ let alert = UIAlertController ( title: nil , message: nil , preferredStyle: . actionSheet)
533
+ alert. addAction ( UIAlertAction ( title: R . string. localizable. chat_forward_one_by_one ( ) , style: . default, handler: { ( _) in
534
+ let vc = MessageReceiverViewController . instance ( content: . messages( messages) )
535
+ self . navigationController? . pushViewController ( vc, animated: true )
536
+ } ) )
537
+ alert. addAction ( UIAlertAction ( title: R . string. localizable. chat_forward_combined ( ) , style: . default, handler: { ( _) in
538
+ let vc = MessageReceiverViewController . instance ( content: . transcript( messages) )
539
+ self . navigationController? . pushViewController ( vc, animated: true )
540
+ } ) )
541
+ alert. addAction ( UIAlertAction ( title: R . string. localizable. dialog_button_cancel ( ) , style: . cancel, handler: nil ) )
542
+ present ( alert, animated: true , completion: nil )
543
+ }
544
+ case . delete:
545
+ let viewModels = dataSource. selectedViewModels. values. map ( { $0 } )
546
+ let controller = UIAlertController ( title: nil , message: nil , preferredStyle: . actionSheet)
547
+ if !viewModels. contains ( where: { $0. message. userId != myUserId || !$0. message. canRecall } ) {
548
+ controller. addAction ( UIAlertAction ( title: Localized . ACTION_DELETE_EVERYONE, style: . destructive, handler: { ( _) in
549
+ if AppGroupUserDefaults . User. hasShownRecallTips {
550
+ self . deleteForEveryone ( viewModels: viewModels)
551
+ } else {
552
+ self . showRecallTips ( viewModels: viewModels)
553
+ }
554
+ } ) )
555
+ }
556
+ controller. addAction ( UIAlertAction ( title: Localized . ACTION_DELETE_ME, style: . destructive, handler: { ( _) in
557
+ self . deleteForMe ( viewModels: viewModels)
558
+ } ) )
559
+ controller. addAction ( UIAlertAction ( title: Localized . DIALOG_BUTTON_CANCEL, style: . cancel, handler: nil ) )
560
+ self . present ( controller, animated: true , completion: nil )
561
+ }
562
+ }
563
+
524
564
@IBAction func dismissAnnouncementBadgeAction( _ sender: Any ) {
525
565
if dataSource. category == . group {
526
566
AppGroupUserDefaults . User. hasUnreadAnnouncement. removeValue ( forKey: conversationId)
@@ -1299,55 +1339,6 @@ class ConversationViewController: UIViewController {
1299
1339
1300
1340
}
1301
1341
1302
- extension ConversationViewController : MultipleSelectionActionViewDelegate {
1303
-
1304
- func multipleSelectionActionViewDidTapAction( _ view: MultipleSelectionActionView ) {
1305
- switch view. intent {
1306
- case . forward:
1307
- let messages = dataSource. selectedViewModels. values
1308
- . map ( { $0. message } )
1309
- . sorted ( by: { $0. createdAt < $1. createdAt } )
1310
- let containsTranscriptMessage = messages. contains {
1311
- $0. category. hasSuffix ( " _TRANSCRIPT " )
1312
- }
1313
- if messages. count == 1 || containsTranscriptMessage {
1314
- let vc = MessageReceiverViewController . instance ( content: . messages( messages) )
1315
- navigationController? . pushViewController ( vc, animated: true )
1316
- } else {
1317
- let alert = UIAlertController ( title: nil , message: nil , preferredStyle: . actionSheet)
1318
- alert. addAction ( UIAlertAction ( title: R . string. localizable. chat_forward_one_by_one ( ) , style: . default, handler: { ( _) in
1319
- let vc = MessageReceiverViewController . instance ( content: . messages( messages) )
1320
- self . navigationController? . pushViewController ( vc, animated: true )
1321
- } ) )
1322
- alert. addAction ( UIAlertAction ( title: R . string. localizable. chat_forward_combined ( ) , style: . default, handler: { ( _) in
1323
- let vc = MessageReceiverViewController . instance ( content: . transcript( messages) )
1324
- self . navigationController? . pushViewController ( vc, animated: true )
1325
- } ) )
1326
- alert. addAction ( UIAlertAction ( title: R . string. localizable. dialog_button_cancel ( ) , style: . cancel, handler: nil ) )
1327
- present ( alert, animated: true , completion: nil )
1328
- }
1329
- case . delete:
1330
- let viewModels = dataSource. selectedViewModels. values. map ( { $0 } )
1331
- let controller = UIAlertController ( title: nil , message: nil , preferredStyle: . actionSheet)
1332
- if !viewModels. contains ( where: { $0. message. userId != myUserId || !$0. message. canRecall } ) {
1333
- controller. addAction ( UIAlertAction ( title: Localized . ACTION_DELETE_EVERYONE, style: . destructive, handler: { ( _) in
1334
- if AppGroupUserDefaults . User. hasShownRecallTips {
1335
- self . deleteForEveryone ( viewModels: viewModels)
1336
- } else {
1337
- self . showRecallTips ( viewModels: viewModels)
1338
- }
1339
- } ) )
1340
- }
1341
- controller. addAction ( UIAlertAction ( title: Localized . ACTION_DELETE_ME, style: . destructive, handler: { ( _) in
1342
- self . deleteForMe ( viewModels: self . dataSource. selectedViewModels. values. map ( { $0 } ) )
1343
- } ) )
1344
- controller. addAction ( UIAlertAction ( title: Localized . DIALOG_BUTTON_CANCEL, style: . cancel, handler: nil ) )
1345
- self . present ( controller, animated: true , completion: nil )
1346
- }
1347
- }
1348
-
1349
- }
1350
-
1351
1342
// MARK: - UIGestureRecognizerDelegate
1352
1343
extension ConversationViewController : UIGestureRecognizerDelegate {
1353
1344
@@ -1965,7 +1956,7 @@ extension ConversationViewController {
1965
1956
SendMessageService . shared. sendPinMessages ( items: [ message] , conversationId: conversationId, action: . pin)
1966
1957
case . unpin:
1967
1958
dataSource. postponeMessagePinningUpdate ( with: message. messageId)
1968
- SendMessageService . shared. sendPinMessages ( items: [ message] , conversationId: conversationId, action: . pin )
1959
+ SendMessageService . shared. sendPinMessages ( items: [ message] , conversationId: conversationId, action: . unpin )
1969
1960
}
1970
1961
}
1971
1962
0 commit comments