Skip to content

Commit 779c53d

Browse files
committed
Add additional guard statement
1 parent 76116e9 commit 779c53d

File tree

8 files changed

+8
-8
lines changed

8 files changed

+8
-8
lines changed

Sources/Entities/BaseChannel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final class BaseChannel<C: PubNubChat.Channel_, M: PubNubChat.Message>: Channel
3434
channels: [BaseChannel],
3535
callback: @escaping (([BaseChannel]) -> Void)
3636
) -> AutoCloseable {
37-
guard let firstChat = channels.first?.chat else {
37+
guard let firstChat = channels.first?.chat, channels.allSatisfy({ $0.chat === firstChat }) else {
3838
return AutoCloseableImpl.empty()
3939
}
4040
return AutoCloseableImpl(

Sources/Entities/BaseMessage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ extension BaseMessage: Message {
5353
messages: [BaseMessage],
5454
callback: @escaping (([BaseMessage]) -> Void)
5555
) -> AutoCloseable {
56-
guard let firstChat = messages.first?.chat else {
56+
guard let firstChat = messages.first?.chat, messages.allSatisfy({ $0.chat === firstChat }) else {
5757
return AutoCloseableImpl.empty()
5858
}
5959
return AutoCloseableImpl(

Sources/Entities/ChannelImpl.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ extension ChannelImpl: Channel {
7777
channels: [ChannelImpl],
7878
callback: @escaping (([ChannelImpl]) -> Void)
7979
) -> AutoCloseable {
80-
guard let firstChat = channels.first?.chat else {
80+
guard let firstChat = channels.first?.chat, channels.allSatisfy({ $0.chat === firstChat }) else {
8181
return AutoCloseableImpl.empty()
8282
}
8383
return AutoCloseableImpl(

Sources/Entities/MembershipImpl.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ extension MembershipImpl: Membership {
7070
memberships: [MembershipImpl],
7171
callback: @escaping (([MembershipImpl]) -> Void)
7272
) -> AutoCloseable {
73-
guard let firstChat = memberships.first?.chat else {
73+
guard let firstChat = memberships.first?.chat, memberships.allSatisfy({ $0.chat === firstChat }) else {
7474
return AutoCloseableImpl.empty()
7575
}
7676
return AutoCloseableImpl(

Sources/Entities/MessageImpl.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ extension MessageImpl: Message {
8585
messages: [MessageImpl],
8686
callback: @escaping (([MessageImpl]) -> Void)
8787
) -> AutoCloseable {
88-
guard let firstChat = messages.first?.chat else {
88+
guard let firstChat = messages.first?.chat, messages.allSatisfy({ $0.chat === firstChat }) else {
8989
return AutoCloseableImpl.empty()
9090
}
9191
return AutoCloseableImpl(

Sources/Entities/ThreadChannelImpl.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ extension ThreadChannelImpl: ThreadChannel {
8282
channels: [ThreadChannelImpl],
8383
callback: @escaping (([ThreadChannelImpl]) -> Void)
8484
) -> AutoCloseable {
85-
guard let firstChat = channels.first?.chat else {
85+
guard let firstChat = channels.first?.chat, channels.allSatisfy({ $0.chat === firstChat }) else {
8686
return AutoCloseableImpl.empty()
8787
}
8888
return AutoCloseableImpl(

Sources/Entities/ThreadMessageImpl.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ extension ThreadMessageImpl: ThreadMessage {
9494
messages: [ThreadMessageImpl],
9595
callback: @escaping (([ThreadMessageImpl]) -> Void)
9696
) -> AutoCloseable {
97-
guard let firstChat = messages.first?.chat else {
97+
guard let firstChat = messages.first?.chat, messages.allSatisfy({ $0.chat === firstChat }) else {
9898
return AutoCloseableImpl.empty()
9999
}
100100
return AutoCloseableImpl(

Sources/Entities/UserImpl.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ extension UserImpl: User {
8787
public var active: Bool { user.active }
8888

8989
public static func streamUpdatesOn(users: [UserImpl], callback: @escaping (([UserImpl]) -> Void)) -> AutoCloseable {
90-
guard let firstChat = users.first?.chat else {
90+
guard let firstChat = users.first?.chat, users.allSatisfy({ $0.chat === firstChat }) else {
9191
return AutoCloseableImpl.empty()
9292
}
9393
return AutoCloseableImpl(

0 commit comments

Comments
 (0)