mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-13 14:56:03 +10:00
Merge branch 'feature/better_send_feel' into develop
This commit is contained in:
@@ -102,6 +102,12 @@ enum MessageMediaType: Int {
|
||||
case Audio = 3
|
||||
}
|
||||
|
||||
enum MessageSendState: Int {
|
||||
case NotSend = 0
|
||||
case Failed = 1
|
||||
case Successed = 2
|
||||
}
|
||||
|
||||
class Message: RLMObject {
|
||||
dynamic var messageID: String = ""
|
||||
|
||||
@@ -117,6 +123,7 @@ class Message: RLMObject {
|
||||
dynamic var thumbnailURLString: String = ""
|
||||
dynamic var localThumbnailName: String = ""
|
||||
|
||||
dynamic var sendState: Int = MessageSendState.NotSend.rawValue
|
||||
dynamic var readed: Bool = false
|
||||
|
||||
dynamic var fromFriend: User?
|
||||
|
||||
@@ -601,6 +601,11 @@ func sendText(text: String, toRecipient recipientID: String, #recipientType: Str
|
||||
|
||||
realm.commitWriteTransaction()
|
||||
|
||||
|
||||
// 发出之前就显示 Message
|
||||
afterCreatedMessage(message)
|
||||
|
||||
|
||||
let messageInfo: JSONDictionary = [
|
||||
"recipient_id": recipientID,
|
||||
"recipient_type": recipientType,
|
||||
@@ -613,13 +618,18 @@ func sendText(text: String, toRecipient recipientID: String, #recipientType: Str
|
||||
failureHandler(reason, errorMessage)
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue()) {
|
||||
realm.beginWriteTransaction()
|
||||
message.sendState = MessageSendState.Failed.rawValue
|
||||
realm.commitWriteTransaction()
|
||||
}
|
||||
|
||||
}, completion: { messageID in
|
||||
dispatch_async(dispatch_get_main_queue()) {
|
||||
realm.beginWriteTransaction()
|
||||
message.messageID = messageID
|
||||
message.sendState = MessageSendState.Successed.rawValue
|
||||
realm.commitWriteTransaction()
|
||||
|
||||
afterCreatedMessage(message)
|
||||
}
|
||||
|
||||
completion(success: true)
|
||||
|
||||
Reference in New Issue
Block a user