[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> {
// RC 0.64.0
await sdk.current.login(credentials);
const serverVersion = store.getState().server.version;
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) {
const user: ILoggedUser = {
id: result.userId,
@ -282,7 +289,7 @@ async function login(credentials: ICredentials, isFromWebView = false): Promise<
avatarETag: result.me.avatarETag,
isFromWebView,
showMessageInMainThread: result.me.settings?.preferences?.showMessageInMainThread ?? true,
enableMessageParserEarlyAdoption: result.me.settings?.preferences?.enableMessageParserEarlyAdoption ?? true
enableMessageParserEarlyAdoption
};
return user;
}

View File

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