Remove message-parser lib and add enable message parser field to User model
This commit is contained in:
parent
f779a0ac31
commit
c95c2089fb
|
@ -26,6 +26,9 @@ export default {
|
|||
Accounts_CustomFields: {
|
||||
type: 'valueAsString'
|
||||
},
|
||||
Accounts_Default_User_Preferences_enableMessageParserEarlyAdoption: {
|
||||
type: 'valueAsBoolean'
|
||||
},
|
||||
Accounts_EmailOrUsernamePlaceholder: {
|
||||
type: 'valueAsString'
|
||||
},
|
||||
|
@ -202,8 +205,5 @@ export default {
|
|||
},
|
||||
Jitsi_Enable_Channels: {
|
||||
type: 'valuesAsBoolean'
|
||||
},
|
||||
Accounts_Default_User_Preferences_enableMessageParserEarlyAdoption: {
|
||||
type: 'valueAsBoolean'
|
||||
}
|
||||
};
|
||||
|
|
|
@ -25,4 +25,6 @@ export default class User extends Model {
|
|||
@field('show_message_in_main_thread') showMessageInMainThread;
|
||||
|
||||
@field('is_from_webview') isFromWebView;
|
||||
|
||||
@field('enable_message_parser_early_adoption') enableMessageParserEarlyAdoption;
|
||||
}
|
||||
|
|
|
@ -105,6 +105,17 @@ export default schemaMigrations({
|
|||
]
|
||||
})
|
||||
]
|
||||
},
|
||||
{
|
||||
toVersion: 12,
|
||||
steps: [
|
||||
addColumns({
|
||||
table: 'users',
|
||||
columns: [
|
||||
{ name: 'enable_message_parser_early_adoption', type: 'boolean', isOptional: true }
|
||||
]
|
||||
})
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { appSchema, tableSchema } from '@nozbe/watermelondb';
|
||||
|
||||
export default appSchema({
|
||||
version: 11,
|
||||
version: 12,
|
||||
tables: [
|
||||
tableSchema({
|
||||
name: 'users',
|
||||
|
@ -16,7 +16,8 @@ export default appSchema({
|
|||
{ name: 'login_email_password', type: 'boolean', isOptional: true },
|
||||
{ name: 'show_message_in_main_thread', type: 'boolean', isOptional: true },
|
||||
{ name: 'avatar_etag', type: 'string', isOptional: true },
|
||||
{ name: 'is_from_webview', type: 'boolean', isOptional: true }
|
||||
{ name: 'is_from_webview', type: 'boolean', isOptional: true },
|
||||
{ name: 'enable_message_parser_early_adoption', type: 'boolean', isOptional: true }
|
||||
]
|
||||
}),
|
||||
tableSchema({
|
||||
|
|
|
@ -61,11 +61,9 @@ class ProfileView extends React.Component {
|
|||
theme: PropTypes.string
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
const { Accounts_enableMessageParserEarlyAdoption } = this.props;
|
||||
this.state = {
|
||||
state = {
|
||||
saving: false,
|
||||
enableMessageParserEarlyAdoption: false,
|
||||
name: null,
|
||||
username: null,
|
||||
email: null,
|
||||
|
@ -74,10 +72,8 @@ class ProfileView extends React.Component {
|
|||
avatarUrl: null,
|
||||
avatar: {},
|
||||
avatarSuggestions: {},
|
||||
customFields: {},
|
||||
enableMessageParser: Accounts_enableMessageParserEarlyAdoption
|
||||
customFields: {}
|
||||
};
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
this.init();
|
||||
|
@ -116,7 +112,7 @@ class ProfileView extends React.Component {
|
|||
init = (user) => {
|
||||
const { user: userProps } = this.props;
|
||||
const {
|
||||
name, username, emails, customFields
|
||||
name, username, emails, customFields, enableMessageParserEarlyAdoption
|
||||
} = user || userProps;
|
||||
|
||||
this.setState({
|
||||
|
@ -127,13 +123,14 @@ class ProfileView extends React.Component {
|
|||
currentPassword: null,
|
||||
avatarUrl: null,
|
||||
avatar: {},
|
||||
customFields: customFields || {}
|
||||
customFields: customFields || {},
|
||||
enableMessageParserEarlyAdoption
|
||||
});
|
||||
}
|
||||
|
||||
formIsChanged = () => {
|
||||
const {
|
||||
name, username, email, newPassword, avatar, customFields
|
||||
name, username, email, newPassword, avatar, customFields, enableMessageParserEarlyAdoption
|
||||
} = this.state;
|
||||
const { user } = this.props;
|
||||
let customFieldsChanged = false;
|
||||
|
@ -149,6 +146,7 @@ class ProfileView extends React.Component {
|
|||
|
||||
return !(user.name === name
|
||||
&& user.username === username
|
||||
&& user.enableMessageParserEarlyAdoption === enableMessageParserEarlyAdoption
|
||||
&& !newPassword
|
||||
&& (user.emails && user.emails[0].address === email)
|
||||
&& !avatar.data
|
||||
|
@ -173,7 +171,7 @@ class ProfileView extends React.Component {
|
|||
this.setState({ saving: true });
|
||||
|
||||
const {
|
||||
name, username, email, newPassword, currentPassword, avatar, customFields, enableMessageParser
|
||||
name, username, email, newPassword, currentPassword, avatar, customFields, enableMessageParserEarlyAdoption
|
||||
} = this.state;
|
||||
const { user, setUser } = this.props;
|
||||
const params = {};
|
||||
|
@ -203,6 +201,11 @@ 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 });
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
"@react-navigation/drawer": "5.12.5",
|
||||
"@react-navigation/native": "5.9.4",
|
||||
"@react-navigation/stack": "5.14.5",
|
||||
"@rocket.chat/message-parser": "^0.27.0",
|
||||
"@rocket.chat/react-native-fast-image": "^8.2.0",
|
||||
"@rocket.chat/sdk": "RocketChat/Rocket.Chat.js.SDK#mobile",
|
||||
"@rocket.chat/ui-kit": "0.13.0",
|
||||
|
|
|
@ -3215,11 +3215,6 @@
|
|||
resolved "https://registry.yarnpkg.com/@redux-saga/types/-/types-1.1.0.tgz#0e81ce56b4883b4b2a3001ebe1ab298b84237204"
|
||||
integrity sha512-afmTuJrylUU/0OtqzaRkbyYFFNgCF73Bvel/sw90pvGrWIZ+vyoIJqA6eMSoA6+nb443kTmulmBtC9NerXboNg==
|
||||
|
||||
"@rocket.chat/message-parser@^0.27.0":
|
||||
version "0.27.0"
|
||||
resolved "https://registry.yarnpkg.com/@rocket.chat/message-parser/-/message-parser-0.27.0.tgz#55a07887da649bffb9277aa11ae843a0f5d22895"
|
||||
integrity sha512-CJxV1N4aSOrTeGKPX+685EeYiG7AMivp8N23SHMZpmbxF36IoVsrdFlxlLRw11Dq8ZMkz4TXAyVk0i4Pvu/psA==
|
||||
|
||||
"@rocket.chat/react-native-fast-image@^8.2.0":
|
||||
version "8.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@rocket.chat/react-native-fast-image/-/react-native-fast-image-8.2.0.tgz#4f48858f95f40afcb10b39cee9b1239c150d6c51"
|
||||
|
|
Loading…
Reference in New Issue