Last active
June 27, 2019 01:26
-
-
Save anchetaWern/37bf0c1091ef2d5098e57e75c2b29546 to your computer and use it in GitHub Desktop.
React Native Stream Chat Profanity Filtering: Listen for updated messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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