Skip to content

Commit 1665b55

Browse files
authored
Merge pull request #43 from zjc19891106/main
fix incorrect construct method
2 parents 3ad4765 + abfcaa3 commit 1665b55

File tree

10 files changed

+42
-41
lines changed

10 files changed

+42
-41
lines changed

Sources/EaseChatUIKit/Classes/Service/Implement/ConversationServiceImplement.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,11 @@ extension ConversationServiceImplement: ConversationService {
117117

118118

119119
public func fetchSilentMode(conversationIds: [String], completion: @escaping (Dictionary<String, SilentModeResult>?, ChatError?) -> Void) {
120-
let conversations = conversationIds.map {
121-
ChatClient.shared().chatManager?.getConversationWithConvId($0) ?? ChatConversation()
120+
var conversations = [ChatConversation]()
121+
for id in conversationIds {
122+
if let conversation = ChatClient.shared().chatManager?.getConversationWithConvId(id) {
123+
conversations.append(conversation)
124+
}
122125
}
123126
ChatClient.shared().pushManager?.getSilentMode(for: conversations,completion: { [weak self] result, error in
124127
self?.handleResult(error: error, type: .fetchSilent)

Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/ChatHistoryViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import UIKit
99

1010
@objcMembers open class ChatHistoryViewController: UIViewController {
1111

12-
public private(set) var message = ChatMessage()
12+
public private(set) var message = ChatMessage(conversationID: "", body: ChatTextMessageBody(text: ""), ext: nil)
1313

1414
public private(set) var messages = [MessageEntity]()
1515

Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/ChatThreadCreateController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import AVFoundation
1212

1313
@objcMembers open class ChatThreadCreateController: UIViewController {
1414

15-
public private(set) var message = ChatMessage()
15+
public private(set) var message = ChatMessage(conversationID: "", body: ChatTextMessageBody(text: ""), ext: nil)
1616

1717
//Thread id empty represents creating a new thread,constructing the first message, and then entering the chat thread send the first message.
1818
public private(set) lazy var viewModel: ChatThreadViewModel = {

Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/ForwardTargetViewController.swift

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -239,35 +239,36 @@ extension ForwardTargetViewController: UITableViewDelegate,UITableViewDataSource
239239
}
240240

241241
@objc open func forwardMessages(indexPath: IndexPath) {
242-
var body = self.messages.first?.body ?? ChatMessageBody()
243-
if self.combineForward {
244-
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 }))
245-
}
246-
247-
var conversationId = ""
248-
if self.searchMode {
249-
conversationId = self.searchResults[indexPath.row].id
250-
} else {
251-
conversationId = self.datas[indexPath.row].id
252-
}
253-
let message = ChatMessage(conversationID: conversationId, body: body, ext: ChatUIKitContext.shared?.currentUser?.toJsonObject())
254-
message.chatType = self.index == 0 ? .chat:.groupChat
255-
ChatClient.shared().chatManager?.send(message, progress: nil, completion: { [weak self] successMessage, error in
256-
guard let `self` = self else { return }
257-
if error == nil {
258-
self.forwarded = true
259-
if let cell = self.targetsList.cellForRow(at: indexPath) as? ForwardTargetCell {
260-
var profile = ChatUserProfile()
261-
if let user = (self.searchMode ? self.searchResults:self.datas)[safe: indexPath.row] as? ChatUserProfile {
262-
profile = user
263-
}
264-
cell.refresh(info: profile, keyword: self.searchKeyWord, forward: .forwarded)
265-
}
242+
if var body = self.messages.first?.body {
243+
if self.combineForward {
244+
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 }))
245+
}
246+
247+
var conversationId = ""
248+
if self.searchMode {
249+
conversationId = self.searchResults[indexPath.row].id
266250
} else {
267-
self.showToast(toast: error?.errorDescription ?? "Failed to forward message")
268-
consoleLogInfo("ForwardTargetViewController forwardMessages error:\(error?.errorDescription ?? "")", type: .error)
251+
conversationId = self.datas[indexPath.row].id
269252
}
270-
})
253+
let message = ChatMessage(conversationID: conversationId, body: body, ext: ChatUIKitContext.shared?.currentUser?.toJsonObject())
254+
message.chatType = self.index == 0 ? .chat:.groupChat
255+
ChatClient.shared().chatManager?.send(message, progress: nil, completion: { [weak self] successMessage, error in
256+
guard let `self` = self else { return }
257+
if error == nil {
258+
self.forwarded = true
259+
if let cell = self.targetsList.cellForRow(at: indexPath) as? ForwardTargetCell {
260+
var profile = ChatUserProfile()
261+
if let user = (self.searchMode ? self.searchResults:self.datas)[safe: indexPath.row] as? ChatUserProfile {
262+
profile = user
263+
}
264+
cell.refresh(info: profile, keyword: self.searchKeyWord, forward: .forwarded)
265+
}
266+
} else {
267+
self.showToast(toast: error?.errorDescription ?? "Failed to forward message")
268+
consoleLogInfo("ForwardTargetViewController forwardMessages error:\(error?.errorDescription ?? "")", type: .error)
269+
}
270+
})
271+
}
271272
}
272273

273274
@objc open func forwardSummary() -> String {

Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/MessageReactionsController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import UIKit
1414

1515
private var needRefresh: (() -> Void)?
1616

17-
public private(set) var message = ChatMessage()
17+
public private(set) var message = ChatMessage(conversationID: "", body: ChatTextMessageBody(text: ""), ext: nil)
1818

1919
public private(set) var reactions = [Reaction]()
2020

Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/MessageReactionsDetailController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import UIKit
1313

1414
public private(set) var cursor = ""
1515

16-
public private(set) var message = ChatMessage()
16+
public private(set) var message = ChatMessage(conversationID: "", body: ChatTextMessageBody(text: ""), ext: nil)
1717

1818
public private(set) var reactions: [MessageReaction] = []
1919

Sources/EaseChatUIKit/Classes/UI/Components/Chat/Controllers/ReportOptionsController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import UIKit
1111

1212
public private(set) var items: [Bool] = []
1313

14-
public private(set) var reportMessage: ChatMessage = ChatMessage()
14+
public private(set) var reportMessage: ChatMessage = ChatMessage(conversationID: "", body: ChatTextMessageBody(text: ""), ext: nil)
1515

1616
public private(set) var selectIndex = 0
1717

Sources/EaseChatUIKit/Classes/UI/Components/Chat/ViewModel/MessageEntity.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public let urlPreviewImageHeight = CGFloat(137)
4646
super.init()
4747
}
4848

49-
public var message: ChatMessage = ChatMessage()
49+
public var message: ChatMessage = ChatMessage(conversationID: "", body: ChatTextMessageBody(text: ""), ext: nil)
5050

5151
public var urlPreview: URLPreviewManager.HTMLContent?
5252

@@ -794,7 +794,7 @@ public let urlPreviewImageHeight = CGFloat(137)
794794
super.init()
795795
}
796796

797-
public var message: ChatMessage = ChatMessage()
797+
public var message: ChatMessage = ChatMessage(conversationID: "", body: ChatTextMessageBody(text: ""), ext: nil)
798798

799799
public var showUserName: String {
800800
if let remark = self.message.user?.remark,!remark.isEmpty {
@@ -846,9 +846,6 @@ extension ChatMessage {
846846
chatUser?.nickname = cacheUser?.nickname ?? ""
847847
}
848848
if chatUser == nil,cacheUser != nil {
849-
if let chatAvatarURL = chatUser?.avatarURL,!chatAvatarURL.isEmpty {
850-
cacheUser?.avatarURL = chatAvatarURL
851-
}
852849
return cacheUser
853850
}
854851
return chatUser

Sources/EaseChatUIKit/Classes/UI/Components/Chat/Views/CommonReactionView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fileprivate let space = Int((ScreenWidth-10-CGFloat((Appearance.chat.commonReact
1616

1717
public private(set) var reactions = [Reaction]()
1818

19-
public private(set) var message = ChatMessage()
19+
public private(set) var message = ChatMessage(conversationID: "", body: ChatTextMessageBody(text: ""), ext: nil)
2020

2121
public private(set) lazy var layout: UICollectionViewFlowLayout = {
2222
let flow = UICollectionViewFlowLayout()

Sources/EaseChatUIKit/Classes/UI/Components/Conversation/Cells/ConversationListCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ extension ConversationListCell: ThemeSwitchProtocol {
172172

173173
public var nickname: String = ""
174174

175-
public var lastMessage: ChatMessage? = ChatMessage()
175+
public var lastMessage: ChatMessage? = ChatMessage(conversationID: "", body: ChatTextMessageBody(text: ""), ext: nil)
176176

177177
public var unreadCount: UInt = 0
178178

0 commit comments

Comments
 (0)