From 28242de8a6e61a6c1ef094dfb3256073ce9ff01a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E7=BB=A7=E8=B6=85?= <984065974@qq.com> Date: Fri, 21 Feb 2025 10:50:42 +0800 Subject: [PATCH 1/4] Update MessageEntity.swift --- .../Classes/UI/Components/Chat/ViewModel/MessageEntity.swift | 3 --- 1 file changed, 3 deletions(-) diff --git a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/ViewModel/MessageEntity.swift b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/ViewModel/MessageEntity.swift index f71addbd..23aec4b1 100644 --- a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/ViewModel/MessageEntity.swift +++ b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/ViewModel/MessageEntity.swift @@ -846,9 +846,6 @@ extension ChatMessage { chatUser?.nickname = cacheUser?.nickname ?? "" } if chatUser == nil,cacheUser != nil { - if let chatAvatarURL = chatUser?.avatarURL,!chatAvatarURL.isEmpty { - cacheUser?.avatarURL = chatAvatarURL - } return cacheUser } return chatUser From b2c5286448ce91a3ff9109dd74e8e3182b7798d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E7=BB=A7=E8=B6=85?= <984065974@qq.com> Date: Mon, 24 Feb 2025 14:10:40 +0800 Subject: [PATCH 2/4] fix incorrect construct method --- .../Chat/Controllers/ChatHistoryViewController.swift | 2 +- .../Chat/Controllers/ChatThreadCreateController.swift | 2 +- .../Chat/Controllers/MessageReactionsController.swift | 2 +- .../Chat/Controllers/MessageReactionsDetailController.swift | 2 +- .../Components/Chat/Controllers/ReportOptionsController.swift | 2 +- .../Classes/UI/Components/Chat/ViewModel/MessageEntity.swift | 4 ++-- .../Classes/UI/Components/Chat/Views/CommonReactionView.swift | 2 +- .../Components/Conversation/Cells/ConversationListCell.swift | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/ChatHistoryViewController.swift b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/ChatHistoryViewController.swift index d4e4d5ae..43f3e628 100644 --- a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/ChatHistoryViewController.swift +++ b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/ChatHistoryViewController.swift @@ -9,7 +9,7 @@ import UIKit @objcMembers open class ChatHistoryViewController: UIViewController { - public private(set) var message = ChatMessage() + public private(set) var message = ChatMessage(conversationID: "", body: ChatTextMessageBody(text: ""), ext: nil) public private(set) var messages = [MessageEntity]() diff --git a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/ChatThreadCreateController.swift b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/ChatThreadCreateController.swift index f8374ed2..2e2afc2e 100644 --- a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/ChatThreadCreateController.swift +++ b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/ChatThreadCreateController.swift @@ -12,7 +12,7 @@ import AVFoundation @objcMembers open class ChatThreadCreateController: UIViewController { - public private(set) var message = ChatMessage() + public private(set) var message = ChatMessage(conversationID: "", body: ChatTextMessageBody(text: ""), ext: nil) //Thread id empty represents creating a new thread,constructing the first message, and then entering the chat thread send the first message. public private(set) lazy var viewModel: ChatThreadViewModel = { diff --git a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/MessageReactionsController.swift b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/MessageReactionsController.swift index dec91a2e..93f18c12 100644 --- a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/MessageReactionsController.swift +++ b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/MessageReactionsController.swift @@ -14,7 +14,7 @@ import UIKit private var needRefresh: (() -> Void)? - public private(set) var message = ChatMessage() + public private(set) var message = ChatMessage(conversationID: "", body: ChatTextMessageBody(text: ""), ext: nil) public private(set) var reactions = [Reaction]() diff --git a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/MessageReactionsDetailController.swift b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/MessageReactionsDetailController.swift index 1bc6d079..3b62e621 100644 --- a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/MessageReactionsDetailController.swift +++ b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/MessageReactionsDetailController.swift @@ -13,7 +13,7 @@ import UIKit public private(set) var cursor = "" - public private(set) var message = ChatMessage() + public private(set) var message = ChatMessage(conversationID: "", body: ChatTextMessageBody(text: ""), ext: nil) public private(set) var reactions: [MessageReaction] = [] diff --git a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/ReportOptionsController.swift b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/ReportOptionsController.swift index 5940a932..6f52b09a 100644 --- a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/ReportOptionsController.swift +++ b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/ReportOptionsController.swift @@ -11,7 +11,7 @@ import UIKit public private(set) var items: [Bool] = [] - public private(set) var reportMessage: ChatMessage = ChatMessage() + public private(set) var reportMessage: ChatMessage = ChatMessage(conversationID: "", body: ChatTextMessageBody(text: ""), ext: nil) public private(set) var selectIndex = 0 diff --git a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/ViewModel/MessageEntity.swift b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/ViewModel/MessageEntity.swift index 23aec4b1..df1b16a6 100644 --- a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/ViewModel/MessageEntity.swift +++ b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/ViewModel/MessageEntity.swift @@ -46,7 +46,7 @@ public let urlPreviewImageHeight = CGFloat(137) super.init() } - public var message: ChatMessage = ChatMessage() + public var message: ChatMessage = ChatMessage(conversationID: "", body: ChatTextMessageBody(text: ""), ext: nil) public var urlPreview: URLPreviewManager.HTMLContent? @@ -794,7 +794,7 @@ public let urlPreviewImageHeight = CGFloat(137) super.init() } - public var message: ChatMessage = ChatMessage() + public var message: ChatMessage = ChatMessage(conversationID: "", body: ChatTextMessageBody(text: ""), ext: nil) public var showUserName: String { if let remark = self.message.user?.remark,!remark.isEmpty { diff --git a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Views/CommonReactionView.swift b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Views/CommonReactionView.swift index c8842a8b..85c728d0 100644 --- a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Views/CommonReactionView.swift +++ b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Views/CommonReactionView.swift @@ -16,7 +16,7 @@ fileprivate let space = Int((ScreenWidth-10-CGFloat((Appearance.chat.commonReact public private(set) var reactions = [Reaction]() - public private(set) var message = ChatMessage() + public private(set) var message = ChatMessage(conversationID: "", body: ChatTextMessageBody(text: ""), ext: nil) public private(set) lazy var layout: UICollectionViewFlowLayout = { let flow = UICollectionViewFlowLayout() diff --git a/Sources/EaseChatUIKit/Classes/UI/Components/Conversation/Cells/ConversationListCell.swift b/Sources/EaseChatUIKit/Classes/UI/Components/Conversation/Cells/ConversationListCell.swift index e04ffb2f..f2261e2d 100644 --- a/Sources/EaseChatUIKit/Classes/UI/Components/Conversation/Cells/ConversationListCell.swift +++ b/Sources/EaseChatUIKit/Classes/UI/Components/Conversation/Cells/ConversationListCell.swift @@ -172,7 +172,7 @@ extension ConversationListCell: ThemeSwitchProtocol { public var nickname: String = "" - public var lastMessage: ChatMessage? = ChatMessage() + public var lastMessage: ChatMessage? = ChatMessage(conversationID: "", body: ChatTextMessageBody(text: ""), ext: nil) public var unreadCount: UInt = 0 From eefdc64470a95731e81e8a9773552850e9ced8d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E7=BB=A7=E8=B6=85?= <984065974@qq.com> Date: Mon, 24 Feb 2025 14:16:49 +0800 Subject: [PATCH 3/4] Update ConversationServiceImplement.swift --- .../Service/Implement/ConversationServiceImplement.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sources/EaseChatUIKit/Classes/Service/Implement/ConversationServiceImplement.swift b/Sources/EaseChatUIKit/Classes/Service/Implement/ConversationServiceImplement.swift index 15ab51e0..21fafdad 100644 --- a/Sources/EaseChatUIKit/Classes/Service/Implement/ConversationServiceImplement.swift +++ b/Sources/EaseChatUIKit/Classes/Service/Implement/ConversationServiceImplement.swift @@ -117,8 +117,11 @@ extension ConversationServiceImplement: ConversationService { public func fetchSilentMode(conversationIds: [String], completion: @escaping (Dictionary?, ChatError?) -> Void) { - let conversations = conversationIds.map { - ChatClient.shared().chatManager?.getConversationWithConvId($0) ?? ChatConversation() + var conversations = [ChatConversation]() + for id in conversationIds { + if let conversation = ChatClient.shared().chatManager?.getConversationWithConvId(id) { + conversations.append(conversation) + } } ChatClient.shared().pushManager?.getSilentMode(for: conversations,completion: { [weak self] result, error in self?.handleResult(error: error, type: .fetchSilent) From abfcaa3f00c18d4b436dd2e91a155fa0eb9fc603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E7=BB=A7=E8=B6=85?= <984065974@qq.com> Date: Mon, 24 Feb 2025 14:20:02 +0800 Subject: [PATCH 4/4] Update ForwardTargetViewController.swift --- .../ForwardTargetViewController.swift | 55 ++++++++++--------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/ForwardTargetViewController.swift b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/ForwardTargetViewController.swift index 69e2042c..c2de71c0 100644 --- a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/ForwardTargetViewController.swift +++ b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/ForwardTargetViewController.swift @@ -239,35 +239,36 @@ extension ForwardTargetViewController: UITableViewDelegate,UITableViewDataSource } @objc open func forwardMessages(indexPath: IndexPath) { - var body = self.messages.first?.body ?? ChatMessageBody() - if self.combineForward { - body = ChatCombineMessageBody(title: "Chat History".chat.localize, summary: self.forwardSummary(), compatibleText: "[Chat History]", messageIdList: self.messages.filter({ChatClient.shared().chatManager?.getMessageWithMessageId($0.messageId)?.status == .succeed}).map({ $0.messageId })) - } - - var conversationId = "" - if self.searchMode { - conversationId = self.searchResults[indexPath.row].id - } else { - conversationId = self.datas[indexPath.row].id - } - let message = ChatMessage(conversationID: conversationId, body: body, ext: ChatUIKitContext.shared?.currentUser?.toJsonObject()) - message.chatType = self.index == 0 ? .chat:.groupChat - ChatClient.shared().chatManager?.send(message, progress: nil, completion: { [weak self] successMessage, error in - guard let `self` = self else { return } - if error == nil { - self.forwarded = true - if let cell = self.targetsList.cellForRow(at: indexPath) as? ForwardTargetCell { - var profile = ChatUserProfile() - if let user = (self.searchMode ? self.searchResults:self.datas)[safe: indexPath.row] as? ChatUserProfile { - profile = user - } - cell.refresh(info: profile, keyword: self.searchKeyWord, forward: .forwarded) - } + if var body = self.messages.first?.body { + if self.combineForward { + body = ChatCombineMessageBody(title: "Chat History".chat.localize, summary: self.forwardSummary(), compatibleText: "[Chat History]", messageIdList: self.messages.filter({ChatClient.shared().chatManager?.getMessageWithMessageId($0.messageId)?.status == .succeed}).map({ $0.messageId })) + } + + var conversationId = "" + if self.searchMode { + conversationId = self.searchResults[indexPath.row].id } else { - self.showToast(toast: error?.errorDescription ?? "Failed to forward message") - consoleLogInfo("ForwardTargetViewController forwardMessages error:\(error?.errorDescription ?? "")", type: .error) + conversationId = self.datas[indexPath.row].id } - }) + let message = ChatMessage(conversationID: conversationId, body: body, ext: ChatUIKitContext.shared?.currentUser?.toJsonObject()) + message.chatType = self.index == 0 ? .chat:.groupChat + ChatClient.shared().chatManager?.send(message, progress: nil, completion: { [weak self] successMessage, error in + guard let `self` = self else { return } + if error == nil { + self.forwarded = true + if let cell = self.targetsList.cellForRow(at: indexPath) as? ForwardTargetCell { + var profile = ChatUserProfile() + if let user = (self.searchMode ? self.searchResults:self.datas)[safe: indexPath.row] as? ChatUserProfile { + profile = user + } + cell.refresh(info: profile, keyword: self.searchKeyWord, forward: .forwarded) + } + } else { + self.showToast(toast: error?.errorDescription ?? "Failed to forward message") + consoleLogInfo("ForwardTargetViewController forwardMessages error:\(error?.errorDescription ?? "")", type: .error) + } + }) + } } @objc open func forwardSummary() -> String {