stream-chat-android icon indicating copy to clipboard operation
stream-chat-android copied to clipboard

Newly added Channel list item missing major properties

Open Chikrix opened this issue 7 years ago • 6 comments

When a user creates a channel and the channel list refreshes with the new list item, when I try to access the newly added channel properties in my channel detail fragment usingstreamClient.channel(channelType, channelId), it's missing several properties like the name, members, etc which adds more work using this channel. Also the channel isn't watching for updates to update the last message and other properties (doesn't act like other channels listed)

Chikrix avatar Nov 02 '19 19:11 Chikrix

@Chikrix , Thanks for your reporting. I have question for your creating new channel. Did you create the channel with withWatch in ChannelQueryRequest ? If you don't set watch option in ChannelQueryRequest you can't get detail info from streamClient.channel(channelType, channelId).

Let me know you are using same code below

val extraData = HashMap<String, Any>()
extraData["name"] = channelName

val members = ArrayList<String>()
members.add(client.getUser().getId())
extraData["members"] = members

val channel = Channel(client, ModelType.channel_messaging, channelId, extraData)
val request = ChannelQueryRequest().withMessages(20).withWatch()

channel.query(request, object : QueryChannelCallback {
	override fun onSuccess(response: ChannelState) {
						
	}

	override fun onError(errMsg: String, errCode: Int) {           
		
	}
})

adrian09h avatar Nov 05 '19 18:11 adrian09h

@adrian09h here's my code for creating channels;

val channelDetails = hashMapOf<String, Any>()
channelDetails[NAME] = channelName
channelDetails[MEMBERS] = membersList // list of userIDs including this user
val channelType = ChannelType.MESSAGING
val channelID = if (membersList.size == 2) {
      channelDetails[IS_GROUP_CHAT] = false
      null
 } else {
       channelDetails[IS_GROUP_CHAT] = true
       "$channelType${UUIDUtils.randomUUIDString()}"
}
val channel = Channel(streamClient, channelType.toString(), channelID, channelDetails)
        val request =
ChannelQueryRequest().withMessages(20).withWatch()
channel.query(request, object : QueryChannelCallback {
            override fun onSuccess(response: ChannelState) {
                // some details were missing in the channel so 
                channel.createdByUser = response.channel.createdByUser
                channel.createdByUserID = response.channel.createdByUserID
                channelCreationListener.onChannelCreated(channel)
            }

            override fun onError(errMsg: String, errCode: Int) {
                channelCreationListener.onChannelCreationFailed(errMsg)
                Log.exception(IllegalStateException("Error setting chat user $errMsg with code $errCode "))
            }
        })

There's no issue with the channel of the user creating the channel, the issue is for other members who see the newly created channel added to their channel list and select the newly added channel

Chikrix avatar Nov 05 '19 22:11 Chikrix

@Chikrix are you using last version? We have released new version 3.2.3 yesterday. Please try last version.

adrian09h avatar Nov 06 '19 14:11 adrian09h

@adrian09h I was using a snapshot of master but above 3.2.0. I'll update now and check. Thanks

Chikrix avatar Nov 06 '19 20:11 Chikrix

@adrian09h I still get this issue. How to reproduce; on two different devices, start a conversation on one (create a new channel), and have the other one open already in the list screen. When the channel list updates in the other device (the newly created channel is added to the list), open that newly added item in the channel detail, if you look into the item, it's missing several key properties, also, if the other member sends a message, it doesn't see their message, but the other member can see its message.

Chikrix avatar Nov 06 '19 21:11 Chikrix

@bevzaanton did some debugging; channel creation sends the extra data correctly; this seems to be an issue with how the notification event is handled in ChatEventHandler. I did not test this but we might have to change channel.query into channel.watch there (line 216) and look into why the extra data is not populated correctly

tbarbugli avatar Nov 08 '19 17:11 tbarbugli