Skip to content

Commit 85f530d

Browse files
authored
Merge pull request #31 from lixm1988/main
适配sdk 4.13.0,禁用ChatMessage 默认构造函数
2 parents fb124f8 + a65df20 commit 85f530d

File tree

8 files changed

+10
-16
lines changed

8 files changed

+10
-16
lines changed

ChatroomUIKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
Pod::Spec.new do |s|
99
s.name = 'ChatroomUIKit'
10-
s.version = '1.1.2'
10+
s.version = '1.1.3'
1111
s.summary = 'ChatroomUIKit.'
1212

1313

Example/ChatroomUIKit/UIComponentsExampleViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class UIComponentsExampleViewController: UIViewController {
2222
}()
2323
//聊天区域
2424
lazy var barrageList: MessageList = {
25-
MessageList(frame: CGRect(x: 0, y: ScreenHeight-BottomBarHeight-54-5, width: self.view.frame.width-50, height: 200))
25+
MessageList(frame: CGRect(x: 0, y: ScreenHeight-BottomBarHeight-54-5-200, width: self.view.frame.width-50, height: 200))
2626
}()
2727
//底部工具栏
2828
lazy var bottomBar: BottomAreaToolBar = {

Sources/ChatroomUIKit/Classes/Service/Implement/ChatroomServiceImplement.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,13 @@ extension ChatroomServiceImplement: ChatroomService {
132132
}
133133
}
134134

135-
public func sendMessage(text: String, roomId: String, completion: @escaping (ChatMessage, ChatError?) -> Void) {
135+
public func sendMessage(text: String, roomId: String, completion: @escaping (ChatMessage?, ChatError?) -> Void) {
136136
let user = ChatroomContext.shared?.currentUser
137137
if let user_json = user?.toJsonObject() {
138138
let message = ChatMessage(conversationID: roomId, body: ChatTextMessageBody(text: text), ext: ["chatroom_uikit_userInfo":user_json])
139139
message.chatType = .chatRoom
140140
ChatClient.shared().chatManager?.send(message, progress: nil,completion: { chatMessage, error in
141-
completion(chatMessage ?? ChatMessage(),error)
141+
completion(chatMessage,error)
142142
})
143143
}
144144
}

Sources/ChatroomUIKit/Classes/Service/Implement/UserServiceImplement.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,8 @@ extension UserServiceImplement:UserServiceProtocol {
9393
if ChatClient.shared().isLoggedIn {
9494
self.logout { _, _ in }
9595
}
96-
if token.hasPrefix("00") {
97-
ChatClient.shared().login(withUsername: userId.lowercased(), agoraToken: token) { user_id, error in
98-
completion(error == nil,error)
99-
}
100-
} else {
101-
ChatClient.shared().login(withUsername: userId, token: token) { user_id, error in
102-
completion(error == nil,error)
103-
}
96+
ChatClient.shared().login(withUsername: userId, token: token) { user_id, error in
97+
completion(error == nil,error)
10498
}
10599
}
106100

Sources/ChatroomUIKit/Classes/Service/Protocol/ChatroomService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ import Foundation
8484
/// - text: You'll send text.
8585
/// - roomId: chatroom id
8686
/// - completion: Send callback,what if success or error.
87-
func sendMessage(text: String, roomId: String, completion: @escaping (ChatMessage,ChatError?) -> Void)
87+
func sendMessage(text: String, roomId: String, completion: @escaping (ChatMessage?,ChatError?) -> Void)
8888

8989
/// Send targeted text messages to some participants of the chat room
9090
/// - Parameters:

Sources/ChatroomUIKit/Classes/UI/Components/Chat/Cells/ChatMessageCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ fileprivate let gift_tail_indent: CGFloat = 26
160160
@objc open class ChatEntity: NSObject {
161161

162162
/// The message associated with the chat entity.
163-
lazy public var message: ChatMessage = ChatMessage()
163+
public var message: ChatMessage!
164164

165165
/// The time at which the message was sent, formatted as "HH:mm".
166166
lazy open var showTime: String = {

Sources/ChatroomUIKit/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!
1515

1616
public private(set) var selectIndex = 0
1717

Sources/ChatroomUIKit/Classes/UI/Components/Room/Views/ChatroomView.swift

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

142142
@objc open func sendTextMessage(text: String) {
143143
self.service?.roomService?.sendMessage(text: text, roomId: ChatroomContext.shared?.roomId ?? "", completion: { [weak self] message, error in
144-
if error == nil {
144+
if error == nil,let message = message {
145145
self?.chatList.showNewMessage(message: message, gift: nil)
146146
} else {
147147
let errorInfo = "Send message failure!\n\(error?.errorDescription ?? "")"

0 commit comments

Comments
 (0)