Remove message-parser lib and add enable message parser field to User model

This commit is contained in:
Gerzon Z 2021-07-30 14:24:05 -04:00
parent f779a0ac31
commit c95c2089fb
7 changed files with 43 additions and 32 deletions

View File

@ -26,6 +26,9 @@ export default {
Accounts_CustomFields: { Accounts_CustomFields: {
type: 'valueAsString' type: 'valueAsString'
}, },
Accounts_Default_User_Preferences_enableMessageParserEarlyAdoption: {
type: 'valueAsBoolean'
},
Accounts_EmailOrUsernamePlaceholder: { Accounts_EmailOrUsernamePlaceholder: {
type: 'valueAsString' type: 'valueAsString'
}, },
@ -202,8 +205,5 @@ export default {
}, },
Jitsi_Enable_Channels: { Jitsi_Enable_Channels: {
type: 'valuesAsBoolean' type: 'valuesAsBoolean'
},
Accounts_Default_User_Preferences_enableMessageParserEarlyAdoption: {
type: 'valueAsBoolean'
} }
}; };

View File

@ -25,4 +25,6 @@ export default class User extends Model {
@field('show_message_in_main_thread') showMessageInMainThread; @field('show_message_in_main_thread') showMessageInMainThread;
@field('is_from_webview') isFromWebView; @field('is_from_webview') isFromWebView;
@field('enable_message_parser_early_adoption') enableMessageParserEarlyAdoption;
} }

View File

@ -105,6 +105,17 @@ export default schemaMigrations({
] ]
}) })
] ]
},
{
toVersion: 12,
steps: [
addColumns({
table: 'users',
columns: [
{ name: 'enable_message_parser_early_adoption', type: 'boolean', isOptional: true }
]
})
]
} }
] ]
}); });

View File

@ -1,7 +1,7 @@
import { appSchema, tableSchema } from '@nozbe/watermelondb'; import { appSchema, tableSchema } from '@nozbe/watermelondb';
export default appSchema({ export default appSchema({
version: 11, version: 12,
tables: [ tables: [
tableSchema({ tableSchema({
name: 'users', name: 'users',
@ -16,7 +16,8 @@ export default appSchema({
{ name: 'login_email_password', type: 'boolean', isOptional: true }, { name: 'login_email_password', type: 'boolean', isOptional: true },
{ name: 'show_message_in_main_thread', type: 'boolean', isOptional: true }, { name: 'show_message_in_main_thread', type: 'boolean', isOptional: true },
{ name: 'avatar_etag', type: 'string', 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({ tableSchema({

View File

@ -61,23 +61,19 @@ class ProfileView extends React.Component {
theme: PropTypes.string theme: PropTypes.string
} }
constructor(props) { state = {
super(props); saving: false,
const { Accounts_enableMessageParserEarlyAdoption } = this.props; enableMessageParserEarlyAdoption: false,
this.state = { name: null,
saving: false, username: null,
name: null, email: null,
username: null, newPassword: null,
email: null, currentPassword: null,
newPassword: null, avatarUrl: null,
currentPassword: null, avatar: {},
avatarUrl: null, avatarSuggestions: {},
avatar: {}, customFields: {}
avatarSuggestions: {}, };
customFields: {},
enableMessageParser: Accounts_enableMessageParserEarlyAdoption
};
}
async componentDidMount() { async componentDidMount() {
this.init(); this.init();
@ -116,7 +112,7 @@ class ProfileView extends React.Component {
init = (user) => { init = (user) => {
const { user: userProps } = this.props; const { user: userProps } = this.props;
const { const {
name, username, emails, customFields name, username, emails, customFields, enableMessageParserEarlyAdoption
} = user || userProps; } = user || userProps;
this.setState({ this.setState({
@ -127,13 +123,14 @@ class ProfileView extends React.Component {
currentPassword: null, currentPassword: null,
avatarUrl: null, avatarUrl: null,
avatar: {}, avatar: {},
customFields: customFields || {} customFields: customFields || {},
enableMessageParserEarlyAdoption
}); });
} }
formIsChanged = () => { formIsChanged = () => {
const { const {
name, username, email, newPassword, avatar, customFields name, username, email, newPassword, avatar, customFields, enableMessageParserEarlyAdoption
} = this.state; } = this.state;
const { user } = this.props; const { user } = this.props;
let customFieldsChanged = false; let customFieldsChanged = false;
@ -149,6 +146,7 @@ class ProfileView extends React.Component {
return !(user.name === name return !(user.name === name
&& user.username === username && user.username === username
&& user.enableMessageParserEarlyAdoption === enableMessageParserEarlyAdoption
&& !newPassword && !newPassword
&& (user.emails && user.emails[0].address === email) && (user.emails && user.emails[0].address === email)
&& !avatar.data && !avatar.data
@ -173,7 +171,7 @@ class ProfileView extends React.Component {
this.setState({ saving: true }); this.setState({ saving: true });
const { const {
name, username, email, newPassword, currentPassword, avatar, customFields, enableMessageParser name, username, email, newPassword, currentPassword, avatar, customFields, enableMessageParserEarlyAdoption
} = this.state; } = this.state;
const { user, setUser } = this.props; const { user, setUser } = this.props;
const params = {}; const params = {};
@ -203,6 +201,11 @@ class ProfileView extends React.Component {
params.currentPassword = SHA256(currentPassword); params.currentPassword = SHA256(currentPassword);
} }
// MessageParser
if (user.enableMessageParserEarlyAdoption !== enableMessageParserEarlyAdoption) {
params.enableMessageParserEarlyAdoption = enableMessageParserEarlyAdoption;
}
const requirePassword = !!params.email || newPassword; const requirePassword = !!params.email || newPassword;
if (requirePassword && !params.currentPassword) { if (requirePassword && !params.currentPassword) {
this.setState({ saving: false }); this.setState({ saving: false });

View File

@ -45,7 +45,6 @@
"@react-navigation/drawer": "5.12.5", "@react-navigation/drawer": "5.12.5",
"@react-navigation/native": "5.9.4", "@react-navigation/native": "5.9.4",
"@react-navigation/stack": "5.14.5", "@react-navigation/stack": "5.14.5",
"@rocket.chat/message-parser": "^0.27.0",
"@rocket.chat/react-native-fast-image": "^8.2.0", "@rocket.chat/react-native-fast-image": "^8.2.0",
"@rocket.chat/sdk": "RocketChat/Rocket.Chat.js.SDK#mobile", "@rocket.chat/sdk": "RocketChat/Rocket.Chat.js.SDK#mobile",
"@rocket.chat/ui-kit": "0.13.0", "@rocket.chat/ui-kit": "0.13.0",

View File

@ -3215,11 +3215,6 @@
resolved "https://registry.yarnpkg.com/@redux-saga/types/-/types-1.1.0.tgz#0e81ce56b4883b4b2a3001ebe1ab298b84237204" resolved "https://registry.yarnpkg.com/@redux-saga/types/-/types-1.1.0.tgz#0e81ce56b4883b4b2a3001ebe1ab298b84237204"
integrity sha512-afmTuJrylUU/0OtqzaRkbyYFFNgCF73Bvel/sw90pvGrWIZ+vyoIJqA6eMSoA6+nb443kTmulmBtC9NerXboNg== 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": "@rocket.chat/react-native-fast-image@^8.2.0":
version "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" resolved "https://registry.yarnpkg.com/@rocket.chat/react-native-fast-image/-/react-native-fast-image-8.2.0.tgz#4f48858f95f40afcb10b39cee9b1239c150d6c51"