Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
Improvement
Browse files Browse the repository at this point in the history
open chat from call even room not exist in room list
  • Loading branch information
saeedmozaffariGithub committed Mar 14, 2018
1 parent 3a002b9 commit adea265
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion iGap/Controller/View Controllers/Call/IGCall.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,32 @@ class IGCall: UIViewController, CallStateObserver, ReturnToCallObserver {

let realm = try! Realm()
let predicate = NSPredicate(format: "chatRoom.peer.id = %lld", userId)
if let roomInfo = try realm.objects(IGRoom.self).filter(predicate).first {
if let roomInfo = try! realm.objects(IGRoom.self).filter(predicate).first {
room = roomInfo
performSegue(withIdentifier: "showRoomMessages", sender: self)
} else {
IGChatGetRoomRequest.Generator.generate(peerId: userId).success({ (protoResponse) in
DispatchQueue.main.async {
if let chatGetRoomResponse = protoResponse as? IGPChatGetRoomResponse {
IGChatGetRoomRequest.Handler.interpret(response: chatGetRoomResponse)
self.room = IGRoom(igpRoom: chatGetRoomResponse.igpRoom)
self.performSegue(withIdentifier: "showRoomMessages", sender: self)
}
}
}).error({ (errorCode, waitTime) in
switch errorCode {
case .timeout:
DispatchQueue.main.async {
let alert = UIAlertController(title: "Timeout", message: "Please try again later", preferredStyle: .alert)
let okAction = UIAlertAction(title: "OK", style: .default, handler: nil)
alert.addAction(okAction)
self.present(alert, animated: true, completion: nil)
}
default:
break
}

}).send()
}
}

Expand Down

0 comments on commit adea265

Please sign in to comment.