[IMPROVE] Make message parser default (#4339)

This commit is contained in:
Diego Mello 2022-07-06 12:43:50 -03:00 committed by GitHub
parent 1027b6c9e6
commit 37db9b208d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 10 deletions

View File

@ -265,7 +265,14 @@ function stopListener(listener: any): boolean {
async function login(credentials: ICredentials, isFromWebView = false): Promise<ILoggedUser | undefined> { async function login(credentials: ICredentials, isFromWebView = false): Promise<ILoggedUser | undefined> {
// RC 0.64.0 // RC 0.64.0
await sdk.current.login(credentials); await sdk.current.login(credentials);
const serverVersion = store.getState().server.version;
const result = sdk.current.currentLogin?.result; const result = sdk.current.currentLogin?.result;
let enableMessageParserEarlyAdoption = true;
if (compareServerVersion(serverVersion, 'lowerThan', '5.0.0')) {
enableMessageParserEarlyAdoption = result.me.settings?.preferences?.enableMessageParserEarlyAdoption ?? true;
}
if (result) { if (result) {
const user: ILoggedUser = { const user: ILoggedUser = {
id: result.userId, id: result.userId,
@ -282,7 +289,7 @@ async function login(credentials: ICredentials, isFromWebView = false): Promise<
avatarETag: result.me.avatarETag, avatarETag: result.me.avatarETag,
isFromWebView, isFromWebView,
showMessageInMainThread: result.me.settings?.preferences?.showMessageInMainThread ?? true, showMessageInMainThread: result.me.settings?.preferences?.showMessageInMainThread ?? true,
enableMessageParserEarlyAdoption: result.me.settings?.preferences?.enableMessageParserEarlyAdoption ?? true enableMessageParserEarlyAdoption
}; };
return user; return user;
} }

View File

@ -6,6 +6,7 @@ import { useDispatch } from 'react-redux';
import { setUser } from '../../actions/login'; import { setUser } from '../../actions/login';
import I18n from '../../i18n'; import I18n from '../../i18n';
import log, { logEvent, events } from '../../lib/methods/helpers/log'; import log, { logEvent, events } from '../../lib/methods/helpers/log';
import { compareServerVersion } from '../../lib/methods/helpers';
import SafeAreaView from '../../containers/SafeAreaView'; import SafeAreaView from '../../containers/SafeAreaView';
import StatusBar from '../../containers/StatusBar'; import StatusBar from '../../containers/StatusBar';
import * as List from '../../containers/List'; import * as List from '../../containers/List';
@ -21,6 +22,7 @@ interface IUserPreferencesViewProps {
const UserPreferencesView = ({ navigation }: IUserPreferencesViewProps): JSX.Element => { const UserPreferencesView = ({ navigation }: IUserPreferencesViewProps): JSX.Element => {
const { enableMessageParserEarlyAdoption, id } = useAppSelector(state => getUserSelector(state)); const { enableMessageParserEarlyAdoption, id } = useAppSelector(state => getUserSelector(state));
const serverVersion = useAppSelector(state => state.server.version);
const dispatch = useDispatch(); const dispatch = useDispatch();
useEffect(() => { useEffect(() => {
@ -61,15 +63,17 @@ const UserPreferencesView = ({ navigation }: IUserPreferencesViewProps): JSX.Ele
/> />
<List.Separator /> <List.Separator />
</List.Section> </List.Section>
<List.Section> {compareServerVersion(serverVersion, 'lowerThan', '5.0.0') ? (
<List.Separator /> <List.Section>
<List.Item <List.Separator />
title='Enable_Message_Parser' <List.Item
testID='preferences-view-enable-message-parser' title='Enable_Message_Parser'
right={() => renderMessageParserSwitch(enableMessageParserEarlyAdoption)} testID='preferences-view-enable-message-parser'
/> right={() => renderMessageParserSwitch(enableMessageParserEarlyAdoption)}
<List.Separator /> />
</List.Section> <List.Separator />
</List.Section>
) : null}
</List.Container> </List.Container>
</SafeAreaView> </SafeAreaView>
); );