Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating channel with new information removes previous data properties #436

Closed
veloware opened this issue Sep 22, 2020 · 5 comments · Fixed by #439
Closed

updating channel with new information removes previous data properties #436

veloware opened this issue Sep 22, 2020 · 5 comments · Fixed by #439

Comments

@veloware
Copy link

veloware commented Sep 22, 2020

I have added a custom field on to a channel when creating the channel, isGroup -

server side

await this.client
      .channel('messaging', channelId, {
        created_by_id: profileId,
        members: [profileId, ...connectionProfileIds],
        isGroup: true,
      })
      .create();

I can see the isGroup: true in the newly created channel when queried on the front end.

I then later wish to update the name for a group on the front end -

client side

await props.channel?.update({
          name: value,
        });

however it seems that although name is updated, I lose the isGroup property.

I have also tried to spread the existing data -

await props.channel?.update({
        ...props.channel.data,
        name: value,
      });

however I get the following TS errors -

Screenshot 2020-09-22 at 11 18 53

I have noticed this across all data properties, e.g. changing the name property by passing only the name property, removes the likes of image etc.

Any help on how to update channel data without removing old channel data? I shouldnt need to pass all channel data properties into each .update() call.

Thanks

gz#6161

@veloware veloware changed the title updating channel with new information removes old custom properties updating channel with new information removes previous data properties Sep 22, 2020
@shodgetts
Copy link

Agent comment from Stephen Hodgetts in Zendesk ticket #6161:

Thanks for the report... investigating.

@vishalnarkhede
Copy link
Contributor

Hey @veloware ,

We are aware of the issue that you mentioned. For channel.update, you will need to send all the properties manually everytime:

channel.update({
  isGroup: channel.data.isGroup
  name: value,
})

@vishalnarkhede vishalnarkhede linked a pull request Sep 23, 2020 that will close this issue
3 tasks
@veloware
Copy link
Author

veloware commented Oct 5, 2020

This seems to still giving an error for properties on the user/member of the channel -

data.members[0].user.created_at is a reserved field, data.members[0].user.last_active is a reserved field, data.members[0].user.online is a reserved field, data.members[0].user.updated_at is a reserved field

@gumuz
Copy link
Contributor

gumuz commented Oct 6, 2020

@vishalnarkhede you think we should exclude members as well or is this a different problem?

@veloware
Copy link
Author

any thoughts on the above? The above error stops you from using the solution of spreading in the existing channel data as done in the unit tests. Not sure if this is because the test data may not have a proper representation of a member object, containing user with a created_at etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants