Chore: Evaluate helpers and methods - Typescript (#4030)

* move userPreferences to methods folder

* create formatAttachmentUrl file

* create compareServerVersion file

* create generateLoadMoreId file
This commit is contained in:
Gleidson Daniel Silva 2022-04-07 10:13:19 -03:00 committed by GitHub
parent 9a11fb2797
commit 7d2ae5ea7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
48 changed files with 68 additions and 71 deletions

View File

@ -10,7 +10,7 @@ import { TYPE } from './constants';
import { ATTEMPTS_KEY, LOCKED_OUT_TIMER_KEY, MAX_ATTEMPTS, PASSCODE_KEY } from '../../constants/localAuthentication'; import { ATTEMPTS_KEY, LOCKED_OUT_TIMER_KEY, MAX_ATTEMPTS, PASSCODE_KEY } from '../../constants/localAuthentication';
import { biometryAuth, resetAttempts } from '../../utils/localAuthentication'; import { biometryAuth, resetAttempts } from '../../utils/localAuthentication';
import { getDiff, getLockedUntil } from './utils'; import { getDiff, getLockedUntil } from './utils';
import { useUserPreferences } from '../../lib/userPreferences'; import { useUserPreferences } from '../../lib/methods/userPreferences';
import I18n from '../../i18n'; import I18n from '../../i18n';
interface IPasscodePasscodeEnter { interface IPasscodePasscodeEnter {

View File

@ -8,12 +8,12 @@ import * as Progress from 'react-native-progress';
import Touchable from './Touchable'; import Touchable from './Touchable';
import Markdown from '../markdown'; import Markdown from '../markdown';
import styles from './styles'; import styles from './styles';
import { formatAttachmentUrl } from '../../lib/utils';
import { themes } from '../../constants/colors'; import { themes } from '../../constants/colors';
import MessageContext from './Context'; import MessageContext from './Context';
import { TGetCustomEmoji } from '../../definitions/IEmoji'; import { TGetCustomEmoji } from '../../definitions/IEmoji';
import { IAttachment } from '../../definitions'; import { IAttachment } from '../../definitions';
import { useTheme } from '../../theme'; import { useTheme } from '../../theme';
import { formatAttachmentUrl } from '../../lib/methods/helpers/formatAttachmentUrl';
interface IMessageButton { interface IMessageButton {
children: React.ReactElement; children: React.ReactElement;

View File

@ -11,12 +11,12 @@ import sharedStyles from '../../views/Styles';
import { themes } from '../../constants/colors'; import { themes } from '../../constants/colors';
import MessageContext from './Context'; import MessageContext from './Context';
import { fileDownloadAndPreview } from '../../utils/fileDownload'; import { fileDownloadAndPreview } from '../../utils/fileDownload';
import { formatAttachmentUrl } from '../../lib/utils';
import { IAttachment } from '../../definitions/IAttachment'; import { IAttachment } from '../../definitions/IAttachment';
import { TGetCustomEmoji } from '../../definitions/IEmoji'; import { TGetCustomEmoji } from '../../definitions/IEmoji';
import RCActivityIndicator from '../ActivityIndicator'; import RCActivityIndicator from '../ActivityIndicator';
import Attachments from './Attachments'; import Attachments from './Attachments';
import { useTheme } from '../../theme'; import { useTheme } from '../../theme';
import { formatAttachmentUrl } from '../../lib/methods/helpers/formatAttachmentUrl';
const styles = StyleSheet.create({ const styles = StyleSheet.create({
button: { button: {

View File

@ -6,7 +6,6 @@ import Touchable from './Touchable';
import Markdown from '../markdown'; import Markdown from '../markdown';
import { isIOS } from '../../utils/deviceInfo'; import { isIOS } from '../../utils/deviceInfo';
import { CustomIcon } from '../../lib/Icons'; import { CustomIcon } from '../../lib/Icons';
import { formatAttachmentUrl } from '../../lib/utils';
import { themes } from '../../constants/colors'; import { themes } from '../../constants/colors';
import MessageContext from './Context'; import MessageContext from './Context';
import { fileDownload } from '../../utils/fileDownload'; import { fileDownload } from '../../utils/fileDownload';
@ -17,6 +16,7 @@ import { IAttachment } from '../../definitions/IAttachment';
import RCActivityIndicator from '../ActivityIndicator'; import RCActivityIndicator from '../ActivityIndicator';
import { TGetCustomEmoji } from '../../definitions/IEmoji'; import { TGetCustomEmoji } from '../../definitions/IEmoji';
import { useTheme } from '../../theme'; import { useTheme } from '../../theme';
import { formatAttachmentUrl } from '../../lib/methods/helpers/formatAttachmentUrl';
const SUPPORTED_TYPES = ['video/quicktime', 'video/mp4', ...(isIOS ? [] : ['video/3gp', 'video/mkv'])]; const SUPPORTED_TYPES = ['video/quicktime', 'video/mp4', ...(isIOS ? [] : ['video/3gp', 'video/mkv'])];
const isTypeSupported = (type: string) => SUPPORTED_TYPES.indexOf(type) !== -1; const isTypeSupported = (type: string) => SUPPORTED_TYPES.indexOf(type) !== -1;

View File

@ -4,7 +4,7 @@ import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord';
import { Q, Model } from '@nozbe/watermelondb'; import { Q, Model } from '@nozbe/watermelondb';
import RocketChat from '../rocketchat'; import RocketChat from '../rocketchat';
import UserPreferences from '../userPreferences'; import UserPreferences from '../methods/userPreferences';
import database from '../database'; import database from '../database';
import protectedFunction from '../methods/helpers/protectedFunction'; import protectedFunction from '../methods/helpers/protectedFunction';
import Deferred from '../../utils/deferred'; import Deferred from '../../utils/deferred';

View File

@ -0,0 +1,15 @@
import { coerce, gt, gte, lt, lte, SemVer } from 'semver';
const methods = {
lowerThan: lt,
lowerThanOrEqualTo: lte,
greaterThan: gt,
greaterThanOrEqualTo: gte
};
export const compareServerVersion = (
currentServerVersion: string | null | undefined,
method: keyof typeof methods,
versionToCompare: string
): boolean =>
(currentServerVersion && methods[method](coerce(currentServerVersion) as string | SemVer, versionToCompare)) as boolean;

View File

@ -0,0 +1,9 @@
export const formatAttachmentUrl = (attachmentUrl: string | undefined, userId: string, token: string, server: string): string => {
if (attachmentUrl && attachmentUrl.startsWith('http')) {
if (attachmentUrl.includes('rc_token')) {
return encodeURI(attachmentUrl);
}
return encodeURI(`${attachmentUrl}?rc_uid=${userId}&rc_token=${token}`);
}
return encodeURI(`${server}${attachmentUrl}?rc_uid=${userId}&rc_token=${token}`);
};

View File

@ -0,0 +1 @@
export const generateLoadMoreId = (id: string): string => `load-more-${id}`;

View File

@ -2,10 +2,10 @@ import EJSON from 'ejson';
import { Encryption } from '../../encryption'; import { Encryption } from '../../encryption';
import { store as reduxStore } from '../../auxStore'; import { store as reduxStore } from '../../auxStore';
import { compareServerVersion } from '../../utils';
import findSubscriptionsRooms from './findSubscriptionsRooms'; import findSubscriptionsRooms from './findSubscriptionsRooms';
import normalizeMessage from './normalizeMessage'; import normalizeMessage from './normalizeMessage';
import { ISubscription, IServerSubscription, IServerRoom, IRoom } from '../../../definitions'; import { ISubscription, IServerSubscription, IServerRoom, IRoom } from '../../../definitions';
import { compareServerVersion } from './compareServerVersion';
export const merge = (subscription: ISubscription | IServerSubscription, room?: IRoom | IServerRoom): ISubscription => { export const merge = (subscription: ISubscription | IServerSubscription, room?: IRoom | IServerRoom): ISubscription => {
const serverVersion = reduxStore.getState().server.version as string; const serverVersion = reduxStore.getState().server.version as string;

View File

@ -6,8 +6,8 @@ import log from '../../utils/log';
import { getMessageById } from '../database/services/Message'; import { getMessageById } from '../database/services/Message';
import roomTypeToApiType, { RoomTypes } from './roomTypeToApiType'; import roomTypeToApiType, { RoomTypes } from './roomTypeToApiType';
import sdk from '../rocketchat/services/sdk'; import sdk from '../rocketchat/services/sdk';
import { generateLoadMoreId } from '../utils';
import updateMessages from './updateMessages'; import updateMessages from './updateMessages';
import { generateLoadMoreId } from './helpers/generateLoadMoreId';
const COUNT = 50; const COUNT = 50;

View File

@ -5,10 +5,10 @@ import orderBy from 'lodash/orderBy';
import log from '../../utils/log'; import log from '../../utils/log';
import { getMessageById } from '../database/services/Message'; import { getMessageById } from '../database/services/Message';
import { MessageTypeLoad } from '../../constants/messageTypeLoad'; import { MessageTypeLoad } from '../../constants/messageTypeLoad';
import { generateLoadMoreId } from '../utils';
import updateMessages from './updateMessages'; import updateMessages from './updateMessages';
import { TMessageModel } from '../../definitions'; import { TMessageModel } from '../../definitions';
import sdk from '../rocketchat/services/sdk'; import sdk from '../rocketchat/services/sdk';
import { generateLoadMoreId } from './helpers/generateLoadMoreId';
const COUNT = 50; const COUNT = 50;

View File

@ -7,8 +7,8 @@ import { getMessageById } from '../database/services/Message';
import { MessageTypeLoad } from '../../constants/messageTypeLoad'; import { MessageTypeLoad } from '../../constants/messageTypeLoad';
import sdk from '../rocketchat/services/sdk'; import sdk from '../rocketchat/services/sdk';
import { IMessage } from '../../definitions'; import { IMessage } from '../../definitions';
import { generateLoadMoreId } from '../utils';
import updateMessages from './updateMessages'; import updateMessages from './updateMessages';
import { generateLoadMoreId } from './helpers/generateLoadMoreId';
const COUNT = 50; const COUNT = 50;

View File

@ -6,8 +6,8 @@ import { IMessage, TMessageModel, TSubscriptionModel, TThreadMessageModel, TThre
import database from '../database'; import database from '../database';
import { getSubscriptionByRoomId } from '../database/services/Subscription'; import { getSubscriptionByRoomId } from '../database/services/Subscription';
import { Encryption } from '../encryption'; import { Encryption } from '../encryption';
import { generateLoadMoreId } from '../utils';
import buildMessage from './helpers/buildMessage'; import buildMessage from './helpers/buildMessage';
import { generateLoadMoreId } from './helpers/generateLoadMoreId';
import protectedFunction from './helpers/protectedFunction'; import protectedFunction from './helpers/protectedFunction';
interface IUpdateMessages { interface IUpdateMessages {

View File

@ -1,9 +1,9 @@
import sdk from '../services/sdk'; import sdk from '../services/sdk';
import { compareServerVersion } from '../../utils';
import { store as reduxStore } from '../../auxStore'; import { store as reduxStore } from '../../auxStore';
import database from '../../database'; import database from '../../database';
import log from '../../../utils/log'; import log from '../../../utils/log';
import { clearEnterpriseModules, setEnterpriseModules as setEnterpriseModulesAction } from '../../../actions/enterpriseModules'; import { clearEnterpriseModules, setEnterpriseModules as setEnterpriseModulesAction } from '../../../actions/enterpriseModules';
import { compareServerVersion } from '../../methods/helpers/compareServerVersion';
const LICENSE_OMNICHANNEL_MOBILE_ENTERPRISE = 'omnichannel-mobile-enterprise'; const LICENSE_OMNICHANNEL_MOBILE_ENTERPRISE = 'omnichannel-mobile-enterprise';
const LICENSE_LIVECHAT_ENTERPRISE = 'livechat-enterprise'; const LICENSE_LIVECHAT_ENTERPRISE = 'livechat-enterprise';

View File

@ -2,13 +2,13 @@ import orderBy from 'lodash/orderBy';
import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord'; import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord';
import { ICustomEmojis } from '../../../reducers/customEmojis'; import { ICustomEmojis } from '../../../reducers/customEmojis';
import { compareServerVersion } from '../../utils';
import { store as reduxStore } from '../../auxStore'; import { store as reduxStore } from '../../auxStore';
import database from '../../database'; import database from '../../database';
import log from '../../../utils/log'; import log from '../../../utils/log';
import { setCustomEmojis as setCustomEmojisAction } from '../../../actions/customEmojis'; import { setCustomEmojis as setCustomEmojisAction } from '../../../actions/customEmojis';
import { ICustomEmoji, TCustomEmojiModel } from '../../../definitions'; import { ICustomEmoji, TCustomEmojiModel } from '../../../definitions';
import sdk from '../services/sdk'; import sdk from '../services/sdk';
import { compareServerVersion } from '../../methods/helpers/compareServerVersion';
interface IUpdateEmojis { interface IUpdateEmojis {
update: TCustomEmojiModel[]; update: TCustomEmojiModel[];

View File

@ -8,8 +8,8 @@ import log from '../../../utils/log';
import { store as reduxStore } from '../../auxStore'; import { store as reduxStore } from '../../auxStore';
import database from '../../database'; import database from '../../database';
import sdk from '../services/sdk'; import sdk from '../services/sdk';
import { compareServerVersion } from '../../utils';
import protectedFunction from '../../methods/helpers/protectedFunction'; import protectedFunction from '../../methods/helpers/protectedFunction';
import { compareServerVersion } from '../../methods/helpers/compareServerVersion';
export const SUPPORTED_PERMISSIONS = [ export const SUPPORTED_PERMISSIONS = [
'add-user-to-any-c-room', 'add-user-to-any-c-room',

View File

@ -2,13 +2,13 @@ import { InteractionManager } from 'react-native';
import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord'; import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord';
import { IActiveUsers } from '../../../reducers/activeUsers'; import { IActiveUsers } from '../../../reducers/activeUsers';
import { compareServerVersion } from '../../utils';
import { store as reduxStore } from '../../auxStore'; import { store as reduxStore } from '../../auxStore';
import { setActiveUsers } from '../../../actions/activeUsers'; import { setActiveUsers } from '../../../actions/activeUsers';
import { setUser } from '../../../actions/login'; import { setUser } from '../../../actions/login';
import database from '../../database'; import database from '../../database';
import { IRocketChat, IUser } from '../../../definitions'; import { IRocketChat, IUser } from '../../../definitions';
import sdk from '../services/sdk'; import sdk from '../services/sdk';
import { compareServerVersion } from '../../methods/helpers/compareServerVersion';
export function subscribeUsersPresence(this: IRocketChat) { export function subscribeUsersPresence(this: IRocketChat) {
const serverVersion = reduxStore.getState().server.version as string; const serverVersion = reduxStore.getState().server.version as string;

View File

@ -10,7 +10,7 @@ import RocketChat from '..';
import { useSsl } from '../../../utils/url'; import { useSsl } from '../../../utils/url';
import log from '../../../utils/log'; import log from '../../../utils/log';
import { E2E_PRIVATE_KEY, E2E_PUBLIC_KEY, E2E_RANDOM_PASSWORD_KEY } from '../../constants'; import { E2E_PRIVATE_KEY, E2E_PUBLIC_KEY, E2E_RANDOM_PASSWORD_KEY } from '../../constants';
import UserPreferences from '../../userPreferences'; import UserPreferences from '../../methods/userPreferences';
import { ICertificate, IRocketChat } from '../../../definitions'; import { ICertificate, IRocketChat } from '../../../definitions';
import sdk from '../services/sdk'; import sdk from '../services/sdk';

View File

@ -3,7 +3,7 @@ import { InteractionManager } from 'react-native';
import { setActiveUsers } from '../../../actions/activeUsers'; import { setActiveUsers } from '../../../actions/activeUsers';
import { setUser } from '../../../actions/login'; import { setUser } from '../../../actions/login';
import { store as reduxStore } from '../../auxStore'; import { store as reduxStore } from '../../auxStore';
import { compareServerVersion } from '../../utils'; import { compareServerVersion } from '../../methods/helpers/compareServerVersion';
// TODO // TODO
export function _setUser(this: any, ddpMessage: { fields: any; id: any; cleared: any }) { export function _setUser(this: any, ddpMessage: { fields: any; id: any; cleared: any }) {

View File

@ -1,5 +1,5 @@
import { IPreferences } from '../../../definitions'; import { IPreferences } from '../../../definitions';
import userPreferences from '../../userPreferences'; import userPreferences from '../../methods/userPreferences';
const SORT_PREFS_KEY = 'RC_SORT_PREFS_KEY'; const SORT_PREFS_KEY = 'RC_SORT_PREFS_KEY';

View File

@ -11,7 +11,6 @@ import protectedFunction from '../../methods/helpers/protectedFunction';
import database from '../../database'; import database from '../../database';
import { selectServerFailure } from '../../../actions/server'; import { selectServerFailure } from '../../../actions/server';
import { twoFactor } from '../../../utils/twoFactor'; import { twoFactor } from '../../../utils/twoFactor';
import { compareServerVersion } from '../../utils';
import { store } from '../../auxStore'; import { store } from '../../auxStore';
import { loginRequest, setLoginServices, setUser } from '../../../actions/login'; import { loginRequest, setLoginServices, setUser } from '../../../actions/login';
import sdk from './sdk'; import sdk from './sdk';
@ -25,6 +24,7 @@ import EventEmitter from '../../../utils/events';
import { updateSettings } from '../../../actions/settings'; import { updateSettings } from '../../../actions/settings';
import defaultSettings from '../../../constants/settings'; import defaultSettings from '../../../constants/settings';
import { MIN_ROCKETCHAT_VERSION } from '../../constants'; import { MIN_ROCKETCHAT_VERSION } from '../../constants';
import { compareServerVersion } from '../../methods/helpers/compareServerVersion';
interface IServices { interface IServices {
[index: string]: string | boolean; [index: string]: string | boolean;

View File

@ -16,9 +16,9 @@ import { TParams } from '../../../definitions/ILivechatEditView';
import { store as reduxStore } from '../../auxStore'; import { store as reduxStore } from '../../auxStore';
import { getDeviceToken } from '../../../notifications/push'; import { getDeviceToken } from '../../../notifications/push';
import { getBundleId, isIOS } from '../../../utils/deviceInfo'; import { getBundleId, isIOS } from '../../../utils/deviceInfo';
import { compareServerVersion } from '../../utils';
import roomTypeToApiType, { RoomTypes } from '../../methods/roomTypeToApiType'; import roomTypeToApiType, { RoomTypes } from '../../methods/roomTypeToApiType';
import sdk from './sdk'; import sdk from './sdk';
import { compareServerVersion } from '../../methods/helpers/compareServerVersion';
export const createChannel = ({ export const createChannel = ({
name, name,

View File

@ -4,7 +4,7 @@ import { shareSetSettings, shareSelectServer, shareSetUser } from '../../../acti
import SSLPinning from '../../../utils/sslPinning'; import SSLPinning from '../../../utils/sslPinning';
import log from '../../../utils/log'; import log from '../../../utils/log';
import { IShareServer, IShareUser } from '../../../reducers/share'; import { IShareServer, IShareUser } from '../../../reducers/share';
import UserPreferences from '../../userPreferences'; import UserPreferences from '../../methods/userPreferences';
import database from '../../database'; import database from '../../database';
import RocketChat from '..'; import RocketChat from '..';
import { encryptionInit } from '../../../actions/encryption'; import { encryptionInit } from '../../../actions/encryption';

View File

@ -1,27 +0,0 @@
import { coerce, gt, gte, lt, lte, SemVer } from 'semver';
export const formatAttachmentUrl = (attachmentUrl: string | undefined, userId: string, token: string, server: string): string => {
if (attachmentUrl && attachmentUrl.startsWith('http')) {
if (attachmentUrl.includes('rc_token')) {
return encodeURI(attachmentUrl);
}
return encodeURI(`${attachmentUrl}?rc_uid=${userId}&rc_token=${token}`);
}
return encodeURI(`${server}${attachmentUrl}?rc_uid=${userId}&rc_token=${token}`);
};
const methods = {
lowerThan: lt,
lowerThanOrEqualTo: lte,
greaterThan: gt,
greaterThanOrEqualTo: gte
};
export const compareServerVersion = (
currentServerVersion: string | null | undefined,
method: keyof typeof methods,
versionToCompare: string
): boolean =>
(currentServerVersion && methods[method](coerce(currentServerVersion) as string | SemVer, versionToCompare)) as boolean;
export const generateLoadMoreId = (id: string): string => `load-more-${id}`;

View File

@ -1,6 +1,6 @@
import { all, delay, put, select, take, takeLatest } from 'redux-saga/effects'; import { all, delay, put, select, take, takeLatest } from 'redux-saga/effects';
import UserPreferences from '../lib/userPreferences'; import UserPreferences from '../lib/methods/userPreferences';
import Navigation from '../lib/Navigation'; import Navigation from '../lib/Navigation';
import * as types from '../actions/actionsTypes'; import * as types from '../actions/actionsTypes';
import { selectServerRequest, serverInitAdd } from '../actions/server'; import { selectServerRequest, serverInitAdd } from '../actions/server';

View File

@ -8,7 +8,7 @@ import Navigation from '../lib/Navigation';
import { E2E_BANNER_TYPE, E2E_PRIVATE_KEY, E2E_PUBLIC_KEY, E2E_RANDOM_PASSWORD_KEY } from '../lib/constants'; import { E2E_BANNER_TYPE, E2E_PRIVATE_KEY, E2E_PUBLIC_KEY, E2E_RANDOM_PASSWORD_KEY } from '../lib/constants';
import database from '../lib/database'; import database from '../lib/database';
import RocketChat from '../lib/rocketchat'; import RocketChat from '../lib/rocketchat';
import UserPreferences from '../lib/userPreferences'; import UserPreferences from '../lib/methods/userPreferences';
import { getUserSelector } from '../selectors/login'; import { getUserSelector } from '../selectors/login';
import { showErrorAlert } from '../utils/info'; import { showErrorAlert } from '../utils/info';
import I18n from '../i18n'; import I18n from '../i18n';

View File

@ -2,7 +2,7 @@ import { put, takeLatest } from 'redux-saga/effects';
import RNBootSplash from 'react-native-bootsplash'; import RNBootSplash from 'react-native-bootsplash';
import { BIOMETRY_ENABLED_KEY } from '../constants/localAuthentication'; import { BIOMETRY_ENABLED_KEY } from '../constants/localAuthentication';
import UserPreferences from '../lib/userPreferences'; import UserPreferences from '../lib/methods/userPreferences';
import { selectServerRequest } from '../actions/server'; import { selectServerRequest } from '../actions/server';
import { setAllPreferences } from '../actions/sortPreferences'; import { setAllPreferences } from '../actions/sortPreferences';
import { APP } from '../actions/actionsTypes'; import { APP } from '../actions/actionsTypes';

View File

@ -16,7 +16,7 @@ import { inviteLinksRequest } from '../actions/inviteLinks';
import { showErrorAlert } from '../utils/info'; import { showErrorAlert } from '../utils/info';
import { localAuthenticate } from '../utils/localAuthentication'; import { localAuthenticate } from '../utils/localAuthentication';
import { encryptionInit, encryptionStop } from '../actions/encryption'; import { encryptionInit, encryptionStop } from '../actions/encryption';
import UserPreferences from '../lib/userPreferences'; import UserPreferences from '../lib/methods/userPreferences';
import { inquiryRequest, inquiryReset } from '../ee/omnichannel/actions/inquiry'; import { inquiryRequest, inquiryReset } from '../ee/omnichannel/actions/inquiry';
import { isOmnichannelStatusAvailable } from '../ee/omnichannel/lib'; import { isOmnichannelStatusAvailable } from '../ee/omnichannel/lib';
import { RootEnum } from '../definitions'; import { RootEnum } from '../definitions';

View File

@ -17,7 +17,7 @@ import log, { logServerVersion } from '../utils/log';
import I18n from '../i18n'; import I18n from '../i18n';
import { BASIC_AUTH_KEY, setBasicAuth } from '../utils/fetch'; import { BASIC_AUTH_KEY, setBasicAuth } from '../utils/fetch';
import { appStart } from '../actions/app'; import { appStart } from '../actions/app';
import UserPreferences from '../lib/userPreferences'; import UserPreferences from '../lib/methods/userPreferences';
import { encryptionStop } from '../actions/encryption'; import { encryptionStop } from '../actions/encryption';
import SSLPinning from '../utils/sslPinning'; import SSLPinning from '../utils/sslPinning';
import { inquiryReset } from '../ee/omnichannel/actions/inquiry'; import { inquiryReset } from '../ee/omnichannel/actions/inquiry';

View File

@ -6,7 +6,7 @@ import { createStackNavigator } from '@react-navigation/stack';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';
import { getTheme, initialTheme, newThemeState, subscribeTheme, unsubscribeTheme } from './utils/theme'; import { getTheme, initialTheme, newThemeState, subscribeTheme, unsubscribeTheme } from './utils/theme';
import UserPreferences from './lib/userPreferences'; import UserPreferences from './lib/methods/userPreferences';
import Navigation from './lib/ShareNavigation'; import Navigation from './lib/ShareNavigation';
import store from './lib/createStore'; import store from './lib/createStore';
import { initStore } from './lib/auxStore'; import { initStore } from './lib/auxStore';

View File

@ -1,6 +1,6 @@
import { compareServerVersion } from '../lib/utils';
import { SubscriptionType } from '../definitions/ISubscription'; import { SubscriptionType } from '../definitions/ISubscription';
import { IAvatar } from '../containers/Avatar/interfaces'; import { IAvatar } from '../containers/Avatar/interfaces';
import { compareServerVersion } from '../lib/methods/helpers/compareServerVersion';
const formatUrl = (url: string, size: number, query: string) => `${url}?format=png&size=${size}${query}`; const formatUrl = (url: string, size: number, query: string) => `${url}?format=png&size=${size}${query}`;

View File

@ -4,7 +4,7 @@ import AsyncStorage from '@react-native-community/async-storage';
import { sha256 } from 'js-sha256'; import { sha256 } from 'js-sha256';
import moment from 'moment'; import moment from 'moment';
import UserPreferences from '../lib/userPreferences'; import UserPreferences from '../lib/methods/userPreferences';
import { store } from '../lib/auxStore'; import { store } from '../lib/auxStore';
import database from '../lib/database'; import database from '../lib/database';
import { getServerTimeSync } from '../lib/rocketchat/services/getServerTimeSync'; import { getServerTimeSync } from '../lib/rocketchat/services/getServerTimeSync';

View File

@ -2,7 +2,7 @@ import { Linking } from 'react-native';
import * as WebBrowser from 'expo-web-browser'; import * as WebBrowser from 'expo-web-browser';
import parse from 'url-parse'; import parse from 'url-parse';
import UserPreferences from '../lib/userPreferences'; import UserPreferences from '../lib/methods/userPreferences';
import { themes } from '../constants/colors'; import { themes } from '../constants/colors';
export const DEFAULT_BROWSER_KEY = 'DEFAULT_BROWSER_KEY'; export const DEFAULT_BROWSER_KEY = 'DEFAULT_BROWSER_KEY';

View File

@ -2,7 +2,7 @@ import { Alert, NativeModules, Platform } from 'react-native';
import DocumentPicker from 'react-native-document-picker'; import DocumentPicker from 'react-native-document-picker';
import * as FileSystem from 'expo-file-system'; import * as FileSystem from 'expo-file-system';
import UserPreferences from '../lib/userPreferences'; import UserPreferences from '../lib/methods/userPreferences';
import I18n from '../i18n'; import I18n from '../i18n';
import { extractHostname } from './server'; import { extractHostname } from './server';
import { ICertificate } from '../definitions'; import { ICertificate } from '../definitions';

View File

@ -5,11 +5,10 @@ import setRootViewColor from 'rn-root-view';
import { IThemePreference, TThemeMode } from '../definitions/ITheme'; import { IThemePreference, TThemeMode } from '../definitions/ITheme';
import { themes } from '../constants/colors'; import { themes } from '../constants/colors';
import { isAndroid } from './deviceInfo'; import { isAndroid } from './deviceInfo';
import UserPreferences from '../lib/userPreferences'; import UserPreferences from '../lib/methods/userPreferences';
import { THEME_PREFERENCES_KEY } from '../lib/constants'; import { THEME_PREFERENCES_KEY } from '../lib/constants';
import { TSupportedThemes } from '../theme'; import { TSupportedThemes } from '../theme';
let themeListener: { remove: () => void } | null; let themeListener: { remove: () => void } | null;
export const initialTheme = (): IThemePreference => { export const initialTheme = (): IThemePreference => {

View File

@ -16,7 +16,6 @@ import I18n from '../i18n';
import { withTheme } from '../theme'; import { withTheme } from '../theme';
import { ImageViewer } from '../presentation/ImageViewer'; import { ImageViewer } from '../presentation/ImageViewer';
import { themes } from '../constants/colors'; import { themes } from '../constants/colors';
import { formatAttachmentUrl } from '../lib/utils';
import RCActivityIndicator from '../containers/ActivityIndicator'; import RCActivityIndicator from '../containers/ActivityIndicator';
import * as HeaderButton from '../containers/HeaderButton'; import * as HeaderButton from '../containers/HeaderButton';
import { isAndroid } from '../utils/deviceInfo'; import { isAndroid } from '../utils/deviceInfo';
@ -26,6 +25,7 @@ import { getHeaderHeight } from '../containers/Header';
import StatusBar from '../containers/StatusBar'; import StatusBar from '../containers/StatusBar';
import { InsideStackParamList } from '../stacks/types'; import { InsideStackParamList } from '../stacks/types';
import { IAttachment } from '../definitions/IAttachment'; import { IAttachment } from '../definitions/IAttachment';
import { formatAttachmentUrl } from '../lib/methods/helpers/formatAttachmentUrl';
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {

View File

@ -10,7 +10,7 @@ import * as List from '../containers/List';
import { DEFAULT_BROWSER_KEY } from '../utils/openLink'; import { DEFAULT_BROWSER_KEY } from '../utils/openLink';
import { isIOS } from '../utils/deviceInfo'; import { isIOS } from '../utils/deviceInfo';
import SafeAreaView from '../containers/SafeAreaView'; import SafeAreaView from '../containers/SafeAreaView';
import UserPreferences from '../lib/userPreferences'; import UserPreferences from '../lib/methods/userPreferences';
import { events, logEvent } from '../utils/log'; import { events, logEvent } from '../utils/log';
type TValue = 'inApp' | 'systemDefault:' | 'googlechrome:' | 'firefox:' | 'brave:'; type TValue = 'inApp' | 'systemDefault:' | 'googlechrome:' | 'firefox:' | 'brave:';

View File

@ -13,7 +13,7 @@ import { LISTENER } from '../containers/Toast';
import { IApplicationState, IBaseScreen } from '../definitions'; import { IApplicationState, IBaseScreen } from '../definitions';
import I18n from '../i18n'; import I18n from '../i18n';
import { E2E_RANDOM_PASSWORD_KEY } from '../lib/constants'; import { E2E_RANDOM_PASSWORD_KEY } from '../lib/constants';
import UserPreferences from '../lib/userPreferences'; import UserPreferences from '../lib/methods/userPreferences';
import { E2ESaveYourPasswordStackParamList } from '../stacks/types'; import { E2ESaveYourPasswordStackParamList } from '../stacks/types';
import { withTheme } from '../theme'; import { withTheme } from '../theme';
import EventEmitter from '../utils/events'; import EventEmitter from '../utils/events';

View File

@ -16,9 +16,9 @@ import { IApplicationState, IBaseScreen, ISearch, TSubscriptionModel } from '../
import I18n from '../i18n'; import I18n from '../i18n';
import database from '../lib/database'; import database from '../lib/database';
import { CustomIcon } from '../lib/Icons'; import { CustomIcon } from '../lib/Icons';
import { compareServerVersion } from '../lib/methods/helpers/compareServerVersion';
import Navigation from '../lib/Navigation'; import Navigation from '../lib/Navigation';
import RocketChat from '../lib/rocketchat'; import RocketChat from '../lib/rocketchat';
import { compareServerVersion } from '../lib/utils';
import UserItem from '../presentation/UserItem'; import UserItem from '../presentation/UserItem';
import { withTheme } from '../theme'; import { withTheme } from '../theme';
import { goRoom } from '../utils/goRoom'; import { goRoom } from '../utils/goRoom';

View File

@ -20,7 +20,7 @@ import I18n from '../../i18n';
import database from '../../lib/database'; import database from '../../lib/database';
import { sanitizeLikeString } from '../../lib/database/utils'; import { sanitizeLikeString } from '../../lib/database/utils';
import RocketChat from '../../lib/rocketchat'; import RocketChat from '../../lib/rocketchat';
import UserPreferences from '../../lib/userPreferences'; import UserPreferences from '../../lib/methods/userPreferences';
import { OutsideParamList } from '../../stacks/types'; import { OutsideParamList } from '../../stacks/types';
import { withTheme } from '../../theme'; import { withTheme } from '../../theme';
import { isTablet } from '../../utils/deviceInfo'; import { isTablet } from '../../utils/deviceInfo';

View File

@ -24,7 +24,6 @@ import database from '../../lib/database';
import { E2E_ROOM_TYPES } from '../../lib/constants'; import { E2E_ROOM_TYPES } from '../../lib/constants';
import protectedFunction from '../../lib/methods/helpers/protectedFunction'; import protectedFunction from '../../lib/methods/helpers/protectedFunction';
import RocketChat from '../../lib/rocketchat'; import RocketChat from '../../lib/rocketchat';
import { compareServerVersion } from '../../lib/utils';
import { getUserSelector } from '../../selectors/login'; import { getUserSelector } from '../../selectors/login';
import { ChatsStackParamList } from '../../stacks/types'; import { ChatsStackParamList } from '../../stacks/types';
import { withTheme } from '../../theme'; import { withTheme } from '../../theme';
@ -34,6 +33,7 @@ import Touch from '../../utils/touch';
import sharedStyles from '../Styles'; import sharedStyles from '../Styles';
import styles from './styles'; import styles from './styles';
import { ERoomType } from '../../definitions/ERoomType'; import { ERoomType } from '../../definitions/ERoomType';
import { compareServerVersion } from '../../lib/methods/helpers/compareServerVersion';
interface IRoomActionsViewProps extends IBaseScreen<ChatsStackParamList, 'RoomActionsView'> { interface IRoomActionsViewProps extends IBaseScreen<ChatsStackParamList, 'RoomActionsView'> {
userId: string; userId: string;

View File

@ -22,7 +22,6 @@ import I18n from '../../i18n';
import database from '../../lib/database'; import database from '../../lib/database';
import { CustomIcon } from '../../lib/Icons'; import { CustomIcon } from '../../lib/Icons';
import RocketChat from '../../lib/rocketchat'; import RocketChat from '../../lib/rocketchat';
import { compareServerVersion } from '../../lib/utils';
import KeyboardView from '../../presentation/KeyboardView'; import KeyboardView from '../../presentation/KeyboardView';
import { TSupportedPermissions } from '../../reducers/permissions'; import { TSupportedPermissions } from '../../reducers/permissions';
import { ModalStackParamList } from '../../stacks/MasterDetailStack/types'; import { ModalStackParamList } from '../../stacks/MasterDetailStack/types';
@ -38,6 +37,7 @@ import { IAvatar } from '../../definitions/IProfileViewInterfaces';
import sharedStyles from '../Styles'; import sharedStyles from '../Styles';
import styles from './styles'; import styles from './styles';
import SwitchContainer from './SwitchContainer'; import SwitchContainer from './SwitchContainer';
import { compareServerVersion } from '../../lib/methods/helpers/compareServerVersion';
interface IRoomInfoEditViewState { interface IRoomInfoEditViewState {
room: ISubscription; room: ISubscription;

View File

@ -10,8 +10,8 @@ import { themes } from '../../../constants/colors';
import ActivityIndicator from '../../../containers/ActivityIndicator'; import ActivityIndicator from '../../../containers/ActivityIndicator';
import { TAnyMessageModel, TMessageModel, TThreadMessageModel, TThreadModel } from '../../../definitions'; import { TAnyMessageModel, TMessageModel, TThreadMessageModel, TThreadModel } from '../../../definitions';
import database from '../../../lib/database'; import database from '../../../lib/database';
import { compareServerVersion } from '../../../lib/methods/helpers/compareServerVersion';
import RocketChat from '../../../lib/rocketchat'; import RocketChat from '../../../lib/rocketchat';
import { compareServerVersion } from '../../../lib/utils';
import debounce from '../../../utils/debounce'; import debounce from '../../../utils/debounce';
import { animateNextTransition } from '../../../utils/layoutAnimation'; import { animateNextTransition } from '../../../utils/layoutAnimation';
import log from '../../../utils/log'; import log from '../../../utils/log';

View File

@ -23,7 +23,7 @@ import { showConfirmationAlert } from '../../utils/info';
import log, { events, logEvent } from '../../utils/log'; import log, { events, logEvent } from '../../utils/log';
import { headerHeight } from '../../containers/Header'; import { headerHeight } from '../../containers/Header';
import { goRoom } from '../../utils/goRoom'; import { goRoom } from '../../utils/goRoom';
import UserPreferences from '../../lib/userPreferences'; import UserPreferences from '../../lib/methods/userPreferences';
import { IApplicationState, IBaseScreen, RootEnum, TServerModel } from '../../definitions'; import { IApplicationState, IBaseScreen, RootEnum, TServerModel } from '../../definitions';
import styles from './styles'; import styles from './styles';
import { ChatsStackParamList } from '../../stacks/types'; import { ChatsStackParamList } from '../../stacks/types';

View File

@ -15,7 +15,7 @@ import { BIOMETRY_ENABLED_KEY, DEFAULT_AUTO_LOCK } from '../constants/localAuthe
import SafeAreaView from '../containers/SafeAreaView'; import SafeAreaView from '../containers/SafeAreaView';
import { events, logEvent } from '../utils/log'; import { events, logEvent } from '../utils/log';
import { TServerModel } from '../definitions/IServer'; import { TServerModel } from '../definitions/IServer';
import userPreferences from '../lib/userPreferences'; import userPreferences from '../lib/methods/userPreferences';
const DEFAULT_BIOMETRY = false; const DEFAULT_BIOMETRY = false;

View File

@ -29,10 +29,10 @@ import { sanitizeLikeString } from '../../lib/database/utils';
import getThreadName from '../../lib/methods/getThreadName'; import getThreadName from '../../lib/methods/getThreadName';
import getRoomInfo, { IRoomInfoResult } from '../../lib/methods/getRoomInfo'; import getRoomInfo, { IRoomInfoResult } from '../../lib/methods/getRoomInfo';
import { isIOS } from '../../utils/deviceInfo'; import { isIOS } from '../../utils/deviceInfo';
import { compareServerVersion } from '../../lib/utils';
import styles from './styles'; import styles from './styles';
import { InsideStackParamList, ChatsStackParamList } from '../../stacks/types'; import { InsideStackParamList, ChatsStackParamList } from '../../stacks/types';
import { IEmoji } from '../../definitions/IEmoji'; import { IEmoji } from '../../definitions/IEmoji';
import { compareServerVersion } from '../../lib/methods/helpers/compareServerVersion';
const QUERY_SIZE = 50; const QUERY_SIZE = 50;

View File

@ -8,7 +8,7 @@ import StatusBar from '../containers/StatusBar';
import * as List from '../containers/List'; import * as List from '../containers/List';
import { supportSystemTheme } from '../utils/deviceInfo'; import { supportSystemTheme } from '../utils/deviceInfo';
import SafeAreaView from '../containers/SafeAreaView'; import SafeAreaView from '../containers/SafeAreaView';
import UserPreferences from '../lib/userPreferences'; import UserPreferences from '../lib/methods/userPreferences';
import { events, logEvent } from '../utils/log'; import { events, logEvent } from '../utils/log';
import { IThemePreference, TThemeMode, TDarkLevel } from '../definitions/ITheme'; import { IThemePreference, TThemeMode, TDarkLevel } from '../definitions/ITheme';
import { THEME_PREFERENCES_KEY } from '../lib/constants'; import { THEME_PREFERENCES_KEY } from '../lib/constants';