Skip to content

Commit 58e883e

Browse files
authored
Merge pull request #412 from zapcannon87/master
fix: omit peer id
2 parents 42b6301 + 40dcaa7 commit 58e883e

File tree

2 files changed

+38
-32
lines changed

2 files changed

+38
-32
lines changed

LeanCloudTests/IMMessageTestCase.swift

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -531,28 +531,28 @@ class IMMessageTestCase: RTMBaseTestCase {
531531
XCTAssertTrue(result.isSuccess)
532532
XCTAssertNil(result.error)
533533
exp.fulfill()
534-
})
535-
}
536-
try? client3.conversationQuery.getConversation(by: ID) { result in
537-
XCTAssertTrue(result.isSuccess)
538-
XCTAssertNil(result.error)
539-
chatRoom3 = result.value as? IMChatRoom
540-
exp.fulfill()
541-
try? chatRoom3?.join(completion: { (result) in
542-
XCTAssertTrue(result.isSuccess)
543-
XCTAssertNil(result.error)
544-
exp.fulfill()
545-
})
546-
}
547-
try? client4.conversationQuery.getConversation(by: ID) { result in
548-
XCTAssertTrue(result.isSuccess)
549-
XCTAssertNil(result.error)
550-
chatRoom4 = result.value as? IMChatRoom
551-
exp.fulfill()
552-
try? chatRoom4?.join(completion: { (result) in
553-
XCTAssertTrue(result.isSuccess)
554-
XCTAssertNil(result.error)
555-
exp.fulfill()
534+
try? client3.conversationQuery.getConversation(by: ID) { result in
535+
XCTAssertTrue(result.isSuccess)
536+
XCTAssertNil(result.error)
537+
chatRoom3 = result.value as? IMChatRoom
538+
exp.fulfill()
539+
try? chatRoom3?.join(completion: { (result) in
540+
XCTAssertTrue(result.isSuccess)
541+
XCTAssertNil(result.error)
542+
exp.fulfill()
543+
try? client4.conversationQuery.getConversation(by: ID) { result in
544+
XCTAssertTrue(result.isSuccess)
545+
XCTAssertNil(result.error)
546+
chatRoom4 = result.value as? IMChatRoom
547+
exp.fulfill()
548+
try? chatRoom4?.join(completion: { (result) in
549+
XCTAssertTrue(result.isSuccess)
550+
XCTAssertNil(result.error)
551+
exp.fulfill()
552+
})
553+
}
554+
})
555+
}
556556
})
557557
}
558558
}
@@ -1505,6 +1505,7 @@ extension IMMessageTestCase {
15051505
}
15061506

15071507
func newOpenedClient(
1508+
application: LCApplication = .default,
15081509
clientID: String? = nil,
15091510
clientIDSuffix: String? = nil,
15101511
options: IMClient.Options = [.receiveUnreadMessageCountAfterSessionDidOpen]) -> IMClient?
@@ -1513,17 +1514,20 @@ extension IMMessageTestCase {
15131514
if let suffix = clientIDSuffix {
15141515
ID += "-\(suffix)"
15151516
}
1516-
var client: IMClient? = try? IMClient(ID: ID, options:options)
1517-
let exp = expectation(description: "open")
1518-
client?.open { (result) in
1519-
XCTAssertTrue(result.isSuccess)
1520-
XCTAssertNil(result.error)
1521-
if result.isFailure {
1522-
client = nil
1517+
var client: IMClient? = try? IMClient(
1518+
application: application,
1519+
ID: ID,
1520+
options: options)
1521+
expecting { (exp) in
1522+
client?.open { (result) in
1523+
XCTAssertTrue(result.isSuccess)
1524+
XCTAssertNil(result.error)
1525+
if result.isFailure {
1526+
client = nil
1527+
}
1528+
exp.fulfill()
15231529
}
1524-
exp.fulfill()
15251530
}
1526-
wait(for: [exp], timeout: timeout)
15271531
return client
15281532
}
15291533

Sources/RTM/RTMConnection.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,9 @@ extension RTMConnection {
952952
return
953953
}
954954
if let defaultPeerID = self.defaultInstantMessagingPeerID {
955-
self.needPeerIDForEveryCommandOfInstantMessaging = (defaultPeerID != peerID)
955+
if !self.needPeerIDForEveryCommandOfInstantMessaging {
956+
self.needPeerIDForEveryCommandOfInstantMessaging = (defaultPeerID != peerID)
957+
}
956958
} else {
957959
self.defaultInstantMessagingPeerID = peerID
958960
}

0 commit comments

Comments
 (0)