Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
320 changes: 160 additions & 160 deletions __tests__/__snapshots__/Storyshots.test.js.snap

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions app/containers/Passcode/Base/Dots.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { View } from 'react-native';
import _ from 'lodash';
import range from 'lodash/range';
import PropTypes from 'prop-types';

import styles from './styles';
Expand All @@ -11,7 +11,7 @@ const SIZE_FULL = 16;

const Dots = React.memo(({ passcode, theme, length }) => (
<View style={styles.dotsContainer}>
{_.range(length).map((val) => {
{range(length).map((val) => {
const lengthSup = (passcode.length >= val + 1);
const height = lengthSup ? SIZE_FULL : SIZE_EMPTY;
const width = lengthSup ? SIZE_FULL : SIZE_EMPTY;
Expand Down
8 changes: 4 additions & 4 deletions app/containers/Passcode/Base/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, {
useState, forwardRef, useImperativeHandle, useRef
} from 'react';
import { Col, Row, Grid } from 'react-native-easy-grid';
import _ from 'lodash';
import range from 'lodash/range';
import PropTypes from 'prop-types';
import * as Animatable from 'react-native-animatable';
import * as Haptics from 'expo-haptics';
Expand Down Expand Up @@ -84,21 +84,21 @@ const Base = forwardRef(({
</Animatable.View>
</Row>
<Row style={[styles.row, styles.buttonRow]}>
{_.range(1, 4).map(i => (
{range(1, 4).map(i => (
<Col key={i} style={styles.colButton}>
<Button text={i} theme={theme} onPress={onPressNumber} />
</Col>
))}
</Row>
<Row style={[styles.row, styles.buttonRow]}>
{_.range(4, 7).map(i => (
{range(4, 7).map(i => (
<Col key={i} style={styles.colButton}>
<Button text={i} theme={theme} onPress={onPressNumber} />
</Col>
))}
</Row>
<Row style={[styles.row, styles.buttonRow]}>
{_.range(7, 10).map(i => (
{range(7, 10).map(i => (
<Col key={i} style={styles.colButton}>
<Button text={i} theme={theme} onPress={onPressNumber} />
</Col>
Expand Down
4 changes: 2 additions & 2 deletions app/containers/TwoFactor/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react';
import { View, Text, InteractionManager } from 'react-native';
import _ from 'lodash';
import isEmpty from 'lodash/isEmpty';
import PropTypes from 'prop-types';
import { sha256 } from 'js-sha256';
import Modal from 'react-native-modal';
Expand Down Expand Up @@ -47,7 +47,7 @@ const TwoFactor = React.memo(({ theme, isMasterDetail }) => {
const sendEmail = () => RocketChat.sendEmailCode();

useDeepCompareEffect(() => {
if (!_.isEmpty(data)) {
if (!isEmpty(data)) {
setCode('');
setVisible(true);
} else {
Expand Down
5 changes: 3 additions & 2 deletions app/lib/methods/enterpriseModules.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import semver from 'semver';
import gte from 'semver/functions/gte';
import coerce from 'semver/functions/coerce';

import reduxStore from '../createStore';
import database from '../database';
Expand Down Expand Up @@ -33,7 +34,7 @@ export function getEnterpriseModules() {
return new Promise(async(resolve) => {
try {
const { version: serverVersion, server: serverId } = reduxStore.getState().server;
if (serverVersion && semver.gte(semver.coerce(serverVersion), '3.1.0')) {
if (serverVersion && gte(coerce(serverVersion), '3.1.0')) {
// RC 3.1.0
const enterpriseModules = await this.methodCallWrapper('license:getModules');
if (enterpriseModules) {
Expand Down
4 changes: 2 additions & 2 deletions app/lib/methods/getCustomEmojis.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { InteractionManager } from 'react-native';
import semver from 'semver';
import lt from 'semver/functions/lt';
import orderBy from 'lodash/orderBy';
import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord';

Expand Down Expand Up @@ -91,7 +91,7 @@ export function getCustomEmojis() {
const updatedSince = await getUpdatedSince(allRecords);

// if server version is lower than 0.75.0, fetches from old api
if (serverVersion && semver.lt(serverVersion, '0.75.0')) {
if (serverVersion && lt(serverVersion, '0.75.0')) {
// RC 0.61.0
const result = await this.sdk.get('emoji-custom');

Expand Down
6 changes: 3 additions & 3 deletions app/lib/methods/getPermissions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { InteractionManager } from 'react-native';
import semver from 'semver';
import lt from 'semver/functions/lt';
import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord';
import { orderBy } from 'lodash';
import orderBy from 'lodash/orderBy';

import database from '../database';
import log from '../../utils/log';
Expand Down Expand Up @@ -79,7 +79,7 @@ export default function() {
const allRecords = await permissionsCollection.query().fetch();

// if server version is lower than 0.73.0, fetches from old api
if (serverVersion && semver.lt(serverVersion, '0.73.0')) {
if (serverVersion && lt(serverVersion, '0.73.0')) {
// RC 0.66.0
const result = await this.sdk.get('permissions.list');
if (!result.success) {
Expand Down
9 changes: 5 additions & 4 deletions app/lib/methods/getUsersPresence.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { InteractionManager } from 'react-native';
import semver from 'semver';
import lt from 'semver/functions/lt';
import gte from 'semver/functions/gte';
import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord';

import reduxStore from '../createStore';
Expand All @@ -11,7 +12,7 @@ export function subscribeUsersPresence() {
const serverVersion = reduxStore.getState().server.version;

// if server is lower than 1.1.0
if (serverVersion && semver.lt(serverVersion, '1.1.0')) {
if (serverVersion && lt(serverVersion, '1.1.0')) {
if (this.activeUsersSubTimeout) {
clearTimeout(this.activeUsersSubTimeout);
this.activeUsersSubTimeout = false;
Expand All @@ -36,11 +37,11 @@ export default async function getUsersPresence() {
const { user: loggedUser } = reduxStore.getState().login;

// if server is greather than or equal 1.1.0
if (serverVersion && semver.gte(serverVersion, '1.1.0')) {
if (serverVersion && gte(serverVersion, '1.1.0')) {
let params = {};

// if server is greather than or equal 3.0.0
if (serverVersion && semver.gte(serverVersion, '3.0.0')) {
if (serverVersion && gte(serverVersion, '3.0.0')) {
// if not have any id
if (!ids.length) {
return;
Expand Down
10 changes: 6 additions & 4 deletions app/lib/rocketchat.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { InteractionManager } from 'react-native';
import semver from 'semver';
import lt from 'semver/functions/lt';
import gte from 'semver/functions/gte';
import coerce from 'semver/functions/coerce';
import {
Rocketchat as RocketchatClient,
settings as RocketChatSettings
Expand Down Expand Up @@ -132,7 +134,7 @@ const RocketChat = {
message: I18n.t('Not_RC_Server', { contact: I18n.t('Contact_your_server_admin') })
};
}
if (semver.lt(jsonRes.version, MIN_ROCKETCHAT_VERSION)) {
if (lt(jsonRes.version, MIN_ROCKETCHAT_VERSION)) {
return {
success: false,
message: I18n.t('Invalid_server_version', {
Expand Down Expand Up @@ -465,7 +467,7 @@ const RocketChat = {

// Force normalized params for 2FA starting RC 3.9.0.
const serverVersion = reduxStore.getState().server.version;
if (serverVersion && semver.gte(semver.coerce(serverVersion), '3.9.0')) {
if (serverVersion && gte(coerce(serverVersion), '3.9.0')) {
const user = params.user ?? params.username;
const password = params.password ?? params.ldapPass ?? params.crowdPassword;
params = { user, password };
Expand Down Expand Up @@ -1372,7 +1374,7 @@ const RocketChat = {
},
readThreads(tmid) {
const serverVersion = reduxStore.getState().server.version;
if (serverVersion && semver.gte(semver.coerce(serverVersion), '3.4.0')) {
if (serverVersion && gte(coerce(serverVersion), '3.4.0')) {
// RC 3.4.0
return this.methodCallWrapper('readThreads', tmid);
}
Expand Down
4 changes: 2 additions & 2 deletions app/presentation/RoomItem/LastMessage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import _ from 'lodash';
import isEqual from 'lodash/isEqual';

import I18n from '../../i18n';
import styles from './styles';
Expand Down Expand Up @@ -45,7 +45,7 @@ const formatMsg = ({
return `${ prefix }${ lastMessage.msg }`;
};

const arePropsEqual = (oldProps, newProps) => _.isEqual(oldProps, newProps);
const arePropsEqual = (oldProps, newProps) => isEqual(oldProps, newProps);

const LastMessage = React.memo(({
lastMessage, type, showLastMessage, username, alert, useRealName, theme
Expand Down
7 changes: 4 additions & 3 deletions app/sagas/selectServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { put, takeLatest } from 'redux-saga/effects';
import { Alert } from 'react-native';
import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord';
import { Q } from '@nozbe/watermelondb';
import semver from 'semver';
import valid from 'semver/functions/valid';
import coerce from 'semver/functions/coerce';

import Navigation from '../lib/Navigation';
import { SERVER } from '../actions/actionsTypes';
Expand Down Expand Up @@ -39,9 +40,9 @@ const getServerInfo = function* getServerInfo({ server, raiseError = true }) {
return;
}

let serverVersion = semver.valid(serverInfo.version);
let serverVersion = valid(serverInfo.version);
if (!serverVersion) {
({ version: serverVersion } = semver.coerce(serverInfo.version));
({ version: serverVersion } = coerce(serverInfo.version));
}

const serversDB = database.servers;
Expand Down
2 changes: 1 addition & 1 deletion app/selectors/login.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createSelector } from 'reselect';
import { isEmpty } from 'lodash';
import isEmpty from 'lodash/isEmpty';

const getUser = (state) => {
if (!isEmpty(state.share?.user)) {
Expand Down
11 changes: 5 additions & 6 deletions app/utils/avatar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import semver from 'semver';
import lt from 'semver/functions/lt';
import coerce from 'semver/functions/coerce';

const formatUrl = (url, size, query) => `${ url }?format=png&size=${ size }${ query }`;

Expand All @@ -8,14 +9,12 @@ export const avatarURL = ({
let room;
if (type === 'd') {
room = text;
} else if (rid && !(serverVersion && semver.lt(semver.coerce(serverVersion), '3.6.0'))) {
} else if (rid && !(serverVersion && lt(coerce(serverVersion), '3.6.0'))) {
room = `room/${ rid }`;
} else {
room = `@${ text }`;
}

const uriSize = size > 100 ? size : 100;

const { id, token } = user;
let query = '';
if (id && token && blockUnauthenticatedAccess) {
Expand All @@ -30,8 +29,8 @@ export const avatarURL = ({
return avatar;
}

return formatUrl(`${ server }${ avatar }`, uriSize, query);
return formatUrl(`${ server }${ avatar }`, size, query);
}

return formatUrl(`${ server }/avatar/${ room }`, uriSize, query);
return formatUrl(`${ server }/avatar/${ room }`, size, query);
};
4 changes: 2 additions & 2 deletions app/views/ChangePasscodeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { StyleSheet } from 'react-native';
import PropTypes from 'prop-types';
import Orientation from 'react-native-orientation-locker';
import useDeepCompareEffect from 'use-deep-compare-effect';
import _ from 'lodash';
import isEmpty from 'lodash/isEmpty';
import Modal from 'react-native-modal';
import Touchable from 'react-native-platform-touchable';

Expand Down Expand Up @@ -32,7 +32,7 @@ const ChangePasscodeView = React.memo(({ theme }) => {
const [data, setData] = useState({});

useDeepCompareEffect(() => {
if (!_.isEmpty(data)) {
if (!isEmpty(data)) {
setVisible(true);
} else {
setVisible(false);
Expand Down
2 changes: 1 addition & 1 deletion app/views/NewMessageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from 'react-native';
import { connect } from 'react-redux';
import equal from 'deep-equal';
import { orderBy } from 'lodash';
import orderBy from 'lodash/orderBy';
import { Q } from '@nozbe/watermelondb';

import Touch from '../utils/touch';
Expand Down
3 changes: 2 additions & 1 deletion app/views/ProfileView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import prompt from 'react-native-prompt-android';
import SHA256 from 'js-sha256';
import ImagePicker from 'react-native-image-crop-picker';
import RNPickerSelect from 'react-native-picker-select';
import { isEqual, omit } from 'lodash';
import isEqual from 'lodash/isEqual';
import omit from 'lodash/omit';

import Touch from '../../utils/touch';
import KeyboardView from '../../presentation/KeyboardView';
Expand Down
9 changes: 5 additions & 4 deletions app/views/RoomActionsView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import {
View, Text, Alert, Share, Switch
} from 'react-native';
import { connect } from 'react-redux';
import _ from 'lodash';
import semver from 'semver';
import isEmpty from 'lodash/isEmpty';
import lt from 'semver/functions/lt';
import coerce from 'semver/functions/coerce';

import Touch from '../../utils/touch';
import { setLoading as setLoadingAction } from '../../actions/selectedUsers';
Expand Down Expand Up @@ -113,7 +114,7 @@ class RoomActionsView extends React.Component {
} catch (e) {
log(e);
}
} else if (room.t === 'd' && _.isEmpty(member)) {
} else if (room.t === 'd' && isEmpty(member)) {
this.updateRoomMember();
}

Expand Down Expand Up @@ -251,7 +252,7 @@ class RoomActionsView extends React.Component {
const { encrypted } = room;
const { serverVersion } = this.props;
let hasPermission = false;
if (serverVersion && semver.lt(semver.coerce(serverVersion), '3.11.0')) {
if (serverVersion && lt(coerce(serverVersion), '3.11.0')) {
hasPermission = canEdit;
} else {
hasPermission = canToggleEncryption;
Expand Down
8 changes: 5 additions & 3 deletions app/views/RoomInfoEditView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import { BLOCK_CONTEXT } from '@rocket.chat/ui-kit';
import ImagePicker from 'react-native-image-crop-picker';
import isEqual from 'lodash/isEqual';
import isEmpty from 'lodash/isEmpty';
import semver from 'semver';
import lt from 'semver/functions/lt';
import coerce from 'semver/functions/coerce';


import database from '../../lib/database';
import { deleteRoom as deleteRoomAction } from '../../actions/room';
Expand Down Expand Up @@ -407,7 +409,7 @@ class RoomInfoEditView extends React.Component {

isServerVersionLowerThan = (version) => {
const { serverVersion } = this.props;
return serverVersion && semver.lt(semver.coerce(serverVersion), version);
return serverVersion && lt(coerce(serverVersion), version);
}

render() {
Expand Down Expand Up @@ -547,7 +549,7 @@ class RoomInfoEditView extends React.Component {
]
: null
}
{serverVersion && !semver.lt(serverVersion, '3.0.0') ? (
{serverVersion && !lt(serverVersion, '3.0.0') ? (
<SwitchContainer
value={enableSysMes}
leftLabelPrimary={I18n.t('Hide_System_Messages')}
Expand Down
6 changes: 3 additions & 3 deletions app/views/RoomInfoView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { View, Text, ScrollView } from 'react-native';
import { BorderlessButton } from 'react-native-gesture-handler';
import { connect } from 'react-redux';
import UAParser from 'ua-parser-js';
import _ from 'lodash';
import isEmpty from 'lodash/isEmpty';

import database from '../../lib/database';
import { CustomIcon } from '../../lib/Icons';
Expand Down Expand Up @@ -169,7 +169,7 @@ class RoomInfoView extends React.Component {
loadUser = async() => {
const { room, roomUser } = this.state;

if (_.isEmpty(roomUser)) {
if (isEmpty(roomUser)) {
try {
const roomUserId = RocketChat.getUidDirectMessage(room);
const result = await RocketChat.getUserInfo(roomUserId);
Expand Down Expand Up @@ -224,7 +224,7 @@ class RoomInfoView extends React.Component {

// We don't need to create a direct
const member = route.params?.member;
if (!_.isEmpty(member)) {
if (!isEmpty(member)) {
return resolve();
}

Expand Down
Loading