diff --git a/app/containers/Passcode/PasscodeEnter.tsx b/app/containers/Passcode/PasscodeEnter.tsx index 145a46d21..a803bdeb4 100644 --- a/app/containers/Passcode/PasscodeEnter.tsx +++ b/app/containers/Passcode/PasscodeEnter.tsx @@ -10,7 +10,7 @@ import { TYPE } from './constants'; import { ATTEMPTS_KEY, LOCKED_OUT_TIMER_KEY, MAX_ATTEMPTS, PASSCODE_KEY } from '../../constants/localAuthentication'; import { biometryAuth, resetAttempts } from '../../utils/localAuthentication'; import { getDiff, getLockedUntil } from './utils'; -import { useUserPreferences } from '../../lib/userPreferences'; +import { useUserPreferences } from '../../lib/methods/userPreferences'; import I18n from '../../i18n'; interface IPasscodePasscodeEnter { diff --git a/app/containers/message/Image.tsx b/app/containers/message/Image.tsx index 7fb20b49d..f7f123f97 100644 --- a/app/containers/message/Image.tsx +++ b/app/containers/message/Image.tsx @@ -8,12 +8,12 @@ import * as Progress from 'react-native-progress'; import Touchable from './Touchable'; import Markdown from '../markdown'; import styles from './styles'; -import { formatAttachmentUrl } from '../../lib/utils'; import { themes } from '../../constants/colors'; import MessageContext from './Context'; import { TGetCustomEmoji } from '../../definitions/IEmoji'; import { IAttachment } from '../../definitions'; import { useTheme } from '../../theme'; +import { formatAttachmentUrl } from '../../lib/methods/helpers/formatAttachmentUrl'; interface IMessageButton { children: React.ReactElement; diff --git a/app/containers/message/Reply.tsx b/app/containers/message/Reply.tsx index 4705c5540..a080988bf 100644 --- a/app/containers/message/Reply.tsx +++ b/app/containers/message/Reply.tsx @@ -11,12 +11,12 @@ import sharedStyles from '../../views/Styles'; import { themes } from '../../constants/colors'; import MessageContext from './Context'; import { fileDownloadAndPreview } from '../../utils/fileDownload'; -import { formatAttachmentUrl } from '../../lib/utils'; import { IAttachment } from '../../definitions/IAttachment'; import { TGetCustomEmoji } from '../../definitions/IEmoji'; import RCActivityIndicator from '../ActivityIndicator'; import Attachments from './Attachments'; import { useTheme } from '../../theme'; +import { formatAttachmentUrl } from '../../lib/methods/helpers/formatAttachmentUrl'; const styles = StyleSheet.create({ button: { diff --git a/app/containers/message/Video.tsx b/app/containers/message/Video.tsx index b493027cb..b651b5dcd 100644 --- a/app/containers/message/Video.tsx +++ b/app/containers/message/Video.tsx @@ -6,7 +6,6 @@ import Touchable from './Touchable'; import Markdown from '../markdown'; import { isIOS } from '../../utils/deviceInfo'; import { CustomIcon } from '../../lib/Icons'; -import { formatAttachmentUrl } from '../../lib/utils'; import { themes } from '../../constants/colors'; import MessageContext from './Context'; import { fileDownload } from '../../utils/fileDownload'; @@ -17,6 +16,7 @@ import { IAttachment } from '../../definitions/IAttachment'; import RCActivityIndicator from '../ActivityIndicator'; import { TGetCustomEmoji } from '../../definitions/IEmoji'; import { useTheme } from '../../theme'; +import { formatAttachmentUrl } from '../../lib/methods/helpers/formatAttachmentUrl'; const SUPPORTED_TYPES = ['video/quicktime', 'video/mp4', ...(isIOS ? [] : ['video/3gp', 'video/mkv'])]; const isTypeSupported = (type: string) => SUPPORTED_TYPES.indexOf(type) !== -1; diff --git a/app/lib/encryption/encryption.ts b/app/lib/encryption/encryption.ts index 39ca516bb..d4231c4dc 100644 --- a/app/lib/encryption/encryption.ts +++ b/app/lib/encryption/encryption.ts @@ -4,7 +4,7 @@ import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord'; import { Q, Model } from '@nozbe/watermelondb'; import RocketChat from '../rocketchat'; -import UserPreferences from '../userPreferences'; +import UserPreferences from '../methods/userPreferences'; import database from '../database'; import protectedFunction from '../methods/helpers/protectedFunction'; import Deferred from '../../utils/deferred'; diff --git a/app/lib/methods/helpers/compareServerVersion.ts b/app/lib/methods/helpers/compareServerVersion.ts new file mode 100644 index 000000000..a419cb33f --- /dev/null +++ b/app/lib/methods/helpers/compareServerVersion.ts @@ -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; diff --git a/app/lib/methods/helpers/formatAttachmentUrl.ts b/app/lib/methods/helpers/formatAttachmentUrl.ts new file mode 100644 index 000000000..6c42244c6 --- /dev/null +++ b/app/lib/methods/helpers/formatAttachmentUrl.ts @@ -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}`); +}; diff --git a/app/lib/methods/helpers/generateLoadMoreId.ts b/app/lib/methods/helpers/generateLoadMoreId.ts new file mode 100644 index 000000000..ccd721efa --- /dev/null +++ b/app/lib/methods/helpers/generateLoadMoreId.ts @@ -0,0 +1 @@ +export const generateLoadMoreId = (id: string): string => `load-more-${id}`; diff --git a/app/lib/methods/helpers/mergeSubscriptionsRooms.ts b/app/lib/methods/helpers/mergeSubscriptionsRooms.ts index e430371a2..9d108b9f9 100644 --- a/app/lib/methods/helpers/mergeSubscriptionsRooms.ts +++ b/app/lib/methods/helpers/mergeSubscriptionsRooms.ts @@ -2,10 +2,10 @@ import EJSON from 'ejson'; import { Encryption } from '../../encryption'; import { store as reduxStore } from '../../auxStore'; -import { compareServerVersion } from '../../utils'; import findSubscriptionsRooms from './findSubscriptionsRooms'; import normalizeMessage from './normalizeMessage'; import { ISubscription, IServerSubscription, IServerRoom, IRoom } from '../../../definitions'; +import { compareServerVersion } from './compareServerVersion'; export const merge = (subscription: ISubscription | IServerSubscription, room?: IRoom | IServerRoom): ISubscription => { const serverVersion = reduxStore.getState().server.version as string; diff --git a/app/lib/methods/loadMessagesForRoom.ts b/app/lib/methods/loadMessagesForRoom.ts index f190473f4..e74e754c3 100644 --- a/app/lib/methods/loadMessagesForRoom.ts +++ b/app/lib/methods/loadMessagesForRoom.ts @@ -6,8 +6,8 @@ import log from '../../utils/log'; import { getMessageById } from '../database/services/Message'; import roomTypeToApiType, { RoomTypes } from './roomTypeToApiType'; import sdk from '../rocketchat/services/sdk'; -import { generateLoadMoreId } from '../utils'; import updateMessages from './updateMessages'; +import { generateLoadMoreId } from './helpers/generateLoadMoreId'; const COUNT = 50; diff --git a/app/lib/methods/loadNextMessages.ts b/app/lib/methods/loadNextMessages.ts index e1f668a3a..6331c8774 100644 --- a/app/lib/methods/loadNextMessages.ts +++ b/app/lib/methods/loadNextMessages.ts @@ -5,10 +5,10 @@ import orderBy from 'lodash/orderBy'; import log from '../../utils/log'; import { getMessageById } from '../database/services/Message'; import { MessageTypeLoad } from '../../constants/messageTypeLoad'; -import { generateLoadMoreId } from '../utils'; import updateMessages from './updateMessages'; import { TMessageModel } from '../../definitions'; import sdk from '../rocketchat/services/sdk'; +import { generateLoadMoreId } from './helpers/generateLoadMoreId'; const COUNT = 50; diff --git a/app/lib/methods/loadSurroundingMessages.ts b/app/lib/methods/loadSurroundingMessages.ts index 727bd200e..a125edd90 100644 --- a/app/lib/methods/loadSurroundingMessages.ts +++ b/app/lib/methods/loadSurroundingMessages.ts @@ -7,8 +7,8 @@ import { getMessageById } from '../database/services/Message'; import { MessageTypeLoad } from '../../constants/messageTypeLoad'; import sdk from '../rocketchat/services/sdk'; import { IMessage } from '../../definitions'; -import { generateLoadMoreId } from '../utils'; import updateMessages from './updateMessages'; +import { generateLoadMoreId } from './helpers/generateLoadMoreId'; const COUNT = 50; diff --git a/app/lib/methods/updateMessages.ts b/app/lib/methods/updateMessages.ts index 4a8c9bb58..b95fbd125 100644 --- a/app/lib/methods/updateMessages.ts +++ b/app/lib/methods/updateMessages.ts @@ -6,8 +6,8 @@ import { IMessage, TMessageModel, TSubscriptionModel, TThreadMessageModel, TThre import database from '../database'; import { getSubscriptionByRoomId } from '../database/services/Subscription'; import { Encryption } from '../encryption'; -import { generateLoadMoreId } from '../utils'; import buildMessage from './helpers/buildMessage'; +import { generateLoadMoreId } from './helpers/generateLoadMoreId'; import protectedFunction from './helpers/protectedFunction'; interface IUpdateMessages { diff --git a/app/lib/userPreferences.ts b/app/lib/methods/userPreferences.ts similarity index 100% rename from app/lib/userPreferences.ts rename to app/lib/methods/userPreferences.ts diff --git a/app/lib/rocketchat/methods/enterpriseModules.ts b/app/lib/rocketchat/methods/enterpriseModules.ts index 5f1475913..41490e719 100644 --- a/app/lib/rocketchat/methods/enterpriseModules.ts +++ b/app/lib/rocketchat/methods/enterpriseModules.ts @@ -1,9 +1,9 @@ import sdk from '../services/sdk'; -import { compareServerVersion } from '../../utils'; import { store as reduxStore } from '../../auxStore'; import database from '../../database'; import log from '../../../utils/log'; import { clearEnterpriseModules, setEnterpriseModules as setEnterpriseModulesAction } from '../../../actions/enterpriseModules'; +import { compareServerVersion } from '../../methods/helpers/compareServerVersion'; const LICENSE_OMNICHANNEL_MOBILE_ENTERPRISE = 'omnichannel-mobile-enterprise'; const LICENSE_LIVECHAT_ENTERPRISE = 'livechat-enterprise'; diff --git a/app/lib/rocketchat/methods/getCustomEmojis.ts b/app/lib/rocketchat/methods/getCustomEmojis.ts index 8e73891ae..94e3d737c 100644 --- a/app/lib/rocketchat/methods/getCustomEmojis.ts +++ b/app/lib/rocketchat/methods/getCustomEmojis.ts @@ -2,13 +2,13 @@ import orderBy from 'lodash/orderBy'; import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord'; import { ICustomEmojis } from '../../../reducers/customEmojis'; -import { compareServerVersion } from '../../utils'; import { store as reduxStore } from '../../auxStore'; import database from '../../database'; import log from '../../../utils/log'; import { setCustomEmojis as setCustomEmojisAction } from '../../../actions/customEmojis'; import { ICustomEmoji, TCustomEmojiModel } from '../../../definitions'; import sdk from '../services/sdk'; +import { compareServerVersion } from '../../methods/helpers/compareServerVersion'; interface IUpdateEmojis { update: TCustomEmojiModel[]; diff --git a/app/lib/rocketchat/methods/getPermissions.ts b/app/lib/rocketchat/methods/getPermissions.ts index d75af0f0c..2de011dc1 100644 --- a/app/lib/rocketchat/methods/getPermissions.ts +++ b/app/lib/rocketchat/methods/getPermissions.ts @@ -8,8 +8,8 @@ import log from '../../../utils/log'; import { store as reduxStore } from '../../auxStore'; import database from '../../database'; import sdk from '../services/sdk'; -import { compareServerVersion } from '../../utils'; import protectedFunction from '../../methods/helpers/protectedFunction'; +import { compareServerVersion } from '../../methods/helpers/compareServerVersion'; export const SUPPORTED_PERMISSIONS = [ 'add-user-to-any-c-room', diff --git a/app/lib/rocketchat/methods/getUsersPresence.ts b/app/lib/rocketchat/methods/getUsersPresence.ts index eb6e349cc..92576a199 100644 --- a/app/lib/rocketchat/methods/getUsersPresence.ts +++ b/app/lib/rocketchat/methods/getUsersPresence.ts @@ -2,13 +2,13 @@ import { InteractionManager } from 'react-native'; import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord'; import { IActiveUsers } from '../../../reducers/activeUsers'; -import { compareServerVersion } from '../../utils'; import { store as reduxStore } from '../../auxStore'; import { setActiveUsers } from '../../../actions/activeUsers'; import { setUser } from '../../../actions/login'; import database from '../../database'; import { IRocketChat, IUser } from '../../../definitions'; import sdk from '../services/sdk'; +import { compareServerVersion } from '../../methods/helpers/compareServerVersion'; export function subscribeUsersPresence(this: IRocketChat) { const serverVersion = reduxStore.getState().server.version as string; diff --git a/app/lib/rocketchat/methods/logout.ts b/app/lib/rocketchat/methods/logout.ts index a9bad1df1..4fe5e05d6 100644 --- a/app/lib/rocketchat/methods/logout.ts +++ b/app/lib/rocketchat/methods/logout.ts @@ -10,7 +10,7 @@ import RocketChat from '..'; import { useSsl } from '../../../utils/url'; import log from '../../../utils/log'; 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 sdk from '../services/sdk'; diff --git a/app/lib/rocketchat/methods/setUser.ts b/app/lib/rocketchat/methods/setUser.ts index f67c9ab2f..db95f0a4e 100644 --- a/app/lib/rocketchat/methods/setUser.ts +++ b/app/lib/rocketchat/methods/setUser.ts @@ -3,7 +3,7 @@ import { InteractionManager } from 'react-native'; import { setActiveUsers } from '../../../actions/activeUsers'; import { setUser } from '../../../actions/login'; import { store as reduxStore } from '../../auxStore'; -import { compareServerVersion } from '../../utils'; +import { compareServerVersion } from '../../methods/helpers/compareServerVersion'; // TODO export function _setUser(this: any, ddpMessage: { fields: any; id: any; cleared: any }) { diff --git a/app/lib/rocketchat/methods/userPreferencesMethods.ts b/app/lib/rocketchat/methods/userPreferencesMethods.ts index fd8ae9741..7ab5db523 100644 --- a/app/lib/rocketchat/methods/userPreferencesMethods.ts +++ b/app/lib/rocketchat/methods/userPreferencesMethods.ts @@ -1,5 +1,5 @@ import { IPreferences } from '../../../definitions'; -import userPreferences from '../../userPreferences'; +import userPreferences from '../../methods/userPreferences'; const SORT_PREFS_KEY = 'RC_SORT_PREFS_KEY'; diff --git a/app/lib/rocketchat/services/connect.ts b/app/lib/rocketchat/services/connect.ts index ed7ca610a..636f45a68 100644 --- a/app/lib/rocketchat/services/connect.ts +++ b/app/lib/rocketchat/services/connect.ts @@ -11,7 +11,6 @@ import protectedFunction from '../../methods/helpers/protectedFunction'; import database from '../../database'; import { selectServerFailure } from '../../../actions/server'; import { twoFactor } from '../../../utils/twoFactor'; -import { compareServerVersion } from '../../utils'; import { store } from '../../auxStore'; import { loginRequest, setLoginServices, setUser } from '../../../actions/login'; import sdk from './sdk'; @@ -25,6 +24,7 @@ import EventEmitter from '../../../utils/events'; import { updateSettings } from '../../../actions/settings'; import defaultSettings from '../../../constants/settings'; import { MIN_ROCKETCHAT_VERSION } from '../../constants'; +import { compareServerVersion } from '../../methods/helpers/compareServerVersion'; interface IServices { [index: string]: string | boolean; diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index 3039f400c..2097b0f75 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -16,9 +16,9 @@ import { TParams } from '../../../definitions/ILivechatEditView'; import { store as reduxStore } from '../../auxStore'; import { getDeviceToken } from '../../../notifications/push'; import { getBundleId, isIOS } from '../../../utils/deviceInfo'; -import { compareServerVersion } from '../../utils'; import roomTypeToApiType, { RoomTypes } from '../../methods/roomTypeToApiType'; import sdk from './sdk'; +import { compareServerVersion } from '../../methods/helpers/compareServerVersion'; export const createChannel = ({ name, diff --git a/app/lib/rocketchat/services/shareExtension.ts b/app/lib/rocketchat/services/shareExtension.ts index 65a7f76dd..023cd601f 100644 --- a/app/lib/rocketchat/services/shareExtension.ts +++ b/app/lib/rocketchat/services/shareExtension.ts @@ -4,7 +4,7 @@ import { shareSetSettings, shareSelectServer, shareSetUser } from '../../../acti import SSLPinning from '../../../utils/sslPinning'; import log from '../../../utils/log'; import { IShareServer, IShareUser } from '../../../reducers/share'; -import UserPreferences from '../../userPreferences'; +import UserPreferences from '../../methods/userPreferences'; import database from '../../database'; import RocketChat from '..'; import { encryptionInit } from '../../../actions/encryption'; diff --git a/app/lib/utils.ts b/app/lib/utils.ts deleted file mode 100644 index 32c36c60d..000000000 --- a/app/lib/utils.ts +++ /dev/null @@ -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}`; diff --git a/app/sagas/deepLinking.js b/app/sagas/deepLinking.js index c10025394..1a30b4733 100644 --- a/app/sagas/deepLinking.js +++ b/app/sagas/deepLinking.js @@ -1,6 +1,6 @@ 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 * as types from '../actions/actionsTypes'; import { selectServerRequest, serverInitAdd } from '../actions/server'; diff --git a/app/sagas/encryption.js b/app/sagas/encryption.js index 6f6f6186e..f7a861686 100644 --- a/app/sagas/encryption.js +++ b/app/sagas/encryption.js @@ -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 database from '../lib/database'; import RocketChat from '../lib/rocketchat'; -import UserPreferences from '../lib/userPreferences'; +import UserPreferences from '../lib/methods/userPreferences'; import { getUserSelector } from '../selectors/login'; import { showErrorAlert } from '../utils/info'; import I18n from '../i18n'; diff --git a/app/sagas/init.js b/app/sagas/init.js index a7efced62..87196a7f0 100644 --- a/app/sagas/init.js +++ b/app/sagas/init.js @@ -2,7 +2,7 @@ import { put, takeLatest } from 'redux-saga/effects'; import RNBootSplash from 'react-native-bootsplash'; import { BIOMETRY_ENABLED_KEY } from '../constants/localAuthentication'; -import UserPreferences from '../lib/userPreferences'; +import UserPreferences from '../lib/methods/userPreferences'; import { selectServerRequest } from '../actions/server'; import { setAllPreferences } from '../actions/sortPreferences'; import { APP } from '../actions/actionsTypes'; diff --git a/app/sagas/login.js b/app/sagas/login.js index 6b265f32c..fa1c05515 100644 --- a/app/sagas/login.js +++ b/app/sagas/login.js @@ -16,7 +16,7 @@ import { inviteLinksRequest } from '../actions/inviteLinks'; import { showErrorAlert } from '../utils/info'; import { localAuthenticate } from '../utils/localAuthentication'; 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 { isOmnichannelStatusAvailable } from '../ee/omnichannel/lib'; import { RootEnum } from '../definitions'; diff --git a/app/sagas/selectServer.js b/app/sagas/selectServer.js index 0d0adcda4..617b4baef 100644 --- a/app/sagas/selectServer.js +++ b/app/sagas/selectServer.js @@ -17,7 +17,7 @@ import log, { logServerVersion } from '../utils/log'; import I18n from '../i18n'; import { BASIC_AUTH_KEY, setBasicAuth } from '../utils/fetch'; import { appStart } from '../actions/app'; -import UserPreferences from '../lib/userPreferences'; +import UserPreferences from '../lib/methods/userPreferences'; import { encryptionStop } from '../actions/encryption'; import SSLPinning from '../utils/sslPinning'; import { inquiryReset } from '../ee/omnichannel/actions/inquiry'; diff --git a/app/share.tsx b/app/share.tsx index 17ad911e8..aa2f4174a 100644 --- a/app/share.tsx +++ b/app/share.tsx @@ -6,7 +6,7 @@ import { createStackNavigator } from '@react-navigation/stack'; import { Provider } from 'react-redux'; 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 store from './lib/createStore'; import { initStore } from './lib/auxStore'; diff --git a/app/utils/avatar.ts b/app/utils/avatar.ts index a2045f7d8..459e04295 100644 --- a/app/utils/avatar.ts +++ b/app/utils/avatar.ts @@ -1,6 +1,6 @@ -import { compareServerVersion } from '../lib/utils'; import { SubscriptionType } from '../definitions/ISubscription'; 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}`; diff --git a/app/utils/localAuthentication.ts b/app/utils/localAuthentication.ts index 9a2255f7d..aac73a456 100644 --- a/app/utils/localAuthentication.ts +++ b/app/utils/localAuthentication.ts @@ -4,7 +4,7 @@ import AsyncStorage from '@react-native-community/async-storage'; import { sha256 } from 'js-sha256'; import moment from 'moment'; -import UserPreferences from '../lib/userPreferences'; +import UserPreferences from '../lib/methods/userPreferences'; import { store } from '../lib/auxStore'; import database from '../lib/database'; import { getServerTimeSync } from '../lib/rocketchat/services/getServerTimeSync'; diff --git a/app/utils/openLink.ts b/app/utils/openLink.ts index 70abcec72..b0305f775 100644 --- a/app/utils/openLink.ts +++ b/app/utils/openLink.ts @@ -2,7 +2,7 @@ import { Linking } from 'react-native'; import * as WebBrowser from 'expo-web-browser'; import parse from 'url-parse'; -import UserPreferences from '../lib/userPreferences'; +import UserPreferences from '../lib/methods/userPreferences'; import { themes } from '../constants/colors'; export const DEFAULT_BROWSER_KEY = 'DEFAULT_BROWSER_KEY'; diff --git a/app/utils/sslPinning.ts b/app/utils/sslPinning.ts index 76ccc9a5b..3111c7b53 100644 --- a/app/utils/sslPinning.ts +++ b/app/utils/sslPinning.ts @@ -2,7 +2,7 @@ import { Alert, NativeModules, Platform } from 'react-native'; import DocumentPicker from 'react-native-document-picker'; import * as FileSystem from 'expo-file-system'; -import UserPreferences from '../lib/userPreferences'; +import UserPreferences from '../lib/methods/userPreferences'; import I18n from '../i18n'; import { extractHostname } from './server'; import { ICertificate } from '../definitions'; diff --git a/app/utils/theme.ts b/app/utils/theme.ts index 08079ca22..1678a156e 100644 --- a/app/utils/theme.ts +++ b/app/utils/theme.ts @@ -5,11 +5,10 @@ import setRootViewColor from 'rn-root-view'; import { IThemePreference, TThemeMode } from '../definitions/ITheme'; import { themes } from '../constants/colors'; import { isAndroid } from './deviceInfo'; -import UserPreferences from '../lib/userPreferences'; +import UserPreferences from '../lib/methods/userPreferences'; import { THEME_PREFERENCES_KEY } from '../lib/constants'; import { TSupportedThemes } from '../theme'; - let themeListener: { remove: () => void } | null; export const initialTheme = (): IThemePreference => { diff --git a/app/views/AttachmentView.tsx b/app/views/AttachmentView.tsx index b51b116d3..b93106a40 100644 --- a/app/views/AttachmentView.tsx +++ b/app/views/AttachmentView.tsx @@ -16,7 +16,6 @@ import I18n from '../i18n'; import { withTheme } from '../theme'; import { ImageViewer } from '../presentation/ImageViewer'; import { themes } from '../constants/colors'; -import { formatAttachmentUrl } from '../lib/utils'; import RCActivityIndicator from '../containers/ActivityIndicator'; import * as HeaderButton from '../containers/HeaderButton'; import { isAndroid } from '../utils/deviceInfo'; @@ -26,6 +25,7 @@ import { getHeaderHeight } from '../containers/Header'; import StatusBar from '../containers/StatusBar'; import { InsideStackParamList } from '../stacks/types'; import { IAttachment } from '../definitions/IAttachment'; +import { formatAttachmentUrl } from '../lib/methods/helpers/formatAttachmentUrl'; const styles = StyleSheet.create({ container: { diff --git a/app/views/DefaultBrowserView.tsx b/app/views/DefaultBrowserView.tsx index 6e726c75c..23ef073bf 100644 --- a/app/views/DefaultBrowserView.tsx +++ b/app/views/DefaultBrowserView.tsx @@ -10,7 +10,7 @@ import * as List from '../containers/List'; import { DEFAULT_BROWSER_KEY } from '../utils/openLink'; import { isIOS } from '../utils/deviceInfo'; import SafeAreaView from '../containers/SafeAreaView'; -import UserPreferences from '../lib/userPreferences'; +import UserPreferences from '../lib/methods/userPreferences'; import { events, logEvent } from '../utils/log'; type TValue = 'inApp' | 'systemDefault:' | 'googlechrome:' | 'firefox:' | 'brave:'; diff --git a/app/views/E2ESaveYourPasswordView.tsx b/app/views/E2ESaveYourPasswordView.tsx index 9bd9a3fbf..3d59fdfa3 100644 --- a/app/views/E2ESaveYourPasswordView.tsx +++ b/app/views/E2ESaveYourPasswordView.tsx @@ -13,7 +13,7 @@ import { LISTENER } from '../containers/Toast'; import { IApplicationState, IBaseScreen } from '../definitions'; import I18n from '../i18n'; 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 { withTheme } from '../theme'; import EventEmitter from '../utils/events'; diff --git a/app/views/NewMessageView.tsx b/app/views/NewMessageView.tsx index c135e1b98..0e191b6ed 100644 --- a/app/views/NewMessageView.tsx +++ b/app/views/NewMessageView.tsx @@ -16,9 +16,9 @@ import { IApplicationState, IBaseScreen, ISearch, TSubscriptionModel } from '../ import I18n from '../i18n'; import database from '../lib/database'; import { CustomIcon } from '../lib/Icons'; +import { compareServerVersion } from '../lib/methods/helpers/compareServerVersion'; import Navigation from '../lib/Navigation'; import RocketChat from '../lib/rocketchat'; -import { compareServerVersion } from '../lib/utils'; import UserItem from '../presentation/UserItem'; import { withTheme } from '../theme'; import { goRoom } from '../utils/goRoom'; diff --git a/app/views/NewServerView/index.tsx b/app/views/NewServerView/index.tsx index 50917ceb5..e5e775ab6 100644 --- a/app/views/NewServerView/index.tsx +++ b/app/views/NewServerView/index.tsx @@ -20,7 +20,7 @@ import I18n from '../../i18n'; import database from '../../lib/database'; import { sanitizeLikeString } from '../../lib/database/utils'; import RocketChat from '../../lib/rocketchat'; -import UserPreferences from '../../lib/userPreferences'; +import UserPreferences from '../../lib/methods/userPreferences'; import { OutsideParamList } from '../../stacks/types'; import { withTheme } from '../../theme'; import { isTablet } from '../../utils/deviceInfo'; diff --git a/app/views/RoomActionsView/index.tsx b/app/views/RoomActionsView/index.tsx index 7cf1c17bc..d3e2d3e88 100644 --- a/app/views/RoomActionsView/index.tsx +++ b/app/views/RoomActionsView/index.tsx @@ -24,7 +24,6 @@ import database from '../../lib/database'; import { E2E_ROOM_TYPES } from '../../lib/constants'; import protectedFunction from '../../lib/methods/helpers/protectedFunction'; import RocketChat from '../../lib/rocketchat'; -import { compareServerVersion } from '../../lib/utils'; import { getUserSelector } from '../../selectors/login'; import { ChatsStackParamList } from '../../stacks/types'; import { withTheme } from '../../theme'; @@ -34,6 +33,7 @@ import Touch from '../../utils/touch'; import sharedStyles from '../Styles'; import styles from './styles'; import { ERoomType } from '../../definitions/ERoomType'; +import { compareServerVersion } from '../../lib/methods/helpers/compareServerVersion'; interface IRoomActionsViewProps extends IBaseScreen { userId: string; diff --git a/app/views/RoomInfoEditView/index.tsx b/app/views/RoomInfoEditView/index.tsx index 06d858d92..bebd8f502 100644 --- a/app/views/RoomInfoEditView/index.tsx +++ b/app/views/RoomInfoEditView/index.tsx @@ -22,7 +22,6 @@ import I18n from '../../i18n'; import database from '../../lib/database'; import { CustomIcon } from '../../lib/Icons'; import RocketChat from '../../lib/rocketchat'; -import { compareServerVersion } from '../../lib/utils'; import KeyboardView from '../../presentation/KeyboardView'; import { TSupportedPermissions } from '../../reducers/permissions'; import { ModalStackParamList } from '../../stacks/MasterDetailStack/types'; @@ -38,6 +37,7 @@ import { IAvatar } from '../../definitions/IProfileViewInterfaces'; import sharedStyles from '../Styles'; import styles from './styles'; import SwitchContainer from './SwitchContainer'; +import { compareServerVersion } from '../../lib/methods/helpers/compareServerVersion'; interface IRoomInfoEditViewState { room: ISubscription; diff --git a/app/views/RoomView/List/index.tsx b/app/views/RoomView/List/index.tsx index eb3e7c4e6..eae6fa8c7 100644 --- a/app/views/RoomView/List/index.tsx +++ b/app/views/RoomView/List/index.tsx @@ -10,8 +10,8 @@ import { themes } from '../../../constants/colors'; import ActivityIndicator from '../../../containers/ActivityIndicator'; import { TAnyMessageModel, TMessageModel, TThreadMessageModel, TThreadModel } from '../../../definitions'; import database from '../../../lib/database'; +import { compareServerVersion } from '../../../lib/methods/helpers/compareServerVersion'; import RocketChat from '../../../lib/rocketchat'; -import { compareServerVersion } from '../../../lib/utils'; import debounce from '../../../utils/debounce'; import { animateNextTransition } from '../../../utils/layoutAnimation'; import log from '../../../utils/log'; diff --git a/app/views/RoomsListView/ServerDropdown.tsx b/app/views/RoomsListView/ServerDropdown.tsx index 299928100..408088291 100644 --- a/app/views/RoomsListView/ServerDropdown.tsx +++ b/app/views/RoomsListView/ServerDropdown.tsx @@ -23,7 +23,7 @@ import { showConfirmationAlert } from '../../utils/info'; import log, { events, logEvent } from '../../utils/log'; import { headerHeight } from '../../containers/Header'; import { goRoom } from '../../utils/goRoom'; -import UserPreferences from '../../lib/userPreferences'; +import UserPreferences from '../../lib/methods/userPreferences'; import { IApplicationState, IBaseScreen, RootEnum, TServerModel } from '../../definitions'; import styles from './styles'; import { ChatsStackParamList } from '../../stacks/types'; diff --git a/app/views/ScreenLockConfigView.tsx b/app/views/ScreenLockConfigView.tsx index 50f2cde84..0c80123e6 100644 --- a/app/views/ScreenLockConfigView.tsx +++ b/app/views/ScreenLockConfigView.tsx @@ -15,7 +15,7 @@ import { BIOMETRY_ENABLED_KEY, DEFAULT_AUTO_LOCK } from '../constants/localAuthe import SafeAreaView from '../containers/SafeAreaView'; import { events, logEvent } from '../utils/log'; import { TServerModel } from '../definitions/IServer'; -import userPreferences from '../lib/userPreferences'; +import userPreferences from '../lib/methods/userPreferences'; const DEFAULT_BIOMETRY = false; diff --git a/app/views/SearchMessagesView/index.tsx b/app/views/SearchMessagesView/index.tsx index c6b5579d4..ec8cc6d84 100644 --- a/app/views/SearchMessagesView/index.tsx +++ b/app/views/SearchMessagesView/index.tsx @@ -29,10 +29,10 @@ import { sanitizeLikeString } from '../../lib/database/utils'; import getThreadName from '../../lib/methods/getThreadName'; import getRoomInfo, { IRoomInfoResult } from '../../lib/methods/getRoomInfo'; import { isIOS } from '../../utils/deviceInfo'; -import { compareServerVersion } from '../../lib/utils'; import styles from './styles'; import { InsideStackParamList, ChatsStackParamList } from '../../stacks/types'; import { IEmoji } from '../../definitions/IEmoji'; +import { compareServerVersion } from '../../lib/methods/helpers/compareServerVersion'; const QUERY_SIZE = 50; diff --git a/app/views/ThemeView.tsx b/app/views/ThemeView.tsx index 512b8b123..39bd3e36d 100644 --- a/app/views/ThemeView.tsx +++ b/app/views/ThemeView.tsx @@ -8,7 +8,7 @@ import StatusBar from '../containers/StatusBar'; import * as List from '../containers/List'; import { supportSystemTheme } from '../utils/deviceInfo'; import SafeAreaView from '../containers/SafeAreaView'; -import UserPreferences from '../lib/userPreferences'; +import UserPreferences from '../lib/methods/userPreferences'; import { events, logEvent } from '../utils/log'; import { IThemePreference, TThemeMode, TDarkLevel } from '../definitions/ITheme'; import { THEME_PREFERENCES_KEY } from '../lib/constants';