@@ -304,7 +304,7 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
304304 isCurrentPage = true
305305 markNeedReadMsg ( )
306306
307- if NEKitChatConfig . shared. ui . messageProperties. showTitleBar {
307+ if ChatUIConfig . shared. messageProperties. showTitleBar {
308308 bodyTopViewTopConstant = topConstant
309309 }
310310
@@ -366,13 +366,14 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
366366 let param = [ " sessionId " : viewModel. conversationId]
367367 Router . shared. use ( " ClearAtMessageRemind " , parameters: param, closure: nil )
368368
369+ NotificationCenter . default. removeObserver ( self )
369370 NETeamUserManager . shared. removeAllTeamInfo ( )
370371 }
371372 }
372373
373374 open func setMoreButton( ) {
374- if NEKitChatConfig . shared. ui . messageProperties. showTitleBarRightIcon {
375- let image = NEKitChatConfig . shared. ui . messageProperties. titleBarRightRes ?? UIImage . ne_imageNamed ( name: " three_point " )
375+ if ChatUIConfig . shared. messageProperties. showTitleBarRightIcon {
376+ let image = ChatUIConfig . shared. messageProperties. titleBarRightRes ?? UIImage . ne_imageNamed ( name: " three_point " )
376377 addRightAction ( image, #selector( toSetting) , self )
377378 navigationView. setMoreButtonImage ( image)
378379 } else {
@@ -460,7 +461,7 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
460461
461462 expandMoreAction ( )
462463
463- if let customController = NEKitChatConfig . shared. ui . customController {
464+ if let customController = ChatUIConfig . shared. customController {
464465 customController ( self )
465466 }
466467 }
@@ -609,8 +610,8 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
609610 }
610611
611612 // 配置项自定义 items
612- if let chatPopMenu = NEKitChatConfig . shared. ui . chatPopMenu {
613- chatPopMenu ( & items, model)
613+ if let chatPopMenu = ChatUIConfig . shared. chatPopMenu {
614+ chatPopMenu ( self , & items, model)
614615 }
615616
616617 // 供用户自定义 items
@@ -731,8 +732,8 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
731732 /// 设置按钮点击事件
732733 override open func toSetting( ) {
733734 // 自定义设置按钮点击事件
734- if let block = NEKitChatConfig . shared. ui . messageProperties. titleBarRightClick {
735- block ( )
735+ if let block = ChatUIConfig . shared. messageProperties. titleBarRightClick {
736+ block ( self )
736737 return
737738 }
738739
@@ -1137,9 +1138,9 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
11371138 }
11381139
11391140 open func didSelectMoreCell( cell: NEInputMoreCell ) {
1140- if let delegate = cell . cellData ? . customDelegate as? AnyObject , let action = cell. cellData? . action {
1141+ if let action = cell. cellData? . action {
11411142 // 用户自定义更多面板按钮
1142- _ = delegate . perform ( action )
1143+ action ( self , cell . cellData )
11431144 return
11441145 }
11451146
@@ -1534,8 +1535,8 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
15341535 if isFile == true {
15351536 let imgSize_MB = Double ( pngImage? . count ?? 0 ) / 1e6
15361537 NEALog . infoLog ( ModuleName + " " + ChatViewController. className ( ) , desc: #function + " imgSize_MB: \( imgSize_MB) MB " )
1537- if imgSize_MB > NEKitChatConfig . shared. ui . fileSizeLimit {
1538- showToast ( String ( format: chatLocalizable ( " fileSize_over_limit " ) , " \( NEKitChatConfig . shared. ui . fileSizeLimit) " ) )
1538+ if imgSize_MB > ChatUIConfig . shared. fileSizeLimit {
1539+ showToast ( String ( format: chatLocalizable ( " fileSize_over_limit " ) , " \( ChatUIConfig . shared. fileSizeLimit) " ) )
15391540 } else {
15401541 viewModel. sendFileMessage ( filePath: imageUrl. relativePath,
15411542 displayName: imageName) { [ weak self] message, error, progress in
@@ -1640,8 +1641,8 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
16401641 let fileAttributes = try FileManager . default. attributesOfItem ( atPath: desPath)
16411642 if let size_B = fileAttributes [ FileAttributeKey . size] as? Double {
16421643 let size_MB = size_B / 1e6
1643- if size_MB > NEKitChatConfig . shared. ui . fileSizeLimit {
1644- showToast ( String ( format: chatLocalizable ( " fileSize_over_limit " ) , " \( NEKitChatConfig . shared. ui . fileSizeLimit) " ) )
1644+ if size_MB > ChatUIConfig . shared. fileSizeLimit {
1645+ showToast ( String ( format: chatLocalizable ( " fileSize_over_limit " ) , " \( ChatUIConfig . shared. fileSizeLimit) " ) )
16451646 try ? FileManager . default. removeItem ( atPath: desPath)
16461647 } else {
16471648 viewModel. sendFileMessage ( filePath: desPath,
@@ -1692,17 +1693,30 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
16921693 controller. dismiss ( animated: true )
16931694 }
16941695
1695- // MARK: - ChatviewModelDelegate
1696+ // MARK: - ChatViewModelDelegate
16961697
16971698 /// 本端即将发送消息状态回调,此时消息还未发送,可对消息进行修改或者拦截发送
16981699 /// 来源: 发送消息, 插入消息
1699- /// - Parameter message: 消息
1700- /// - Parameter completion: 是否继续发送消息
1701- public func readySendMessage( _ message: V2NIMMessage , _ completion: @escaping ( Bool ) -> Void ) {
1702- if let block = NEKitChatConfig . shared. ui. onSendMessage {
1703- completion ( block ( message, self ) )
1700+ /// - Parameter param: 消息参数,包含消息和发送参数
1701+ /// - Returns: (修改后的)消息参数,若消息参数为 nil,则表示拦截该消息不发送
1702+ public func beforeSend( _ param: MessageSendParams ) -> MessageSendParams ? {
1703+ if let block = ChatKitClient . shared. beforeSend {
1704+ let p = block ( self , param)
1705+ return p
1706+ } else {
1707+ return param
1708+ }
1709+ }
1710+
1711+ /// 本端即将发送消息状态回调,此时消息还未发送,可对消息进行修改或者拦截发送
1712+ /// 来源: 发送消息, 插入消息
1713+ /// - Parameter param: 消息参数,包含消息和发送参数
1714+ /// - Parameter completion: (修改后的)消息参数,若消息参数为 nil,则表示拦截该消息不发送
1715+ public func beforeSend( _ param: MessageSendParams , _ completion: @escaping ( MessageSendParams ? ) -> Void ) {
1716+ if let block = ChatKitClient . shared. beforeSendCompletion {
1717+ block ( self , param, completion)
17041718 } else {
1705- completion ( true )
1719+ completion ( param )
17061720 }
17071721 }
17081722
@@ -2152,8 +2166,8 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
21522166 removeOperationView ( )
21532167
21542168 // 配置项拦截
2155- if let popMenuClick = NEKitChatConfig . shared. ui . popMenuClick {
2156- popMenuClick ( item)
2169+ if let popMenuClick = ChatUIConfig . shared. popMenuClick {
2170+ popMenuClick ( self , item)
21572171 return
21582172 }
21592173
@@ -2299,6 +2313,15 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
22992313 }
23002314
23012315 if let message = weakSelf? . viewModel. operationModel? . message {
2316+ // 校验消息可撤回时间
2317+ let date = Date ( )
2318+ let currentTime = date. timeIntervalSince1970
2319+ let reTime = ChatUIConfig . shared. getReeditTimeGap ( )
2320+ if Int ( currentTime - message. createTime) >= reTime * 60 {
2321+ weakSelf? . showToast ( chatLocalizable ( " ravokable_time_expired " ) )
2322+ return
2323+ }
2324+
23022325 if weakSelf? . viewModel. operationModel? . type == . text {
23032326 weakSelf? . viewModel. operationModel? . isReedit = true
23042327 }
@@ -2816,7 +2839,7 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
28162839 /// 输入框【更多】按钮点击事件,子类重写
28172840 @discardableResult
28182841 open func expandMoreAction( ) -> [ NEMoreItemModel ] {
2819- var items = NEChatUIKitClient . instance. getMoreActionData ( sessionType: V2NIMConversationIdUtil . conversationType ( viewModel. conversationId) )
2842+ var items = NEChatUIKitClient . instance. getMoreActionData ( sessionType: V2NIMConversationIdUtil . conversationType ( viewModel. conversationId) , self )
28202843 if NEChatKitClient . instance. delegate == nil {
28212844 items = items. filter { item in
28222845 if item. type == . location {
@@ -3498,8 +3521,8 @@ extension ChatViewController: ChatBaseCellDelegate {
34983521 }
34993522
35003523 open func didTapMessageView( _ cell: UITableViewCell , _ model: MessageContentModel ? , _ replyModel: MessageModel ? ) {
3501- if let tapClick = NEKitChatConfig . shared. ui . messageItemClick {
3502- tapClick ( cell, model)
3524+ if let tapClick = ChatUIConfig . shared. messageItemClick {
3525+ tapClick ( self , cell, model)
35033526 return
35043527 }
35053528
0 commit comments