Skip to content

Commit

Permalink
Merge pull request #339 from Dongshanxu/master
Browse files Browse the repository at this point in the history
9.2.0 bugfix
  • Loading branch information
shine2008 authored Jun 30, 2022
2 parents 289250a + 2e7ed10 commit 2655144
Show file tree
Hide file tree
Showing 31 changed files with 149 additions and 209 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ extension ChatViewController: ChatBaseCellDelegate {

func didTapAvatarView(_ cell: UITableViewCell, _ model: MessageContentModel?) {
if let isOut = model?.message?.isOutgoingMsg, isOut {
Router.shared.use(MeSetting, parameters: ["nav": navigationController as Any], closure: nil)
Router.shared.use(MeSettingRouter, parameters: ["nav": navigationController as Any], closure: nil)
return
}
if let uid = model?.message?.from {
Expand Down Expand Up @@ -638,7 +638,7 @@ extension ChatViewController {
// MARK:ChatInputViewDelegate
public func sendText(text: String?) {
guard let content = text, content.count > 0 else {
self.view.makeToast(localizable("text_is_nil"))
self.showToast(localizable("text_is_nil"))
return
}
if viewmodel.isReplying, let msg = self.viewmodel.operationModel?.message {
Expand Down Expand Up @@ -726,7 +726,7 @@ extension ChatViewController {
}else if index == 3 {
showBottomVideoAction(self, false)
}else {
self.view.makeToast(localizable("open_soon"))
self.showToast(localizable("open_soon"))
}
}

Expand Down Expand Up @@ -796,7 +796,7 @@ extension ChatViewController {
}

guard let image = info[.originalImage] as? UIImage else {
self.view.makeToast(localizable("image_is_nil"))
self.showToast(localizable("image_is_nil"))
return
}
viewmodel.sendImageMessage(image: image, {[weak self] error in
Expand Down Expand Up @@ -908,7 +908,9 @@ extension ChatViewController {
NEAuthManager.requestAudioAuthorization { granted in
if granted {
}else {
self.showToast(localizable("没有麦克风权限"))
DispatchQueue.main.async {
self.showToast(localizable("没有麦克风权限"))
}
}
}
}
Expand Down Expand Up @@ -975,7 +977,7 @@ extension ChatViewController {
public func playAudio(_ filePath: String, didBeganWithError error: Error?) {
print(#function + "\(error)")
if let e = error {
self.view.makeToast(e.localizedDescription)
self.showToast(e.localizedDescription)
// stop
self.playingCell?.stopAnimation()
}
Expand All @@ -984,7 +986,7 @@ extension ChatViewController {
public func playAudio(_ filePath: String, didCompletedWithError error: Error?) {
print(#function + "\(error)")
if let e = error {
self.view.makeToast(e.localizedDescription)
self.showToast(e.localizedDescription)
}
// stop
self.playingCell?.stopAnimation()
Expand All @@ -993,7 +995,7 @@ extension ChatViewController {
public func stopPlayAudio(_ filePath: String, didCompletedWithError error: Error?) {
print(#function + "\(error)")
if let e = error {
self.view.makeToast(e.localizedDescription)
self.showToast(e.localizedDescription)
}
self.playingCell?.stopAnimation()
}
Expand Down Expand Up @@ -1021,7 +1023,7 @@ extension ChatViewController {
print("[record] sdk Completed error:\(error)")
self.menuView.stopRecordAnimation()
guard let fp = filePath else {
self.view.makeToast(error?.localizedDescription)
self.showToast(error?.localizedDescription ?? "")
return
}
let dur = recordDuration(filePath: fp)
Expand All @@ -1030,13 +1032,13 @@ extension ChatViewController {
if dur > 1 {
self.viewmodel.sendAudioMessage(filePath: fp, { error in
if let e = error {
self.view.makeToast(e.localizedDescription)
self.showToast(e.localizedDescription)
}else {

}
})
}else {
self.view.makeToast(localizable("录音时间太短"))
self.showToast(localizable("录音时间太短"))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public class ReadViewController: NEBaseViewController, UIScrollViewDelegate, UIT
NIMSDK.shared().chatManager.queryMessageReceiptDetail(message) { anError, receiptInfo in
print("anError:\(anError) receiptInfo:\(receiptInfo)")
if let error = anError {
self.view.makeToast(error.localizedDescription)
self.showToast(error.localizedDescription)
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public class UserSettingViewController: NEBaseViewController, UserSettingViewMod
return true
}){
weakSelf?.navigationController?.viewControllers = allControllers
Router.shared.use(ChatPushGroupVC, parameters: ["nav": weakSelf?.navigationController as Any, "session" : session as Any], closure: nil)
Router.shared.use(PushTeamChatVCRouter, parameters: ["nav": weakSelf?.navigationController as Any, "session" : session as Any], closure: nil)
}
}
}else if let error = param["msg"] as? String {
Expand Down

This file was deleted.

58 changes: 34 additions & 24 deletions NEKitChatUI/NEKitChatUI/Classes/Chat/ViewModel/ChatViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -496,21 +496,26 @@ public class ChatViewModel: NSObject, ChatRepoMessageDelegate, NIMChatManagerDel
}

// MARK: NIMChatManagerDelegate
//收到消息
public func onRecvMessages(_ messages: [NIMMessage]) {
print("\(#function) 1messages:\(messages.count)")

for msg in messages {
if msg.session?.sessionId == self.session.sessionId {
self.newMsg = msg
self.addTimeMessage(msg)
self.messages.append(self.modelFromMessage(message: msg))

//自定义消息处理
if msg.messageType == .custom {

}else {
self.newMsg = msg
self.addTimeMessage(msg)
self.messages.append(self.modelFromMessage(message: msg))
}

}
}
self.delegate?.onRecvMessages(messages)

// self.markRead(messages: messages, { error in
// print("mark read \(error?.localizedDescription)")
// })

}


Expand All @@ -520,25 +525,30 @@ public class ChatViewModel: NSObject, ChatRepoMessageDelegate, NIMChatManagerDel
if message.session?.sessionId != self.session.sessionId {
return
}
if self.newMsg == nil {
self.newMsg = message
}

var isResend = false
for (i, msg) in self.messages.enumerated() {
if message.messageId == msg.message?.messageId {
self.messages[i].message = message
isResend = true
break
//自定义消息发送之前的处理
if message.messageType == .custom {

}else {
if self.newMsg == nil {
self.newMsg = message
}

var isResend = false
for (i, msg) in self.messages.enumerated() {
if message.messageId == msg.message?.messageId {
self.messages[i].message = message
isResend = true
break
}
}

if !isResend {
self.addTimeMessage(message)
self.messages.append(self.modelFromMessage(message: message))
}

self.delegate?.willSend(message)
}

if !isResend {
self.addTimeMessage(message)
self.messages.append(self.modelFromMessage(message: message))
}

self.delegate?.willSend(message)
}

public func send(_ message: NIMMessage, progress: Float) {
Expand Down
4 changes: 2 additions & 2 deletions NEKitChatUI/NEKitChatUI/Classes/ChatRouter/ChatRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public struct ChatRouter {


// p2p
Router.shared.register("pushChatVC") { param in
Router.shared.register(PushP2pChatVCRouter) { param in
print("param:\(param)")
let nav = param["nav"] as? UINavigationController
guard let session = param["session"] as? NIMSession else {
Expand All @@ -22,7 +22,7 @@ public struct ChatRouter {
}

// group
Router.shared.register(ChatPushGroupVC) { param in
Router.shared.register(PushTeamChatVCRouter) { param in
print("param:\(param)")
let nav = param["nav"] as? UINavigationController
guard let session = param["session"] as? NIMSession else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ extension UIViewController: UIImagePickerControllerDelegate {
//在需要的地方present出来
self.present(photoPicker, animated: true, completion: nil)
}else {
self.view.makeToast("未打开相册权限")
self.showToast("未打开相册权限")
}
}
}
Expand All @@ -259,7 +259,9 @@ extension UIViewController: UIImagePickerControllerDelegate {
//在需要的地方present出来
self.present(photoPicker, animated: true, completion: nil)
}else {
self.view.makeToast("未打开相册权限")
// self.view.makeToast("未打开相册权限")
self.showToast("未打开相册权限")

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import Foundation
import UIKit

public protocol ContactCellDataProtrol {
func setModel(_ model: ContactInfo, _ config: ContactsConfig)
func setModel(_ model: ContactInfo)
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public struct ContactRouter {
nav?.pushViewController(contactSelectVC, animated: true)
}

Router.shared.register(ContactSearchUserRouter) { param in
Router.shared.register(ContactAddFriendRouter) { param in
let nav = param["nav"] as? UINavigationController
let findFrined = FindFriendViewController()
nav?.pushViewController(findFrined, animated: true)
Expand Down
26 changes: 0 additions & 26 deletions NEKitContactUI/NEKitContactUI/Classes/Common/ContactsConfig.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class TeamListViewController: UIViewController, UITableViewDelegate, UITa
}
if let teamid = model.teamId {
let session = NIMSession(teamid, type: .team)
Router.shared.use(ChatPushGroupVC, parameters: ["nav": navigationController as Any, "session" : session as Any], closure: nil)
Router.shared.use(PushTeamChatVCRouter, parameters: ["nav": navigationController as Any, "session" : session as Any], closure: nil)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public class ContactUserViewController: ContactBaseViewController, UITableViewDe
return
}
let session = NIMSession(accid, type: .P2P)
Router.shared.use("pushChatVC", parameters: ["nav": self.navigationController,"session": session]) { obj, routerState, str in
Router.shared.use(PushP2pChatVCRouter, parameters: ["nav": self.navigationController,"session": session]) { obj, routerState, str in
print("obj:\(obj) routerState:\(routerState) str:\(str)")
}
}
Expand All @@ -238,7 +238,7 @@ public class ContactUserViewController: ContactBaseViewController, UITableViewDe
if let userId = user?.userId {
viewModel.deleteFriend(account: userId) { error in
if error != nil {
self.view.makeToast(error?.localizedDescription)
self.showToast(error?.localizedDescription ?? "")
}else {
self.navigationController?.popViewController(animated: true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class ContactSelectedCell: ContactTableViewCell {
])
}

override func setModel(_ model: ContactInfo, _ config: ContactsConfig) {
super.setModel(model, config)
override func setModel(_ model: ContactInfo) {
super.setModel(model)
if model.isSelected == false {
sImage.isHighlighted = false
}else {
Expand Down
Loading

0 comments on commit 2655144

Please sign in to comment.