Skip to content

Commit

Permalink
Check the result is success for joinTheCommonChannel
Browse files Browse the repository at this point in the history
  • Loading branch information
skydoves committed Dec 14, 2022
1 parent 0301951 commit 4184ced
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ internal class GPTChannelRepositoryImpl @Inject constructor(

override suspend fun joinTheCommonChannel(user: User) {
val channelClient = chatClient.channel(commonChannelId)
val members = channelClient.watch().await().data().members
val isExist = members.firstOrNull { it.user.id == user.id }
if (isExist == null) {
channelClient.addMembers(listOf(user.id)).await()
val result = channelClient.watch().await()
if (result.isSuccess) {
val members = result.data().members
val isExist = members.firstOrNull { it.user.id == user.id }
if (isExist == null) {
channelClient.addMembers(listOf(user.id)).await()
}
}
}

Expand Down

0 comments on commit 4184ced

Please sign in to comment.