Skip to content

Instantly share code, notes, and snippets.

@anchetaWern
Last active June 27, 2019 01:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anchetaWern/37bf0c1091ef2d5098e57e75c2b29546 to your computer and use it in GitHub Desktop.
Save anchetaWern/37bf0c1091ef2d5098e57e75c2b29546 to your computer and use it in GitHub Desktop.
React Native Stream Chat Profanity Filtering: Listen for updated messages
channel.on('message.updated', async (event) => {
const { message } = this.getMessage(event.message);
if (message.user._id == this.user_id) {
if (message.user.warn_count < 3) {
Alert.alert("Profanity warning", "You will be banned indefinitely on the 3rd time you do this.");
}
}
this.setState(state => {
const messages = state.messages.map((item) => {
if (item._id == message._id) {
return { ...item, text: message.text };
} else {
return item;
}
});
return {
messages
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment