Skip to content

Instantly share code, notes, and snippets.

@sendbird-community
Created December 29, 2021 22:05
Show Gist options
  • Save sendbird-community/1fa6f4b6a1fbeced0082d6e5a2f5c125 to your computer and use it in GitHub Desktop.
Save sendbird-community/1fa6f4b6a1fbeced0082d6e5a2f5c125 to your computer and use it in GitHub Desktop.
updateChannelParams function
const updateChannelParams = () => {
var channelParams = new sdk.GroupChannelParams();
var messageId = message.messageId;
var channelDataString = "";
if (currentChannel.data) {
var parsedChannelData = JSON.parse(currentChannel.data);
parsedChannelData[`${messageId}`] = {
voting_app_options: [],
};
channelDataString = JSON.stringify(parsedChannelData);
} else {
var newChannelData = {};
newChannelData[`${messageId}`] = {
voting_app_options: [],
};
channelDataString = JSON.stringify(newChannelData);
}
channelParams.data = channelDataString;
currentChannel.updateChannel(channelParams, (err, channel) => {
var parsedChannelData = JSON.parse(channelParams.data);
console.log("updatedChannelParamsData new=", parsedChannelData);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment