diff --git a/app/containers/markdown/index.js b/app/containers/markdown/index.js index bc2fdba73..6eef6e7e9 100644 --- a/app/containers/markdown/index.js +++ b/app/containers/markdown/index.js @@ -68,6 +68,7 @@ const parser = new Parser(); class Markdown extends PureComponent { static propTypes = { msg: PropTypes.string, + md: PropTypes.string, getCustomEmoji: PropTypes.func, baseUrl: PropTypes.string, username: PropTypes.string, diff --git a/app/containers/message/Content.js b/app/containers/message/Content.js index 90af48acd..3d8151217 100644 --- a/app/containers/message/Content.js +++ b/app/containers/message/Content.js @@ -48,6 +48,7 @@ const Content = React.memo((props) => { const { baseUrl, user, onLinkPress } = useContext(MessageContext); content = ( { @@ -63,7 +65,7 @@ class ProfileView extends React.Component { state = { saving: false, - enableMessageParserEarlyAdoption: false, + enableMessageParser: false, name: null, username: null, email: null, @@ -72,7 +74,8 @@ class ProfileView extends React.Component { avatarUrl: null, avatar: {}, avatarSuggestions: {}, - customFields: {} + customFields: {}, + preferences: [] }; async componentDidMount() { @@ -109,12 +112,15 @@ class ProfileView extends React.Component { this.setState({ avatar }); } - init = (user) => { + init = async(user) => { const { user: userProps } = this.props; const { - name, username, emails, customFields, enableMessageParserEarlyAdoption + name, username, emails, customFields, id } = user || userProps; + const result = await RocketChat.getUserPreferences(id); + const { preferences } = result; + this.setState({ name, username, @@ -124,13 +130,14 @@ class ProfileView extends React.Component { avatarUrl: null, avatar: {}, customFields: customFields || {}, - enableMessageParserEarlyAdoption + enableMessageParser: preferences?.enableMessageParserEarlyAdoption || false, + preferences }); } formIsChanged = () => { const { - name, username, email, newPassword, avatar, customFields, enableMessageParserEarlyAdoption + name, username, email, newPassword, avatar, customFields, enableMessageParser, preferences } = this.state; const { user } = this.props; let customFieldsChanged = false; @@ -146,7 +153,7 @@ class ProfileView extends React.Component { return !(user.name === name && user.username === username - && user.enableMessageParserEarlyAdoption === enableMessageParserEarlyAdoption + && preferences.enableMessageParserEarlyAdoption === enableMessageParser && !newPassword && (user.emails && user.emails[0].address === email) && !avatar.data @@ -171,7 +178,7 @@ class ProfileView extends React.Component { this.setState({ saving: true }); const { - name, username, email, newPassword, currentPassword, avatar, customFields, enableMessageParserEarlyAdoption + name, username, email, newPassword, currentPassword, avatar, customFields } = this.state; const { user, setUser } = this.props; const params = {}; @@ -201,11 +208,6 @@ class ProfileView extends React.Component { params.currentPassword = SHA256(currentPassword); } - // MessageParser - if (user.enableMessageParserEarlyAdoption !== enableMessageParserEarlyAdoption) { - params.enableMessageParserEarlyAdoption = enableMessageParserEarlyAdoption; - } - const requirePassword = !!params.email || newPassword; if (requirePassword && !params.currentPassword) { this.setState({ saving: false }); @@ -433,7 +435,18 @@ class ProfileView extends React.Component { } } - toggleEnableMessageParserEarlyAdoption = (value) => { + renderMessageParserSwitch = () => { + const { enableMessageParser } = this.state; + return ( + + ); + } + + toggleEnableMessageParser = (value) => { // logEvent(events.RI_EDIT_TOGGLE_SYSTEM_MSG); this.setState({ enableMessageParser: value }); } @@ -457,7 +470,7 @@ class ProfileView extends React.Component { render() { const { - name, username, email, newPassword, avatarUrl, customFields, avatar, saving, enableMessageParser + name, username, email, newPassword, avatarUrl, customFields, avatar, saving } = this.state; const { user, @@ -554,16 +567,16 @@ class ProfileView extends React.Component { testID='profile-view-new-password' theme={theme} /> - this.setState({ enableMessageParser: value })} - labelContainerStyle={styles.hideSystemMessages} - leftLabelStyle={styles.systemMessagesLabel} - /> + + {Accounts_enableMessageParserEarlyAdoption + ? ( + this.renderMessageParserSwitch()} + /> + ) : null} + {this.renderCustomFields()}