From 9a11fb2797ab33bf3f3b54ab20ac88451703a561 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Wed, 6 Apr 2022 17:35:53 -0300 Subject: [PATCH 1/9] [FIX] Add token expired verification (#3964) --- app/actions/login.ts | 6 ++++-- app/i18n/locales/en.json | 1 + app/sagas/login.js | 12 ++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/actions/login.ts b/app/actions/login.ts index 02d280747..990c9f858 100644 --- a/app/actions/login.ts +++ b/app/actions/login.ts @@ -25,6 +25,7 @@ interface ILoginFailure extends Action { interface ILogout extends Action { forcedByServer: boolean; + message: string; } interface ISetUser extends Action { @@ -79,10 +80,11 @@ export function loginFailure(err: Record): ILoginFailure { }; } -export function logout(forcedByServer = false): ILogout { +export function logout(forcedByServer = false, message = ''): ILogout { return { type: types.LOGOUT, - forcedByServer + forcedByServer, + message }; } diff --git a/app/i18n/locales/en.json b/app/i18n/locales/en.json index fe16b8854..2f416a609 100644 --- a/app/i18n/locales/en.json +++ b/app/i18n/locales/en.json @@ -597,6 +597,7 @@ "you": "you", "You": "You", "Logged_out_by_server": "You've been logged out by the server. Please log in again.", + "Token_expired": "Your session has expired. Please log in again.", "You_need_to_access_at_least_one_RocketChat_server_to_share_something": "You need to access at least one Rocket.Chat server to share something.", "You_need_to_verifiy_your_email_address_to_get_notications": "You need to verify your email address to get notifications", "Your_certificate": "Your Certificate", diff --git a/app/sagas/login.js b/app/sagas/login.js index 41fe6c5ca..6b265f32c 100644 --- a/app/sagas/login.js +++ b/app/sagas/login.js @@ -65,8 +65,10 @@ const handleLoginRequest = function* handleLoginRequest({ credentials, logoutOnE yield put(loginSuccess(result)); } } catch (e) { - if (logoutOnError && e.data && e.data.message && /you've been logged out by the server/i.test(e.data.message)) { - yield put(logout(true)); + if (e?.data?.message && /you've been logged out by the server/i.test(e.data.message)) { + yield put(logout(true, 'Logged_out_by_server')); + } else if (e?.data?.message && /your session has expired/i.test(e.data.message)) { + yield put(logout(true, 'Token_expired')); } else { logEvent(events.LOGIN_DEFAULT_LOGIN_F); yield put(loginFailure(e)); @@ -177,7 +179,7 @@ const handleLoginSuccess = function* handleLoginSuccess({ user }) { } }; -const handleLogout = function* handleLogout({ forcedByServer }) { +const handleLogout = function* handleLogout({ forcedByServer, message }) { yield put(encryptionStop()); yield put(appStart({ root: RootEnum.ROOT_LOADING, text: I18n.t('Logging_out') })); const server = yield select(getServer); @@ -188,7 +190,9 @@ const handleLogout = function* handleLogout({ forcedByServer }) { // if the user was logged out by the server if (forcedByServer) { yield put(appStart({ root: RootEnum.ROOT_OUTSIDE })); - showErrorAlert(I18n.t('Logged_out_by_server'), I18n.t('Oops')); + if (message) { + showErrorAlert(I18n.t(message), I18n.t('Oops')); + } yield delay(300); EventEmitter.emit('NewServer', { server }); } else { From 7d2ae5ea7c0bc7e31282baf244a20e60194efd4a Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Silva Date: Thu, 7 Apr 2022 10:13:19 -0300 Subject: [PATCH 2/9] Chore: Evaluate helpers and methods - Typescript (#4030) * move userPreferences to methods folder * create formatAttachmentUrl file * create compareServerVersion file * create generateLoadMoreId file --- app/containers/Passcode/PasscodeEnter.tsx | 2 +- app/containers/message/Image.tsx | 2 +- app/containers/message/Reply.tsx | 2 +- app/containers/message/Video.tsx | 2 +- app/lib/encryption/encryption.ts | 2 +- .../methods/helpers/compareServerVersion.ts | 15 +++++++++++ .../methods/helpers/formatAttachmentUrl.ts | 9 +++++++ app/lib/methods/helpers/generateLoadMoreId.ts | 1 + .../helpers/mergeSubscriptionsRooms.ts | 2 +- app/lib/methods/loadMessagesForRoom.ts | 2 +- app/lib/methods/loadNextMessages.ts | 2 +- app/lib/methods/loadSurroundingMessages.ts | 2 +- app/lib/methods/updateMessages.ts | 2 +- app/lib/{ => methods}/userPreferences.ts | 0 .../rocketchat/methods/enterpriseModules.ts | 2 +- app/lib/rocketchat/methods/getCustomEmojis.ts | 2 +- app/lib/rocketchat/methods/getPermissions.ts | 2 +- .../rocketchat/methods/getUsersPresence.ts | 2 +- app/lib/rocketchat/methods/logout.ts | 2 +- app/lib/rocketchat/methods/setUser.ts | 2 +- .../methods/userPreferencesMethods.ts | 2 +- app/lib/rocketchat/services/connect.ts | 2 +- app/lib/rocketchat/services/restApi.ts | 2 +- app/lib/rocketchat/services/shareExtension.ts | 2 +- app/lib/utils.ts | 27 ------------------- app/sagas/deepLinking.js | 2 +- app/sagas/encryption.js | 2 +- app/sagas/init.js | 2 +- app/sagas/login.js | 2 +- app/sagas/selectServer.js | 2 +- app/share.tsx | 2 +- app/utils/avatar.ts | 2 +- app/utils/localAuthentication.ts | 2 +- app/utils/openLink.ts | 2 +- app/utils/sslPinning.ts | 2 +- app/utils/theme.ts | 3 +-- app/views/AttachmentView.tsx | 2 +- app/views/DefaultBrowserView.tsx | 2 +- app/views/E2ESaveYourPasswordView.tsx | 2 +- app/views/NewMessageView.tsx | 2 +- app/views/NewServerView/index.tsx | 2 +- app/views/RoomActionsView/index.tsx | 2 +- app/views/RoomInfoEditView/index.tsx | 2 +- app/views/RoomView/List/index.tsx | 2 +- app/views/RoomsListView/ServerDropdown.tsx | 2 +- app/views/ScreenLockConfigView.tsx | 2 +- app/views/SearchMessagesView/index.tsx | 2 +- app/views/ThemeView.tsx | 2 +- 48 files changed, 68 insertions(+), 71 deletions(-) create mode 100644 app/lib/methods/helpers/compareServerVersion.ts create mode 100644 app/lib/methods/helpers/formatAttachmentUrl.ts create mode 100644 app/lib/methods/helpers/generateLoadMoreId.ts rename app/lib/{ => methods}/userPreferences.ts (100%) delete mode 100644 app/lib/utils.ts 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'; From 474ea98a3b9341d5c51c885b449b5ed23ae31400 Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Silva Date: Thu, 7 Apr 2022 10:22:19 -0300 Subject: [PATCH 3/9] Chore: Create app/lib/navigation folder (#4027) * change Navigation to appNavigation and move to navigation folder * change ShareNavigation to shareNavigation and move to navigation folder * fix navigation import Co-authored-by: Diego Mello --- app/AppContainer.tsx | 2 +- app/containers/InAppNotification/NotifierComponent.tsx | 2 +- app/containers/InAppNotification/index.tsx | 2 +- app/containers/MessageActions/index.tsx | 2 +- app/containers/MessageBox/index.tsx | 2 +- app/containers/UIKit/Image.tsx | 2 +- app/containers/markdown/Table.tsx | 2 +- app/lib/methods/actions.ts | 2 +- app/lib/{Navigation.ts => navigation/appNavigation.ts} | 0 app/lib/{ShareNavigation.ts => navigation/shareNavigation.ts} | 0 app/lib/rocketchat/methods/callJitsi.ts | 2 +- app/lib/rocketchat/methods/triggerActions.ts | 2 +- app/sagas/createChannel.js | 2 +- app/sagas/deepLinking.js | 2 +- app/sagas/encryption.js | 2 +- app/sagas/inviteLinks.js | 2 +- app/sagas/messages.js | 2 +- app/sagas/room.js | 2 +- app/sagas/selectServer.js | 2 +- app/share.tsx | 2 +- app/utils/goRoom.ts | 2 +- app/views/CannedResponseDetail.tsx | 2 +- app/views/CannedResponsesListView/index.tsx | 2 +- app/views/CreateDiscussionView/index.tsx | 2 +- app/views/ModalBlockView.tsx | 2 +- app/views/NewMessageView.tsx | 2 +- app/views/RoomInfoView/index.tsx | 2 +- app/views/RoomView/index.tsx | 2 +- app/views/SidebarView/index.tsx | 2 +- 29 files changed, 27 insertions(+), 27 deletions(-) rename app/lib/{Navigation.ts => navigation/appNavigation.ts} (100%) rename app/lib/{ShareNavigation.ts => navigation/shareNavigation.ts} (100%) diff --git a/app/AppContainer.tsx b/app/AppContainer.tsx index 0ae892b7f..af3d34fe0 100644 --- a/app/AppContainer.tsx +++ b/app/AppContainer.tsx @@ -4,7 +4,7 @@ import { createStackNavigator } from '@react-navigation/stack'; import { connect } from 'react-redux'; import { SetUsernameStackParamList, StackParamList } from './definitions/navigationTypes'; -import Navigation from './lib/Navigation'; +import Navigation from './lib/navigation/appNavigation'; import { defaultHeader, getActiveRouteName, navigationTheme } from './utils/navigation'; import { RootEnum } from './definitions'; // Stacks diff --git a/app/containers/InAppNotification/NotifierComponent.tsx b/app/containers/InAppNotification/NotifierComponent.tsx index c0c16a9c3..5987c0c7a 100644 --- a/app/containers/InAppNotification/NotifierComponent.tsx +++ b/app/containers/InAppNotification/NotifierComponent.tsx @@ -12,7 +12,7 @@ import { themes } from '../../constants/colors'; import { useTheme } from '../../theme'; import { ROW_HEIGHT } from '../../presentation/RoomItem'; import { goRoom } from '../../utils/goRoom'; -import Navigation from '../../lib/Navigation'; +import Navigation from '../../lib/navigation/appNavigation'; import { useOrientation } from '../../dimensions'; import { IApplicationState, ISubscription, SubscriptionType } from '../../definitions'; diff --git a/app/containers/InAppNotification/index.tsx b/app/containers/InAppNotification/index.tsx index 7e5d15889..49e227389 100644 --- a/app/containers/InAppNotification/index.tsx +++ b/app/containers/InAppNotification/index.tsx @@ -5,7 +5,7 @@ import { dequal } from 'dequal'; import NotifierComponent, { INotifierComponent } from './NotifierComponent'; import EventEmitter from '../../utils/events'; -import Navigation from '../../lib/Navigation'; +import Navigation from '../../lib/navigation/appNavigation'; import { getActiveRoute } from '../../utils/navigation'; import { IApplicationState } from '../../definitions'; import { IRoom } from '../../reducers/room'; diff --git a/app/containers/MessageActions/index.tsx b/app/containers/MessageActions/index.tsx index 0527a45fb..904be75f2 100644 --- a/app/containers/MessageActions/index.tsx +++ b/app/containers/MessageActions/index.tsx @@ -8,7 +8,7 @@ import RocketChat from '../../lib/rocketchat'; import database from '../../lib/database'; import I18n from '../../i18n'; import log, { logEvent } from '../../utils/log'; -import Navigation from '../../lib/Navigation'; +import Navigation from '../../lib/navigation/appNavigation'; import { getMessageTranslation } from '../message/utils'; import { LISTENER } from '../Toast'; import EventEmitter from '../../utils/events'; diff --git a/app/containers/MessageBox/index.tsx b/app/containers/MessageBox/index.tsx index 857dfb575..a087949c9 100644 --- a/app/containers/MessageBox/index.tsx +++ b/app/containers/MessageBox/index.tsx @@ -44,7 +44,7 @@ import { } from './constants'; import CommandsPreview from './CommandsPreview'; import { getUserSelector } from '../../selectors/login'; -import Navigation from '../../lib/Navigation'; +import Navigation from '../../lib/navigation/appNavigation'; import { withActionSheet } from '../ActionSheet'; import { sanitizeLikeString } from '../../lib/database/utils'; import { CustomIcon } from '../../lib/Icons'; diff --git a/app/containers/UIKit/Image.tsx b/app/containers/UIKit/Image.tsx index ad229fcb3..d35874f2e 100644 --- a/app/containers/UIKit/Image.tsx +++ b/app/containers/UIKit/Image.tsx @@ -4,7 +4,7 @@ import FastImage from '@rocket.chat/react-native-fast-image'; import { BLOCK_CONTEXT } from '@rocket.chat/ui-kit'; import ImageContainer from '../message/Image'; -import Navigation from '../../lib/Navigation'; +import Navigation from '../../lib/navigation/appNavigation'; import { IThumb, IImage, IElement } from './interfaces'; import { IAttachment } from '../../definitions'; diff --git a/app/containers/markdown/Table.tsx b/app/containers/markdown/Table.tsx index 5f38aa017..39ca2f3a9 100644 --- a/app/containers/markdown/Table.tsx +++ b/app/containers/markdown/Table.tsx @@ -3,7 +3,7 @@ import { ScrollView, Text, TouchableOpacity, View, ViewStyle } from 'react-nativ import { CELL_WIDTH } from './TableCell'; import styles from './styles'; -import Navigation from '../../lib/Navigation'; +import Navigation from '../../lib/navigation/appNavigation'; import I18n from '../../i18n'; import { themes } from '../../constants/colors'; diff --git a/app/lib/methods/actions.ts b/app/lib/methods/actions.ts index 2e4323598..da4c55db7 100644 --- a/app/lib/methods/actions.ts +++ b/app/lib/methods/actions.ts @@ -3,7 +3,7 @@ import { TRocketChat } from '../../definitions/IRocketChat'; import EventEmitter from '../../utils/events'; import fetch from '../../utils/fetch'; import random from '../../utils/random'; -import Navigation from '../Navigation'; +import Navigation from '../navigation/appNavigation'; import sdk from '../rocketchat/services/sdk'; const triggersId = new Map(); diff --git a/app/lib/Navigation.ts b/app/lib/navigation/appNavigation.ts similarity index 100% rename from app/lib/Navigation.ts rename to app/lib/navigation/appNavigation.ts diff --git a/app/lib/ShareNavigation.ts b/app/lib/navigation/shareNavigation.ts similarity index 100% rename from app/lib/ShareNavigation.ts rename to app/lib/navigation/shareNavigation.ts diff --git a/app/lib/rocketchat/methods/callJitsi.ts b/app/lib/rocketchat/methods/callJitsi.ts index 0bd2567cc..7b19bb389 100644 --- a/app/lib/rocketchat/methods/callJitsi.ts +++ b/app/lib/rocketchat/methods/callJitsi.ts @@ -1,7 +1,7 @@ import { ISubscription } from '../../../definitions'; import { events, logEvent } from '../../../utils/log'; import { store } from '../../auxStore'; -import Navigation from '../../Navigation'; +import Navigation from '../../navigation/appNavigation'; import sdk from '../services/sdk'; async function jitsiURL({ room }: { room: ISubscription }) { diff --git a/app/lib/rocketchat/methods/triggerActions.ts b/app/lib/rocketchat/methods/triggerActions.ts index 9816f386d..65a14528e 100644 --- a/app/lib/rocketchat/methods/triggerActions.ts +++ b/app/lib/rocketchat/methods/triggerActions.ts @@ -7,7 +7,7 @@ import { } from '../../../containers/UIKit/interfaces'; import { TRocketChat } from '../../../definitions'; import { triggerAction } from '../../methods/actions'; -import Navigation from '../../Navigation'; +import Navigation from '../../navigation/appNavigation'; export function triggerBlockAction(this: TRocketChat, options: ITriggerBlockAction) { return triggerAction.call(this, { type: ActionTypes.ACTION, ...options }); diff --git a/app/sagas/createChannel.js b/app/sagas/createChannel.js index 8185f673e..f540e3226 100644 --- a/app/sagas/createChannel.js +++ b/app/sagas/createChannel.js @@ -5,7 +5,7 @@ import { CREATE_CHANNEL, LOGIN } from '../actions/actionsTypes'; import { createChannelFailure, createChannelSuccess } from '../actions/createChannel'; import { showErrorAlert } from '../utils/info'; import RocketChat from '../lib/rocketchat'; -import Navigation from '../lib/Navigation'; +import Navigation from '../lib/navigation/appNavigation'; import database from '../lib/database'; import I18n from '../i18n'; import { events, logEvent } from '../utils/log'; diff --git a/app/sagas/deepLinking.js b/app/sagas/deepLinking.js index 1a30b4733..71036b4aa 100644 --- a/app/sagas/deepLinking.js +++ b/app/sagas/deepLinking.js @@ -1,7 +1,7 @@ import { all, delay, put, select, take, takeLatest } from 'redux-saga/effects'; import UserPreferences from '../lib/methods/userPreferences'; -import Navigation from '../lib/Navigation'; +import Navigation from '../lib/navigation/appNavigation'; import * as types from '../actions/actionsTypes'; import { selectServerRequest, serverInitAdd } from '../actions/server'; import { inviteLinksRequest, inviteLinksSetToken } from '../actions/inviteLinks'; diff --git a/app/sagas/encryption.js b/app/sagas/encryption.js index f7a861686..4ab7e83d7 100644 --- a/app/sagas/encryption.js +++ b/app/sagas/encryption.js @@ -4,7 +4,7 @@ import { put, select, takeLatest } from 'redux-saga/effects'; import { ENCRYPTION } from '../actions/actionsTypes'; import { encryptionSet } from '../actions/encryption'; import { Encryption } from '../lib/encryption'; -import Navigation from '../lib/Navigation'; +import Navigation from '../lib/navigation/appNavigation'; 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'; diff --git a/app/sagas/inviteLinks.js b/app/sagas/inviteLinks.js index 2fd536614..de67c52a8 100644 --- a/app/sagas/inviteLinks.js +++ b/app/sagas/inviteLinks.js @@ -5,7 +5,7 @@ import { INVITE_LINKS } from '../actions/actionsTypes'; import { inviteLinksFailure, inviteLinksSetInvite, inviteLinksSuccess } from '../actions/inviteLinks'; import RocketChat from '../lib/rocketchat'; import log from '../utils/log'; -import Navigation from '../lib/Navigation'; +import Navigation from '../lib/navigation/appNavigation'; import I18n from '../i18n'; const handleRequest = function* handleRequest({ token }) { diff --git a/app/sagas/messages.js b/app/sagas/messages.js index d4d110faa..2f38c2975 100644 --- a/app/sagas/messages.js +++ b/app/sagas/messages.js @@ -1,7 +1,7 @@ import { select, takeLatest } from 'redux-saga/effects'; import { Q } from '@nozbe/watermelondb'; -import Navigation from '../lib/Navigation'; +import Navigation from '../lib/navigation/appNavigation'; import { MESSAGES } from '../actions/actionsTypes'; import RocketChat from '../lib/rocketchat'; import database from '../lib/database'; diff --git a/app/sagas/room.js b/app/sagas/room.js index f45bf123a..10d615a0b 100644 --- a/app/sagas/room.js +++ b/app/sagas/room.js @@ -3,7 +3,7 @@ import prompt from 'react-native-prompt-android'; import { delay, put, race, select, take, takeLatest } from 'redux-saga/effects'; import EventEmitter from '../utils/events'; -import Navigation from '../lib/Navigation'; +import Navigation from '../lib/navigation/appNavigation'; import * as types from '../actions/actionsTypes'; import { removedRoom } from '../actions/room'; import RocketChat from '../lib/rocketchat'; diff --git a/app/sagas/selectServer.js b/app/sagas/selectServer.js index 617b4baef..b58a61642 100644 --- a/app/sagas/selectServer.js +++ b/app/sagas/selectServer.js @@ -5,7 +5,7 @@ import { Q } from '@nozbe/watermelondb'; import valid from 'semver/functions/valid'; import coerce from 'semver/functions/coerce'; -import Navigation from '../lib/Navigation'; +import Navigation from '../lib/navigation/appNavigation'; import { SERVER } from '../actions/actionsTypes'; import { selectServerFailure, selectServerRequest, selectServerSuccess, serverFailure } from '../actions/server'; import { clearSettings } from '../actions/settings'; diff --git a/app/share.tsx b/app/share.tsx index aa2f4174a..8a4ca1f1d 100644 --- a/app/share.tsx +++ b/app/share.tsx @@ -7,7 +7,7 @@ import { Provider } from 'react-redux'; import { getTheme, initialTheme, newThemeState, subscribeTheme, unsubscribeTheme } from './utils/theme'; import UserPreferences from './lib/methods/userPreferences'; -import Navigation from './lib/ShareNavigation'; +import Navigation from './lib/navigation/shareNavigation'; import store from './lib/createStore'; import { initStore } from './lib/auxStore'; import { closeShareExtension, shareExtensionInit } from './lib/rocketchat/services/shareExtension'; diff --git a/app/utils/goRoom.ts b/app/utils/goRoom.ts index 64881abc1..46de9fb11 100644 --- a/app/utils/goRoom.ts +++ b/app/utils/goRoom.ts @@ -1,5 +1,5 @@ import { ChatsStackParamList } from '../stacks/types'; -import Navigation from '../lib/Navigation'; +import Navigation from '../lib/navigation/appNavigation'; import RocketChat from '../lib/rocketchat'; import { IOmnichannelRoom, SubscriptionType, IVisitor, TSubscriptionModel, ISubscription } from '../definitions'; diff --git a/app/views/CannedResponseDetail.tsx b/app/views/CannedResponseDetail.tsx index 1bb0ae646..91ea72c14 100644 --- a/app/views/CannedResponseDetail.tsx +++ b/app/views/CannedResponseDetail.tsx @@ -10,7 +10,7 @@ import StatusBar from '../containers/StatusBar'; import Button from '../containers/Button'; import { useTheme } from '../theme'; import RocketChat from '../lib/rocketchat'; -import Navigation from '../lib/Navigation'; +import Navigation from '../lib/navigation/appNavigation'; import { goRoom } from '../utils/goRoom'; import { themes } from '../constants/colors'; import Markdown from '../containers/markdown'; diff --git a/app/views/CannedResponsesListView/index.tsx b/app/views/CannedResponsesListView/index.tsx index e9dec1475..c273efd4a 100644 --- a/app/views/CannedResponsesListView/index.tsx +++ b/app/views/CannedResponsesListView/index.tsx @@ -16,7 +16,7 @@ import { getHeaderTitlePosition } from '../../containers/Header'; import { useTheme } from '../../theme'; import RocketChat from '../../lib/rocketchat'; import debounce from '../../utils/debounce'; -import Navigation from '../../lib/Navigation'; +import Navigation from '../../lib/navigation/appNavigation'; import { goRoom } from '../../utils/goRoom'; import * as HeaderButton from '../../containers/HeaderButton'; import * as List from '../../containers/List'; diff --git a/app/views/CreateDiscussionView/index.tsx b/app/views/CreateDiscussionView/index.tsx index 97d263680..936ce3f3e 100644 --- a/app/views/CreateDiscussionView/index.tsx +++ b/app/views/CreateDiscussionView/index.tsx @@ -14,7 +14,7 @@ import { withTheme } from '../../theme'; import { getUserSelector } from '../../selectors/login'; import TextInput from '../../containers/TextInput'; import RocketChat from '../../lib/rocketchat'; -import Navigation from '../../lib/Navigation'; +import Navigation from '../../lib/navigation/appNavigation'; import { createDiscussionRequest } from '../../actions/createDiscussion'; import { showErrorAlert } from '../../utils/info'; import SafeAreaView from '../../containers/SafeAreaView'; diff --git a/app/views/ModalBlockView.tsx b/app/views/ModalBlockView.tsx index c87a3fd9c..119f45d7f 100644 --- a/app/views/ModalBlockView.tsx +++ b/app/views/ModalBlockView.tsx @@ -13,7 +13,7 @@ import { modalBlockWithContext } from '../containers/UIKit/MessageBlock'; import RocketChat from '../lib/rocketchat'; import ActivityIndicator from '../containers/ActivityIndicator'; import { textParser } from '../containers/UIKit/utils'; -import Navigation from '../lib/Navigation'; +import Navigation from '../lib/navigation/appNavigation'; import { MasterDetailInsideStackParamList } from '../stacks/MasterDetailStack/types'; import { ContainerTypes, ModalActions } from '../containers/UIKit/interfaces'; diff --git a/app/views/NewMessageView.tsx b/app/views/NewMessageView.tsx index 0e191b6ed..cfc7f0c7c 100644 --- a/app/views/NewMessageView.tsx +++ b/app/views/NewMessageView.tsx @@ -16,8 +16,8 @@ import { IApplicationState, IBaseScreen, ISearch, TSubscriptionModel } from '../ import I18n from '../i18n'; import database from '../lib/database'; import { CustomIcon } from '../lib/Icons'; +import Navigation from '../lib/navigation/appNavigation'; import { compareServerVersion } from '../lib/methods/helpers/compareServerVersion'; -import Navigation from '../lib/Navigation'; import RocketChat from '../lib/rocketchat'; import UserItem from '../presentation/UserItem'; import { withTheme } from '../theme'; diff --git a/app/views/RoomInfoView/index.tsx b/app/views/RoomInfoView/index.tsx index 1266e5741..dfcbd95ed 100644 --- a/app/views/RoomInfoView/index.tsx +++ b/app/views/RoomInfoView/index.tsx @@ -25,7 +25,7 @@ import { LISTENER } from '../../containers/Toast'; import EventEmitter from '../../utils/events'; import SafeAreaView from '../../containers/SafeAreaView'; import { goRoom } from '../../utils/goRoom'; -import Navigation from '../../lib/Navigation'; +import Navigation from '../../lib/navigation/appNavigation'; import Livechat from './Livechat'; import Channel from './Channel'; import Direct from './Direct'; diff --git a/app/views/RoomView/index.tsx b/app/views/RoomView/index.tsx index 491e7f780..7ff56c8b4 100644 --- a/app/views/RoomView/index.tsx +++ b/app/views/RoomView/index.tsx @@ -44,7 +44,7 @@ import { import { Review } from '../../utils/review'; import RoomClass from '../../lib/methods/subscriptions/room'; import { getUserSelector } from '../../selectors/login'; -import Navigation from '../../lib/Navigation'; +import Navigation from '../../lib/navigation/appNavigation'; import SafeAreaView from '../../containers/SafeAreaView'; import { withDimensions } from '../../dimensions'; import { getHeaderTitlePosition } from '../../containers/Header'; diff --git a/app/views/SidebarView/index.tsx b/app/views/SidebarView/index.tsx index d240e6cb3..67f1af9bc 100644 --- a/app/views/SidebarView/index.tsx +++ b/app/views/SidebarView/index.tsx @@ -15,7 +15,7 @@ import { themes } from '../../constants/colors'; import { withTheme } from '../../theme'; import { getUserSelector } from '../../selectors/login'; import SafeAreaView from '../../containers/SafeAreaView'; -import Navigation from '../../lib/Navigation'; +import Navigation from '../../lib/navigation/appNavigation'; import SidebarItem from './SidebarItem'; import styles from './styles'; import { DrawerParamList } from '../../stacks/types'; From bdf83e546efa14a2b0e42de137d69ae041c4e1ef Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Silva Date: Thu, 7 Apr 2022 11:10:03 -0300 Subject: [PATCH 4/9] Chore: Move constants away from rocketchat folder - Typescript (#4022) * create keys file and export all consts * fix import E2E_MESSAGE_TYPE * fix constants import * fix constants import * fix E2E_BANNER_TYPE import * fix E2E_ROOM_TYPES import * fix THEME_PREFERENCES_KEY import * fix CRASH_REPORT_KEY and ANALYTICS_EVENTS_KEY import * fix MIN_ROCKETCHAT_VERSION import * fix constantDisplayMode import * fix environment imports * fix links imports * fix localAuthentication imports * fix localPath imports * fix messagesStatus imports * fix messageTypeLoad imports * fix defaultSettings imports * fix tablet imports * update with todo for colors * move to lib folder * change constant/colors to constant --- app/containers/ActionSheet/ActionSheet.tsx | 2 +- app/containers/ActionSheet/Handle.tsx | 2 +- app/containers/ActionSheet/Item.tsx | 2 +- app/containers/ActivityIndicator.tsx | 2 +- app/containers/AppVersion.tsx | 2 +- app/containers/BackgroundContainer/index.tsx | 2 +- app/containers/Button/index.tsx | 2 +- app/containers/Check.tsx | 2 +- app/containers/EmojiPicker/TabBar.tsx | 2 +- app/containers/EmojiPicker/index.tsx | 2 +- app/containers/FormContainer.tsx | 2 +- app/containers/Header/index.tsx | 2 +- app/containers/HeaderButton/HeaderButtonItem.tsx | 2 +- .../InAppNotification/NotifierComponent.tsx | 2 +- app/containers/List/ListHeader.tsx | 2 +- app/containers/List/ListIcon.tsx | 2 +- app/containers/List/ListInfo.tsx | 2 +- app/containers/List/ListItem.tsx | 2 +- app/containers/List/ListSeparator.tsx | 2 +- app/containers/Loading.tsx | 2 +- app/containers/LoginServices.tsx | 2 +- app/containers/MessageActions/Header.tsx | 2 +- app/containers/MessageBox/CommandsPreview/Item.tsx | 2 +- app/containers/MessageBox/CommandsPreview/index.tsx | 2 +- app/containers/MessageBox/EmojiKeyboard.tsx | 2 +- .../MessageBox/Mentions/FixedMentionItem.tsx | 2 +- .../MessageBox/Mentions/MentionHeaderList.tsx | 4 ++-- app/containers/MessageBox/Mentions/MentionItem.tsx | 2 +- app/containers/MessageBox/Mentions/index.tsx | 2 +- app/containers/MessageBox/RecordAudio.tsx | 2 +- app/containers/MessageBox/ReplyPreview.tsx | 2 +- app/containers/MessageBox/buttons/BaseButton.tsx | 2 +- app/containers/MessageBox/buttons/SendButton.tsx | 2 +- app/containers/MessageBox/index.tsx | 2 +- app/containers/OrSeparator.tsx | 2 +- app/containers/Passcode/Base/Button.tsx | 2 +- app/containers/Passcode/Base/Dots.tsx | 2 +- app/containers/Passcode/Base/LockIcon.tsx | 2 +- app/containers/Passcode/Base/Locked.tsx | 2 +- app/containers/Passcode/Base/Subtitle.tsx | 2 +- app/containers/Passcode/Base/Title.tsx | 2 +- app/containers/Passcode/Base/index.tsx | 3 +-- app/containers/Passcode/PasscodeEnter.tsx | 2 +- app/containers/Passcode/utils.ts | 2 +- app/containers/ReactionsModal.tsx | 2 +- app/containers/RoomHeader/RoomHeader.tsx | 2 +- app/containers/RoomTypeIcon.tsx | 2 +- app/containers/SafeAreaView.tsx | 2 +- app/containers/SearchBox.tsx | 2 +- app/containers/SearchHeader.tsx | 2 +- app/containers/Status/Status.tsx | 2 +- app/containers/StatusBar.tsx | 2 +- app/containers/TextInput.tsx | 2 +- app/containers/ThreadDetails.tsx | 2 +- app/containers/Toast.tsx | 2 +- app/containers/TwoFactor/index.tsx | 2 +- app/containers/UIKit/DatePicker.tsx | 2 +- app/containers/UIKit/Input.tsx | 2 +- app/containers/UIKit/MultiSelect/Chips.tsx | 2 +- app/containers/UIKit/MultiSelect/Input.tsx | 2 +- app/containers/UIKit/MultiSelect/Items.tsx | 2 +- app/containers/UIKit/MultiSelect/index.tsx | 2 +- app/containers/UIKit/Overflow.tsx | 2 +- app/containers/UIKit/Section.tsx | 2 +- app/containers/UIKit/Select.tsx | 2 +- app/containers/UIKit/index.tsx | 2 +- app/containers/markdown/AtMention.tsx | 2 +- app/containers/markdown/BlockQuote.tsx | 2 +- app/containers/markdown/Emoji.tsx | 2 +- app/containers/markdown/Hashtag.tsx | 2 +- app/containers/markdown/Link.tsx | 2 +- app/containers/markdown/ListItem.tsx | 2 +- app/containers/markdown/Preview.tsx | 2 +- app/containers/markdown/Table.tsx | 2 +- app/containers/markdown/TableCell.tsx | 2 +- app/containers/markdown/TableRow.tsx | 2 +- app/containers/markdown/index.tsx | 2 +- app/containers/markdown/new/Code.tsx | 2 +- app/containers/markdown/new/Emoji.tsx | 2 +- app/containers/markdown/new/Heading.tsx | 2 +- app/containers/markdown/new/Image.tsx | 2 +- app/containers/markdown/new/InlineCode.tsx | 2 +- app/containers/markdown/new/Link.tsx | 2 +- app/containers/markdown/new/OrderedList.tsx | 2 +- app/containers/markdown/new/Paragraph.tsx | 2 +- app/containers/markdown/new/Plain.tsx | 2 +- app/containers/markdown/new/Quote.tsx | 2 +- app/containers/markdown/new/TaskList.tsx | 2 +- app/containers/markdown/new/UnorderedList.tsx | 2 +- app/containers/message/Attachments.tsx | 2 +- app/containers/message/Audio.tsx | 2 +- app/containers/message/Broadcast.tsx | 2 +- app/containers/message/CallButton.tsx | 2 +- .../message/Components/CollapsibleQuote/index.tsx | 2 +- app/containers/message/Content.tsx | 3 +-- app/containers/message/Discussion.tsx | 2 +- app/containers/message/Encrypted.tsx | 3 +-- app/containers/message/Image.tsx | 2 +- app/containers/message/Message.tsx | 2 +- app/containers/message/MessageError.tsx | 2 +- app/containers/message/Reactions.tsx | 2 +- app/containers/message/ReadReceipt.tsx | 2 +- app/containers/message/RepliedThread.tsx | 2 +- app/containers/message/Reply.tsx | 2 +- app/containers/message/Thread.tsx | 2 +- app/containers/message/Urls.tsx | 2 +- app/containers/message/User.tsx | 2 +- app/containers/message/Video.tsx | 2 +- app/containers/message/index.tsx | 3 +-- app/definitions/IMessage.ts | 2 +- app/definitions/IPreferences.ts | 2 +- app/ee/omnichannel/containers/OmnichannelStatus.tsx | 2 +- app/ee/omnichannel/views/QueueListView.tsx | 4 +--- app/index.tsx | 4 +--- app/{ => lib}/constants/colors.ts | 0 app/{ => lib}/constants/constantDisplayMode.ts | 0 .../settings.ts => lib/constants/defaultSettings.ts} | 2 +- app/{ => lib}/constants/environment.ts | 0 app/lib/constants/index.ts | 11 +++++++++++ app/lib/{constants.ts => constants/keys.ts} | 0 app/{ => lib}/constants/links.ts | 2 +- app/{ => lib}/constants/localAuthentication.ts | 0 app/{ => lib}/constants/localPath.ts | 0 app/{ => lib}/constants/messageTypeLoad.ts | 0 app/{ => lib}/constants/messagesStatus.ts | 2 +- app/{ => lib}/constants/tablet.ts | 0 app/lib/database/index.ts | 2 +- app/lib/encryption/encryption.ts | 6 +++--- app/lib/encryption/room.ts | 2 +- app/lib/methods/helpers/buildMessage.ts | 2 +- app/lib/methods/loadMessagesForRoom.ts | 2 +- app/lib/methods/loadNextMessages.ts | 2 +- app/lib/methods/loadSurroundingMessages.ts | 2 +- app/lib/methods/sendMessage.ts | 3 +-- app/lib/methods/subscriptions/rooms.ts | 2 +- app/lib/methods/updateMessages.ts | 2 +- app/lib/rocketchat/methods/getSettings.ts | 5 ++--- app/lib/rocketchat/methods/helpers.ts | 3 +-- app/lib/rocketchat/methods/logout.ts | 2 +- app/lib/rocketchat/services/connect.ts | 3 +-- app/notifications/push/index.ts | 2 +- app/presentation/DirectoryItem/index.tsx | 2 +- app/presentation/ImageViewer/ImageViewer.android.tsx | 2 +- app/presentation/ImageViewer/ImageViewer.tsx | 2 +- app/presentation/RoomItem/Actions.tsx | 3 +-- app/presentation/RoomItem/IconOrAvatar.js | 2 +- app/presentation/RoomItem/LastMessage.tsx | 3 +-- app/presentation/RoomItem/RoomItem.tsx | 2 +- app/presentation/RoomItem/Tag.tsx | 2 +- app/presentation/RoomItem/Title.tsx | 2 +- app/presentation/RoomItem/Touchable.tsx | 2 +- app/presentation/RoomItem/UpdatedAt.tsx | 2 +- app/presentation/RoomItem/Wrapper.tsx | 3 +-- app/presentation/ServerItem/index.tsx | 2 +- app/presentation/TextInput.tsx | 2 +- app/presentation/UnreadBadge/getUnreadStyle.test.js | 2 +- app/presentation/UnreadBadge/getUnreadStyle.ts | 2 +- app/presentation/UserItem.tsx | 2 +- app/reducers/settings.ts | 4 ++-- app/reducers/sortPreferences.test.ts | 2 +- app/reducers/sortPreferences.ts | 2 +- app/sagas/encryption.js | 2 +- app/sagas/init.js | 2 +- app/share.tsx | 2 +- app/stacks/InsideStack.tsx | 2 +- app/stacks/MasterDetailStack/ModalContainer.tsx | 2 +- app/theme.tsx | 2 +- app/utils/fileDownload/index.ts | 2 +- app/utils/localAuthentication.ts | 2 +- app/utils/log/index.ts | 2 +- app/utils/navigation/index.ts | 2 +- app/utils/openLink.ts | 2 +- app/utils/review.ts | 3 +-- app/utils/room.ts | 2 +- app/utils/theme.ts | 5 ++--- app/utils/touch.tsx | 2 +- app/views/AddExistingChannelView.tsx | 2 +- app/views/AttachmentView.tsx | 2 +- app/views/AuthLoadingView.tsx | 2 +- app/views/AutoTranslateView/index.tsx | 2 +- app/views/CannedResponseDetail.tsx | 2 +- .../CannedResponsesListView/CannedResponseItem.tsx | 2 +- .../CannedResponsesListView/Dropdown/DropdownItem.tsx | 2 +- app/views/CannedResponsesListView/Dropdown/index.tsx | 2 +- app/views/CannedResponsesListView/index.tsx | 2 +- app/views/ChangePasscodeView.tsx | 3 +-- app/views/CreateChannelView.tsx | 2 +- app/views/CreateDiscussionView/SelectChannel.tsx | 2 +- app/views/CreateDiscussionView/SelectUsers.tsx | 2 +- app/views/CreateDiscussionView/index.tsx | 3 +-- app/views/DefaultBrowserView.tsx | 2 +- app/views/DirectoryView/Options.tsx | 2 +- app/views/DirectoryView/index.tsx | 2 +- app/views/DiscussionsView/DiscussionDetails.tsx | 2 +- app/views/DiscussionsView/Item.stories.js | 2 +- app/views/DiscussionsView/Item.tsx | 2 +- app/views/DiscussionsView/index.tsx | 2 +- app/views/DisplayPrefsView.tsx | 3 +-- app/views/E2EEncryptionSecurityView.tsx | 2 +- app/views/E2EEnterYourPasswordView.tsx | 2 +- app/views/E2EHowItWorksView.tsx | 2 +- app/views/E2ESaveYourPasswordView.tsx | 3 +-- app/views/ForgotPasswordView.tsx | 2 +- app/views/ForwardLivechatView.tsx | 2 +- app/views/InviteUsersEditView/index.tsx | 2 +- app/views/InviteUsersView/index.tsx | 2 +- app/views/LanguageView/index.tsx | 2 +- app/views/LivechatEditView.tsx | 2 +- app/views/LoginView.tsx | 2 +- app/views/MarkdownTableView.tsx | 2 +- app/views/MessagesView/index.tsx | 2 +- app/views/ModalBlockView.tsx | 2 +- app/views/NewMessageView.tsx | 2 +- app/views/NewServerView/ServerInput/Item.tsx | 2 +- app/views/NewServerView/ServerInput/index.tsx | 2 +- app/views/NewServerView/index.tsx | 2 +- app/views/NotificationPreferencesView/index.tsx | 2 +- app/views/PickerView.tsx | 2 +- app/views/ProfileView/index.tsx | 2 +- app/views/ReadReceiptView/index.tsx | 2 +- app/views/RegisterView.tsx | 2 +- app/views/RoomActionsView/index.tsx | 3 +-- app/views/RoomInfoEditView/SwitchContainer.tsx | 2 +- app/views/RoomInfoEditView/index.tsx | 2 +- app/views/RoomInfoView/Direct.tsx | 2 +- app/views/RoomInfoView/Item.tsx | 2 +- app/views/RoomInfoView/Livechat.tsx | 2 +- app/views/RoomInfoView/index.tsx | 2 +- app/views/RoomMembersView/index.tsx | 2 +- app/views/RoomView/Banner.tsx | 2 +- app/views/RoomView/JoinCode.tsx | 2 +- app/views/RoomView/LeftButtons.tsx | 2 +- app/views/RoomView/List/NavBottomFAB.tsx | 2 +- app/views/RoomView/List/index.tsx | 2 +- app/views/RoomView/LoadMore/LoadMore.stories.js | 3 +-- app/views/RoomView/LoadMore/index.tsx | 3 +-- app/views/RoomView/ReactionPicker.tsx | 2 +- app/views/RoomView/Separator.tsx | 2 +- app/views/RoomView/UploadProgress.tsx | 2 +- app/views/RoomView/index.tsx | 4 +--- app/views/RoomView/services/getMoreMessages.ts | 2 +- app/views/RoomsListView/Header/Header.tsx | 2 +- app/views/RoomsListView/ListHeader/index.tsx | 3 +-- app/views/RoomsListView/ServerDropdown.tsx | 2 +- app/views/RoomsListView/index.tsx | 5 +---- app/views/ScreenLockConfigView.tsx | 3 +-- app/views/ScreenLockedView.tsx | 2 +- app/views/SearchMessagesView/index.tsx | 2 +- app/views/SecurityPrivacyView.tsx | 4 +--- app/views/SelectListView.tsx | 2 +- app/views/SelectedUsersView.tsx | 2 +- app/views/SetUsernameView.tsx | 2 +- app/views/SettingsView/index.tsx | 4 +--- app/views/ShareListView/Header/Header.ios.tsx | 2 +- app/views/ShareListView/Header/Header.tsx | 2 +- app/views/ShareListView/index.tsx | 2 +- app/views/ShareView/Header.tsx | 2 +- app/views/ShareView/Preview.tsx | 4 ++-- app/views/ShareView/Thumbs.tsx | 2 +- app/views/ShareView/index.tsx | 2 +- app/views/SidebarView/SidebarItem.tsx | 2 +- app/views/SidebarView/index.tsx | 2 +- app/views/Styles.js | 2 +- app/views/TeamChannelsView.tsx | 2 +- app/views/ThemeView.tsx | 3 +-- .../ThreadMessagesView/Dropdown/DropdownItem.tsx | 2 +- app/views/ThreadMessagesView/Dropdown/index.tsx | 2 +- app/views/ThreadMessagesView/Item.stories.js | 2 +- app/views/ThreadMessagesView/Item.tsx | 2 +- app/views/ThreadMessagesView/index.tsx | 2 +- app/views/UserNotificationPreferencesView/index.tsx | 2 +- app/views/UserPreferencesView/index.tsx | 2 +- app/views/WithoutServersView.tsx | 2 +- app/views/WorkspaceView/ServerAvatar.tsx | 2 +- app/views/WorkspaceView/index.tsx | 2 +- storybook/stories/Markdown.tsx | 2 +- storybook/stories/Message.js | 4 +--- storybook/stories/NewMarkdown.js | 2 +- storybook/stories/RoomItem.js | 3 +-- storybook/stories/UiKitMessage.js | 2 +- storybook/stories/UiKitModal.js | 2 +- 281 files changed, 290 insertions(+), 318 deletions(-) rename app/{ => lib}/constants/colors.ts (100%) rename app/{ => lib}/constants/constantDisplayMode.ts (100%) rename app/{constants/settings.ts => lib/constants/defaultSettings.ts} (99%) rename app/{ => lib}/constants/environment.ts (100%) create mode 100644 app/lib/constants/index.ts rename app/lib/{constants.ts => constants/keys.ts} (100%) rename app/{ => lib}/constants/links.ts (90%) rename app/{ => lib}/constants/localAuthentication.ts (100%) rename app/{ => lib}/constants/localPath.ts (100%) rename app/{ => lib}/constants/messageTypeLoad.ts (100%) rename app/{ => lib}/constants/messagesStatus.ts (50%) rename app/{ => lib}/constants/tablet.ts (100%) diff --git a/app/containers/ActionSheet/ActionSheet.tsx b/app/containers/ActionSheet/ActionSheet.tsx index 79303a593..673e515a1 100644 --- a/app/containers/ActionSheet/ActionSheet.tsx +++ b/app/containers/ActionSheet/ActionSheet.tsx @@ -7,7 +7,7 @@ import Animated, { Easing, Extrapolate, interpolateNode, Value } from 'react-nat import { useSafeAreaInsets } from 'react-native-safe-area-context'; import ScrollBottomSheet from 'react-native-scroll-bottom-sheet'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { useDimensions, useOrientation } from '../../dimensions'; import I18n from '../../i18n'; import { useTheme } from '../../theme'; diff --git a/app/containers/ActionSheet/Handle.tsx b/app/containers/ActionSheet/Handle.tsx index 1b2b6a62c..650d44ef5 100644 --- a/app/containers/ActionSheet/Handle.tsx +++ b/app/containers/ActionSheet/Handle.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { View } from 'react-native'; import styles from './styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { useTheme } from '../../theme'; export const Handle = React.memo(() => { diff --git a/app/containers/ActionSheet/Item.tsx b/app/containers/ActionSheet/Item.tsx index 9c281f8c1..1a1627006 100644 --- a/app/containers/ActionSheet/Item.tsx +++ b/app/containers/ActionSheet/Item.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { Text, View } from 'react-native'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { CustomIcon } from '../../lib/Icons'; import { useTheme } from '../../theme'; import { Button } from './Button'; diff --git a/app/containers/ActivityIndicator.tsx b/app/containers/ActivityIndicator.tsx index 701926416..6e4f2db0a 100644 --- a/app/containers/ActivityIndicator.tsx +++ b/app/containers/ActivityIndicator.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { ActivityIndicator, ActivityIndicatorProps, StyleSheet } from 'react-native'; import { useTheme } from '../theme'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; interface IActivityIndicator extends ActivityIndicatorProps { absolute?: boolean; diff --git a/app/containers/AppVersion.tsx b/app/containers/AppVersion.tsx index 217f46d44..bb1800f60 100644 --- a/app/containers/AppVersion.tsx +++ b/app/containers/AppVersion.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import sharedStyles from '../views/Styles'; import { getReadableVersion } from '../utils/deviceInfo'; import I18n from '../i18n'; diff --git a/app/containers/BackgroundContainer/index.tsx b/app/containers/BackgroundContainer/index.tsx index c9fc70d57..53636328c 100644 --- a/app/containers/BackgroundContainer/index.tsx +++ b/app/containers/BackgroundContainer/index.tsx @@ -3,7 +3,7 @@ import { ActivityIndicator, ImageBackground, StyleSheet, Text, View } from 'reac import { useTheme } from '../../theme'; import sharedStyles from '../../views/Styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; interface IBackgroundContainer { text?: string; diff --git a/app/containers/Button/index.tsx b/app/containers/Button/index.tsx index 8c99dccee..71d64e696 100644 --- a/app/containers/Button/index.tsx +++ b/app/containers/Button/index.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { StyleSheet, Text } from 'react-native'; import Touchable from 'react-native-platform-touchable'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import sharedStyles from '../../views/Styles'; import ActivityIndicator from '../ActivityIndicator'; diff --git a/app/containers/Check.tsx b/app/containers/Check.tsx index c51bc8b46..6a43cf9ad 100644 --- a/app/containers/Check.tsx +++ b/app/containers/Check.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { StyleSheet } from 'react-native'; import { CustomIcon } from '../lib/Icons'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import { useTheme } from '../theme'; const styles = StyleSheet.create({ diff --git a/app/containers/EmojiPicker/TabBar.tsx b/app/containers/EmojiPicker/TabBar.tsx index 2517d6d15..240c56ecd 100644 --- a/app/containers/EmojiPicker/TabBar.tsx +++ b/app/containers/EmojiPicker/TabBar.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Text, TouchableOpacity, View } from 'react-native'; import styles from './styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; interface ITabBarProps { goToPage: Function; diff --git a/app/containers/EmojiPicker/index.tsx b/app/containers/EmojiPicker/index.tsx index 5c67b06df..5a2a71bb8 100644 --- a/app/containers/EmojiPicker/index.tsx +++ b/app/containers/EmojiPicker/index.tsx @@ -15,7 +15,7 @@ import { emojisByCategory } from '../../emojis'; import protectedFunction from '../../lib/methods/helpers/protectedFunction'; import shortnameToUnicode from '../../utils/shortnameToUnicode'; import log from '../../utils/log'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { withTheme } from '../../theme'; import { IEmoji } from '../../definitions/IEmoji'; diff --git a/app/containers/FormContainer.tsx b/app/containers/FormContainer.tsx index 8c862b54d..3cdf0de7f 100644 --- a/app/containers/FormContainer.tsx +++ b/app/containers/FormContainer.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { ScrollView, ScrollViewProps, StyleSheet, View } from 'react-native'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import sharedStyles from '../views/Styles'; import scrollPersistTaps from '../utils/scrollPersistTaps'; import KeyboardView from '../presentation/KeyboardView'; diff --git a/app/containers/Header/index.tsx b/app/containers/Header/index.tsx index 17d888409..b9e2d1f43 100644 --- a/app/containers/Header/index.tsx +++ b/app/containers/Header/index.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { SafeAreaView } from 'react-native-safe-area-context'; import { StyleSheet, View } from 'react-native'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { themedHeader } from '../../utils/navigation'; import { isIOS, isTablet } from '../../utils/deviceInfo'; import { useTheme } from '../../theme'; diff --git a/app/containers/HeaderButton/HeaderButtonItem.tsx b/app/containers/HeaderButton/HeaderButtonItem.tsx index 987975db2..20ea46082 100644 --- a/app/containers/HeaderButton/HeaderButtonItem.tsx +++ b/app/containers/HeaderButton/HeaderButtonItem.tsx @@ -4,7 +4,7 @@ import Touchable from 'react-native-platform-touchable'; import { CustomIcon } from '../../lib/Icons'; import { useTheme } from '../../theme'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import sharedStyles from '../../views/Styles'; interface IHeaderButtonItem { diff --git a/app/containers/InAppNotification/NotifierComponent.tsx b/app/containers/InAppNotification/NotifierComponent.tsx index 5987c0c7a..6f886c010 100644 --- a/app/containers/InAppNotification/NotifierComponent.tsx +++ b/app/containers/InAppNotification/NotifierComponent.tsx @@ -8,7 +8,7 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context'; import Avatar from '../Avatar'; import { CustomIcon } from '../../lib/Icons'; import sharedStyles from '../../views/Styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { useTheme } from '../../theme'; import { ROW_HEIGHT } from '../../presentation/RoomItem'; import { goRoom } from '../../utils/goRoom'; diff --git a/app/containers/List/ListHeader.tsx b/app/containers/List/ListHeader.tsx index 469d4cec6..301961268 100644 --- a/app/containers/List/ListHeader.tsx +++ b/app/containers/List/ListHeader.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; import sharedStyles from '../../views/Styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import I18n from '../../i18n'; import { useTheme } from '../../theme'; import { PADDING_HORIZONTAL } from './constants'; diff --git a/app/containers/List/ListIcon.tsx b/app/containers/List/ListIcon.tsx index c134b1690..79e24ea66 100644 --- a/app/containers/List/ListIcon.tsx +++ b/app/containers/List/ListIcon.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { CustomIcon } from '../../lib/Icons'; import { useTheme } from '../../theme'; import { ICON_SIZE } from './constants'; diff --git a/app/containers/List/ListInfo.tsx b/app/containers/List/ListInfo.tsx index baac47ccc..1a8dc8910 100644 --- a/app/containers/List/ListInfo.tsx +++ b/app/containers/List/ListInfo.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; import sharedStyles from '../../views/Styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { useTheme } from '../../theme'; import { PADDING_HORIZONTAL } from './constants'; import I18n from '../../i18n'; diff --git a/app/containers/List/ListItem.tsx b/app/containers/List/ListItem.tsx index c09266a41..0fef43c2a 100644 --- a/app/containers/List/ListItem.tsx +++ b/app/containers/List/ListItem.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { I18nManager, StyleSheet, Text, View } from 'react-native'; import Touch from '../../utils/touch'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import sharedStyles from '../../views/Styles'; import { useTheme } from '../../theme'; import I18n from '../../i18n'; diff --git a/app/containers/List/ListSeparator.tsx b/app/containers/List/ListSeparator.tsx index f86dee196..d0e8d1cdd 100644 --- a/app/containers/List/ListSeparator.tsx +++ b/app/containers/List/ListSeparator.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { StyleSheet, View, ViewStyle } from 'react-native'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { useTheme } from '../../theme'; const styles = StyleSheet.create({ diff --git a/app/containers/Loading.tsx b/app/containers/Loading.tsx index 69cd6565a..93ad43be2 100644 --- a/app/containers/Loading.tsx +++ b/app/containers/Loading.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Animated, Modal, StyleSheet, View } from 'react-native'; import { withTheme } from '../theme'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; const styles = StyleSheet.create({ container: { diff --git a/app/containers/LoginServices.tsx b/app/containers/LoginServices.tsx index f087922d1..7872a417d 100644 --- a/app/containers/LoginServices.tsx +++ b/app/containers/LoginServices.tsx @@ -7,7 +7,7 @@ import { StackNavigationProp } from '@react-navigation/stack'; import { withTheme } from '../theme'; import sharedStyles from '../views/Styles'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import Button from './Button'; import OrSeparator from './OrSeparator'; import Touch from '../utils/touch'; diff --git a/app/containers/MessageActions/Header.tsx b/app/containers/MessageActions/Header.tsx index 82cbee2cc..943b40c09 100644 --- a/app/containers/MessageActions/Header.tsx +++ b/app/containers/MessageActions/Header.tsx @@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'; import { FlatList, StyleSheet, Text, View } from 'react-native'; import { useTheme } from '../../theme'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { CustomIcon } from '../../lib/Icons'; import shortnameToUnicode from '../../utils/shortnameToUnicode'; import CustomEmoji from '../EmojiPicker/CustomEmoji'; diff --git a/app/containers/MessageBox/CommandsPreview/Item.tsx b/app/containers/MessageBox/CommandsPreview/Item.tsx index e65ee70b7..a14a828aa 100644 --- a/app/containers/MessageBox/CommandsPreview/Item.tsx +++ b/app/containers/MessageBox/CommandsPreview/Item.tsx @@ -2,7 +2,7 @@ import FastImage from '@rocket.chat/react-native-fast-image'; import React, { useContext, useState } from 'react'; import { TouchableOpacity } from 'react-native'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { CustomIcon } from '../../../lib/Icons'; import { useTheme } from '../../../theme'; import ActivityIndicator from '../../ActivityIndicator'; diff --git a/app/containers/MessageBox/CommandsPreview/index.tsx b/app/containers/MessageBox/CommandsPreview/index.tsx index e5a94200a..924fc41e7 100644 --- a/app/containers/MessageBox/CommandsPreview/index.tsx +++ b/app/containers/MessageBox/CommandsPreview/index.tsx @@ -2,7 +2,7 @@ import { dequal } from 'dequal'; import React from 'react'; import { FlatList } from 'react-native'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { IPreviewItem } from '../../../definitions'; import { useTheme } from '../../../theme'; import styles from '../styles'; diff --git a/app/containers/MessageBox/EmojiKeyboard.tsx b/app/containers/MessageBox/EmojiKeyboard.tsx index c6e742170..e38660a9b 100644 --- a/app/containers/MessageBox/EmojiKeyboard.tsx +++ b/app/containers/MessageBox/EmojiKeyboard.tsx @@ -5,7 +5,7 @@ import { KeyboardRegistry } from 'react-native-ui-lib/keyboard'; import { store } from '../../lib/auxStore'; import EmojiPicker from '../EmojiPicker'; import styles from './styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { withTheme } from '../../theme'; import { IEmoji } from '../../definitions/IEmoji'; diff --git a/app/containers/MessageBox/Mentions/FixedMentionItem.tsx b/app/containers/MessageBox/Mentions/FixedMentionItem.tsx index 0b5693998..6846463b0 100644 --- a/app/containers/MessageBox/Mentions/FixedMentionItem.tsx +++ b/app/containers/MessageBox/Mentions/FixedMentionItem.tsx @@ -3,7 +3,7 @@ import { Text, TouchableOpacity } from 'react-native'; import styles from '../styles'; import I18n from '../../../i18n'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { useTheme } from '../../../theme'; interface IMessageBoxFixedMentionItem { diff --git a/app/containers/MessageBox/Mentions/MentionHeaderList.tsx b/app/containers/MessageBox/Mentions/MentionHeaderList.tsx index 4be2dcdcd..d0a0284e4 100644 --- a/app/containers/MessageBox/Mentions/MentionHeaderList.tsx +++ b/app/containers/MessageBox/Mentions/MentionHeaderList.tsx @@ -1,14 +1,14 @@ import React, { useContext } from 'react'; import { ActivityIndicator, Text, TouchableOpacity, View } from 'react-native'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import I18n from '../../../i18n'; import { CustomIcon } from '../../../lib/Icons'; import { useTheme } from '../../../theme'; import sharedStyles from '../../../views/Styles'; -import { MENTIONS_TRACKING_TYPE_CANNED } from '../constants'; import MessageboxContext from '../Context'; import styles from '../styles'; +import { MENTIONS_TRACKING_TYPE_CANNED } from '../constants'; interface IMentionHeaderList { trackingType: string; diff --git a/app/containers/MessageBox/Mentions/MentionItem.tsx b/app/containers/MessageBox/Mentions/MentionItem.tsx index 9daf4d47a..500ca8681 100644 --- a/app/containers/MessageBox/Mentions/MentionItem.tsx +++ b/app/containers/MessageBox/Mentions/MentionItem.tsx @@ -1,7 +1,7 @@ import React, { useContext } from 'react'; import { Text, TouchableOpacity } from 'react-native'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { IEmoji } from '../../../definitions/IEmoji'; import { useTheme } from '../../../theme'; import Avatar from '../../Avatar'; diff --git a/app/containers/MessageBox/Mentions/index.tsx b/app/containers/MessageBox/Mentions/index.tsx index c7bbd1539..80bee8979 100644 --- a/app/containers/MessageBox/Mentions/index.tsx +++ b/app/containers/MessageBox/Mentions/index.tsx @@ -5,7 +5,7 @@ import { dequal } from 'dequal'; import MentionHeaderList from './MentionHeaderList'; import styles from '../styles'; import MentionItem from './MentionItem'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { useTheme } from '../../../theme'; interface IMessageBoxMentions { diff --git a/app/containers/MessageBox/RecordAudio.tsx b/app/containers/MessageBox/RecordAudio.tsx index 3071d6310..ac717ffb2 100644 --- a/app/containers/MessageBox/RecordAudio.tsx +++ b/app/containers/MessageBox/RecordAudio.tsx @@ -7,7 +7,7 @@ import { activateKeepAwake, deactivateKeepAwake } from 'expo-keep-awake'; import styles from './styles'; import I18n from '../../i18n'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { CustomIcon } from '../../lib/Icons'; import { events, logEvent } from '../../utils/log'; diff --git a/app/containers/MessageBox/ReplyPreview.tsx b/app/containers/MessageBox/ReplyPreview.tsx index 24f426c17..27309fe93 100644 --- a/app/containers/MessageBox/ReplyPreview.tsx +++ b/app/containers/MessageBox/ReplyPreview.tsx @@ -6,7 +6,7 @@ import { connect } from 'react-redux'; import { MarkdownPreview } from '../markdown'; import { CustomIcon } from '../../lib/Icons'; import sharedStyles from '../../views/Styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { IMessage } from '../../definitions/IMessage'; import { useTheme } from '../../theme'; import { IApplicationState } from '../../definitions'; diff --git a/app/containers/MessageBox/buttons/BaseButton.tsx b/app/containers/MessageBox/buttons/BaseButton.tsx index be63c5934..6c9a36ae7 100644 --- a/app/containers/MessageBox/buttons/BaseButton.tsx +++ b/app/containers/MessageBox/buttons/BaseButton.tsx @@ -5,7 +5,7 @@ import styles from '../styles'; import i18n from '../../../i18n'; import { CustomIcon } from '../../../lib/Icons'; import { useTheme } from '../../../theme'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; interface IBaseButton { onPress(): void; diff --git a/app/containers/MessageBox/buttons/SendButton.tsx b/app/containers/MessageBox/buttons/SendButton.tsx index 2634307fd..e1dc19d43 100644 --- a/app/containers/MessageBox/buttons/SendButton.tsx +++ b/app/containers/MessageBox/buttons/SendButton.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { useTheme } from '../../../theme'; import BaseButton from './BaseButton'; diff --git a/app/containers/MessageBox/index.tsx b/app/containers/MessageBox/index.tsx index a087949c9..463fc11d9 100644 --- a/app/containers/MessageBox/index.tsx +++ b/app/containers/MessageBox/index.tsx @@ -20,7 +20,7 @@ import RecordAudio from './RecordAudio'; import I18n from '../../i18n'; import ReplyPreview from './ReplyPreview'; import debounce from '../../utils/debounce'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; // @ts-ignore // eslint-disable-next-line import/extensions,import/no-unresolved import LeftButtons from './LeftButtons'; diff --git a/app/containers/OrSeparator.tsx b/app/containers/OrSeparator.tsx index 5be1ee883..408ed8d3c 100644 --- a/app/containers/OrSeparator.tsx +++ b/app/containers/OrSeparator.tsx @@ -3,7 +3,7 @@ import { StyleSheet, Text, View } from 'react-native'; import I18n from '../i18n'; import sharedStyles from '../views/Styles'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; const styles = StyleSheet.create({ container: { diff --git a/app/containers/Passcode/Base/Button.tsx b/app/containers/Passcode/Base/Button.tsx index 26ef8eca1..a60b1b23a 100644 --- a/app/containers/Passcode/Base/Button.tsx +++ b/app/containers/Passcode/Base/Button.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Text } from 'react-native'; import styles from './styles'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import Touch from '../../../utils/touch'; import { CustomIcon } from '../../../lib/Icons'; import { useTheme } from '../../../theme'; diff --git a/app/containers/Passcode/Base/Dots.tsx b/app/containers/Passcode/Base/Dots.tsx index 25e41d6cd..378f78b0e 100644 --- a/app/containers/Passcode/Base/Dots.tsx +++ b/app/containers/Passcode/Base/Dots.tsx @@ -3,7 +3,7 @@ import { View } from 'react-native'; import range from 'lodash/range'; import styles from './styles'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { useTheme } from '../../../theme'; const SIZE_EMPTY = 12; diff --git a/app/containers/Passcode/Base/LockIcon.tsx b/app/containers/Passcode/Base/LockIcon.tsx index ea795e8eb..975124386 100644 --- a/app/containers/Passcode/Base/LockIcon.tsx +++ b/app/containers/Passcode/Base/LockIcon.tsx @@ -3,7 +3,7 @@ import { View } from 'react-native'; import { Row } from 'react-native-easy-grid'; import styles from './styles'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { CustomIcon } from '../../../lib/Icons'; import { useTheme } from '../../../theme'; diff --git a/app/containers/Passcode/Base/Locked.tsx b/app/containers/Passcode/Base/Locked.tsx index 6b9381fdf..a78be5ac4 100644 --- a/app/containers/Passcode/Base/Locked.tsx +++ b/app/containers/Passcode/Base/Locked.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from 'react'; import { Grid } from 'react-native-easy-grid'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { resetAttempts } from '../../../utils/localAuthentication'; import { TYPE } from '../constants'; import { getDiff, getLockedUntil } from '../utils'; diff --git a/app/containers/Passcode/Base/Subtitle.tsx b/app/containers/Passcode/Base/Subtitle.tsx index 766cfcd7a..e98615d45 100644 --- a/app/containers/Passcode/Base/Subtitle.tsx +++ b/app/containers/Passcode/Base/Subtitle.tsx @@ -3,7 +3,7 @@ import { Text, View } from 'react-native'; import { Row } from 'react-native-easy-grid'; import styles from './styles'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { useTheme } from '../../../theme'; interface IPasscodeSubtitle { diff --git a/app/containers/Passcode/Base/Title.tsx b/app/containers/Passcode/Base/Title.tsx index b66b861a9..8b8aa9578 100644 --- a/app/containers/Passcode/Base/Title.tsx +++ b/app/containers/Passcode/Base/Title.tsx @@ -3,7 +3,7 @@ import { Text, View } from 'react-native'; import { Row } from 'react-native-easy-grid'; import styles from './styles'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { useTheme } from '../../../theme'; interface IPasscodeTitle { diff --git a/app/containers/Passcode/Base/index.tsx b/app/containers/Passcode/Base/index.tsx index 3a1bd3f73..940c5987f 100644 --- a/app/containers/Passcode/Base/index.tsx +++ b/app/containers/Passcode/Base/index.tsx @@ -9,8 +9,7 @@ import styles from './styles'; import Button from './Button'; import Dots from './Dots'; import { TYPE } from '../constants'; -import { themes } from '../../../constants/colors'; -import { PASSCODE_LENGTH } from '../../../constants/localAuthentication'; +import { PASSCODE_LENGTH, themes } from '../../../lib/constants'; import { useTheme } from '../../../theme'; import LockIcon from './LockIcon'; import Title from './Title'; diff --git a/app/containers/Passcode/PasscodeEnter.tsx b/app/containers/Passcode/PasscodeEnter.tsx index a803bdeb4..992877c7d 100644 --- a/app/containers/Passcode/PasscodeEnter.tsx +++ b/app/containers/Passcode/PasscodeEnter.tsx @@ -7,7 +7,7 @@ import { sha256 } from 'js-sha256'; import Base, { IBase } from './Base'; import Locked from './Base/Locked'; 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 '../../lib/constants'; import { biometryAuth, resetAttempts } from '../../utils/localAuthentication'; import { getDiff, getLockedUntil } from './utils'; import { useUserPreferences } from '../../lib/methods/userPreferences'; diff --git a/app/containers/Passcode/utils.ts b/app/containers/Passcode/utils.ts index 4c6f21a7d..5bc3b8c3f 100644 --- a/app/containers/Passcode/utils.ts +++ b/app/containers/Passcode/utils.ts @@ -1,7 +1,7 @@ import AsyncStorage from '@react-native-community/async-storage'; import moment from 'moment'; -import { LOCKED_OUT_TIMER_KEY, TIME_TO_LOCK } from '../../constants/localAuthentication'; +import { LOCKED_OUT_TIMER_KEY, TIME_TO_LOCK } from '../../lib/constants'; export const getLockedUntil = async () => { const t = await AsyncStorage.getItem(LOCKED_OUT_TIMER_KEY); diff --git a/app/containers/ReactionsModal.tsx b/app/containers/ReactionsModal.tsx index 2bbd9fa4f..522448c0a 100644 --- a/app/containers/ReactionsModal.tsx +++ b/app/containers/ReactionsModal.tsx @@ -7,7 +7,7 @@ import Emoji from './message/Emoji'; import I18n from '../i18n'; import { CustomIcon } from '../lib/Icons'; import sharedStyles from '../views/Styles'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import { useTheme, withTheme } from '../theme'; import { TGetCustomEmoji } from '../definitions/IEmoji'; import { TMessageModel, ILoggedUser } from '../definitions'; diff --git a/app/containers/RoomHeader/RoomHeader.tsx b/app/containers/RoomHeader/RoomHeader.tsx index 2ee96db45..f764c6421 100644 --- a/app/containers/RoomHeader/RoomHeader.tsx +++ b/app/containers/RoomHeader/RoomHeader.tsx @@ -3,7 +3,7 @@ import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'; import I18n from '../../i18n'; import sharedStyles from '../../views/Styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { MarkdownPreview } from '../markdown'; import RoomTypeIcon from '../RoomTypeIcon'; import { TUserStatus } from '../../definitions'; diff --git a/app/containers/RoomTypeIcon.tsx b/app/containers/RoomTypeIcon.tsx index ad9b63e1f..7a87ca9d5 100644 --- a/app/containers/RoomTypeIcon.tsx +++ b/app/containers/RoomTypeIcon.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { StyleSheet, ViewStyle } from 'react-native'; import { CustomIcon } from '../lib/Icons'; -import { STATUS_COLORS, themes } from '../constants/colors'; +import { STATUS_COLORS, themes } from '../lib/constants'; import Status from './Status/Status'; import { withTheme } from '../theme'; import { TUserStatus } from '../definitions'; diff --git a/app/containers/SafeAreaView.tsx b/app/containers/SafeAreaView.tsx index 2ffae53ec..74a40ef05 100644 --- a/app/containers/SafeAreaView.tsx +++ b/app/containers/SafeAreaView.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { StyleSheet, ViewProps } from 'react-native'; import { SafeAreaView as SafeAreaContext } from 'react-native-safe-area-context'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import { useTheme } from '../theme'; const styles = StyleSheet.create({ diff --git a/app/containers/SearchBox.tsx b/app/containers/SearchBox.tsx index e19cd5343..2dbda29cd 100644 --- a/app/containers/SearchBox.tsx +++ b/app/containers/SearchBox.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { StyleSheet, Text, TextInput as RNTextInput, TextInputProps, View } from 'react-native'; import Touchable from 'react-native-platform-touchable'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import I18n from '../i18n'; import { CustomIcon } from '../lib/Icons'; import TextInput from '../presentation/TextInput'; diff --git a/app/containers/SearchHeader.tsx b/app/containers/SearchHeader.tsx index 8d3c81416..589ef1d2b 100644 --- a/app/containers/SearchHeader.tsx +++ b/app/containers/SearchHeader.tsx @@ -4,7 +4,7 @@ import { StyleSheet, View } from 'react-native'; import I18n from '../i18n'; import { useTheme } from '../theme'; import sharedStyles from '../views/Styles'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import TextInput from '../presentation/TextInput'; import { isIOS, isTablet } from '../utils/deviceInfo'; import { useOrientation } from '../dimensions'; diff --git a/app/containers/Status/Status.tsx b/app/containers/Status/Status.tsx index 860f79601..b23b01dd9 100644 --- a/app/containers/Status/Status.tsx +++ b/app/containers/Status/Status.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { StyleProp, TextStyle } from 'react-native'; import { CustomIcon } from '../../lib/Icons'; -import { STATUS_COLORS } from '../../constants/colors'; +import { STATUS_COLORS } from '../../lib/constants'; import { IStatus } from './definition'; const Status = React.memo(({ style, status = 'offline', size = 32, ...props }: Omit) => { diff --git a/app/containers/StatusBar.tsx b/app/containers/StatusBar.tsx index e54eb46e1..03349c92a 100644 --- a/app/containers/StatusBar.tsx +++ b/app/containers/StatusBar.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { StatusBar as StatusBarRN } from 'react-native'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import { useTheme } from '../theme'; const supportedStyles = { diff --git a/app/containers/TextInput.tsx b/app/containers/TextInput.tsx index 0224a6ef5..553206a08 100644 --- a/app/containers/TextInput.tsx +++ b/app/containers/TextInput.tsx @@ -4,7 +4,7 @@ import Touchable from 'react-native-platform-touchable'; import sharedStyles from '../views/Styles'; import TextInput from '../presentation/TextInput'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import { CustomIcon } from '../lib/Icons'; import ActivityIndicator from './ActivityIndicator'; diff --git a/app/containers/ThreadDetails.tsx b/app/containers/ThreadDetails.tsx index 081397ef0..64a65d42a 100644 --- a/app/containers/ThreadDetails.tsx +++ b/app/containers/ThreadDetails.tsx @@ -3,7 +3,7 @@ import { StyleSheet, Text, View, ViewStyle } from 'react-native'; import Touchable from 'react-native-platform-touchable'; import { CustomIcon } from '../lib/Icons'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import sharedStyles from '../views/Styles'; import { useTheme } from '../theme'; import { TThreadModel } from '../definitions/IThread'; diff --git a/app/containers/Toast.tsx b/app/containers/Toast.tsx index ba1598f90..c19af1383 100644 --- a/app/containers/Toast.tsx +++ b/app/containers/Toast.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { StyleSheet } from 'react-native'; import EasyToast from 'react-native-easy-toast'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import sharedStyles from '../views/Styles'; import EventEmitter from '../utils/events'; import { withTheme } from '../theme'; diff --git a/app/containers/TwoFactor/index.tsx b/app/containers/TwoFactor/index.tsx index 200095b47..6509f57d3 100644 --- a/app/containers/TwoFactor/index.tsx +++ b/app/containers/TwoFactor/index.tsx @@ -10,7 +10,7 @@ import TextInput from '../TextInput'; import I18n from '../../i18n'; import EventEmitter from '../../utils/events'; import { useTheme } from '../../theme'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import Button from '../Button'; import sharedStyles from '../../views/Styles'; import RocketChat from '../../lib/rocketchat'; diff --git a/app/containers/UIKit/DatePicker.tsx b/app/containers/UIKit/DatePicker.tsx index 69ebb1296..59fb576f1 100644 --- a/app/containers/UIKit/DatePicker.tsx +++ b/app/containers/UIKit/DatePicker.tsx @@ -7,7 +7,7 @@ import moment from 'moment'; import Button from '../Button'; import { textParser } from './utils'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import sharedStyles from '../../views/Styles'; import { CustomIcon } from '../../lib/Icons'; import { isAndroid } from '../../utils/deviceInfo'; diff --git a/app/containers/UIKit/Input.tsx b/app/containers/UIKit/Input.tsx index b3492e447..70538701b 100644 --- a/app/containers/UIKit/Input.tsx +++ b/app/containers/UIKit/Input.tsx @@ -3,7 +3,7 @@ import { StyleSheet, Text, View } from 'react-native'; import { BLOCK_CONTEXT } from '@rocket.chat/ui-kit'; import sharedStyles from '../../views/Styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { IInput } from './interfaces'; const styles = StyleSheet.create({ diff --git a/app/containers/UIKit/MultiSelect/Chips.tsx b/app/containers/UIKit/MultiSelect/Chips.tsx index 7367bd497..49ebf1633 100644 --- a/app/containers/UIKit/MultiSelect/Chips.tsx +++ b/app/containers/UIKit/MultiSelect/Chips.tsx @@ -3,7 +3,7 @@ import { Text, View } from 'react-native'; import Touchable from 'react-native-platform-touchable'; import FastImage from '@rocket.chat/react-native-fast-image'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { textParser } from '../utils'; import { CustomIcon } from '../../../lib/Icons'; import styles from './styles'; diff --git a/app/containers/UIKit/MultiSelect/Input.tsx b/app/containers/UIKit/MultiSelect/Input.tsx index 00c5b20a1..3f270a0a7 100644 --- a/app/containers/UIKit/MultiSelect/Input.tsx +++ b/app/containers/UIKit/MultiSelect/Input.tsx @@ -3,7 +3,7 @@ import { Text, View } from 'react-native'; import Touchable from 'react-native-platform-touchable'; import { CustomIcon } from '../../../lib/Icons'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import ActivityIndicator from '../../ActivityIndicator'; import styles from './styles'; diff --git a/app/containers/UIKit/MultiSelect/Items.tsx b/app/containers/UIKit/MultiSelect/Items.tsx index 339139c1f..4e9265d24 100644 --- a/app/containers/UIKit/MultiSelect/Items.tsx +++ b/app/containers/UIKit/MultiSelect/Items.tsx @@ -6,7 +6,7 @@ import FastImage from '@rocket.chat/react-native-fast-image'; import Check from '../../Check'; import * as List from '../../List'; import { textParser } from '../utils'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import styles from './styles'; import { IItemData } from '.'; diff --git a/app/containers/UIKit/MultiSelect/index.tsx b/app/containers/UIKit/MultiSelect/index.tsx index 57ac91bf3..bb7c67e7e 100644 --- a/app/containers/UIKit/MultiSelect/index.tsx +++ b/app/containers/UIKit/MultiSelect/index.tsx @@ -15,7 +15,7 @@ import { BLOCK_CONTEXT } from '@rocket.chat/ui-kit'; import Button from '../../Button'; import TextInput from '../../TextInput'; import { textParser } from '../utils'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import I18n from '../../../i18n'; import { isIOS } from '../../../utils/deviceInfo'; import { useTheme } from '../../../theme'; diff --git a/app/containers/UIKit/Overflow.tsx b/app/containers/UIKit/Overflow.tsx index 2d1f4c8b1..e3041370c 100644 --- a/app/containers/UIKit/Overflow.tsx +++ b/app/containers/UIKit/Overflow.tsx @@ -5,7 +5,7 @@ import Touchable from 'react-native-platform-touchable'; import { CustomIcon } from '../../lib/Icons'; import ActivityIndicator from '../ActivityIndicator'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { useTheme } from '../../theme'; import { BUTTON_HIT_SLOP } from '../message/utils'; import * as List from '../List'; diff --git a/app/containers/UIKit/Section.tsx b/app/containers/UIKit/Section.tsx index 5630b9660..ce549060d 100644 --- a/app/containers/UIKit/Section.tsx +++ b/app/containers/UIKit/Section.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; import { BLOCK_CONTEXT } from '@rocket.chat/ui-kit'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { IAccessoryComponent, IFields, ISection } from './interfaces'; import { useTheme } from '../../theme'; diff --git a/app/containers/UIKit/Select.tsx b/app/containers/UIKit/Select.tsx index c2b213ac2..1e00ecc8b 100644 --- a/app/containers/UIKit/Select.tsx +++ b/app/containers/UIKit/Select.tsx @@ -3,7 +3,7 @@ import { StyleSheet } from 'react-native'; import RNPickerSelect from 'react-native-picker-select'; import sharedStyles from '../../views/Styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { CustomIcon } from '../../lib/Icons'; import { textParser } from './utils'; import { isAndroid, isIOS } from '../../utils/deviceInfo'; diff --git a/app/containers/UIKit/index.tsx b/app/containers/UIKit/index.tsx index 8e7775a20..14ee93c25 100644 --- a/app/containers/UIKit/index.tsx +++ b/app/containers/UIKit/index.tsx @@ -7,7 +7,7 @@ import Markdown, { MarkdownPreview } from '../markdown'; import Button from '../Button'; import TextInput from '../TextInput'; import { textParser, useBlockContext } from './utils'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import sharedStyles from '../../views/Styles'; import { Divider } from './Divider'; import { Section } from './Section'; diff --git a/app/containers/markdown/AtMention.tsx b/app/containers/markdown/AtMention.tsx index 707b7994d..2402ff087 100644 --- a/app/containers/markdown/AtMention.tsx +++ b/app/containers/markdown/AtMention.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { StyleProp, Text, TextStyle } from 'react-native'; import { useTheme } from '../../theme'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import styles from './styles'; import { events, logEvent } from '../../utils/log'; import { IUserMention } from './interfaces'; diff --git a/app/containers/markdown/BlockQuote.tsx b/app/containers/markdown/BlockQuote.tsx index aa67c0e3d..5c3e1757a 100644 --- a/app/containers/markdown/BlockQuote.tsx +++ b/app/containers/markdown/BlockQuote.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { View } from 'react-native'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import styles from './styles'; interface IBlockQuote { diff --git a/app/containers/markdown/Emoji.tsx b/app/containers/markdown/Emoji.tsx index f5672a599..061661388 100644 --- a/app/containers/markdown/Emoji.tsx +++ b/app/containers/markdown/Emoji.tsx @@ -3,7 +3,7 @@ import { Text } from 'react-native'; import shortnameToUnicode from '../../utils/shortnameToUnicode'; import CustomEmoji from '../EmojiPicker/CustomEmoji'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import styles from './styles'; interface IEmoji { diff --git a/app/containers/markdown/Hashtag.tsx b/app/containers/markdown/Hashtag.tsx index 482740ed1..6a3899960 100644 --- a/app/containers/markdown/Hashtag.tsx +++ b/app/containers/markdown/Hashtag.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { StyleProp, Text, TextStyle } from 'react-native'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { useTheme } from '../../theme'; import { IUserChannel } from './interfaces'; import styles from './styles'; diff --git a/app/containers/markdown/Link.tsx b/app/containers/markdown/Link.tsx index 0020d4828..a74443ab6 100644 --- a/app/containers/markdown/Link.tsx +++ b/app/containers/markdown/Link.tsx @@ -3,7 +3,7 @@ import { Text } from 'react-native'; import Clipboard from '@react-native-clipboard/clipboard'; import styles from './styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { LISTENER } from '../Toast'; import EventEmitter from '../../utils/events'; import I18n from '../../i18n'; diff --git a/app/containers/markdown/ListItem.tsx b/app/containers/markdown/ListItem.tsx index f822bd87a..c109e69d3 100644 --- a/app/containers/markdown/ListItem.tsx +++ b/app/containers/markdown/ListItem.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; const style = StyleSheet.create({ container: { diff --git a/app/containers/markdown/Preview.tsx b/app/containers/markdown/Preview.tsx index fd7519643..65262da72 100644 --- a/app/containers/markdown/Preview.tsx +++ b/app/containers/markdown/Preview.tsx @@ -3,7 +3,7 @@ import { Text, TextStyle } from 'react-native'; import removeMarkdown from 'remove-markdown'; import shortnameToUnicode from '../../utils/shortnameToUnicode'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { formatText } from './formatText'; import { useTheme } from '../../theme'; import styles from './styles'; diff --git a/app/containers/markdown/Table.tsx b/app/containers/markdown/Table.tsx index 39ca2f3a9..7f1d07a51 100644 --- a/app/containers/markdown/Table.tsx +++ b/app/containers/markdown/Table.tsx @@ -5,7 +5,7 @@ import { CELL_WIDTH } from './TableCell'; import styles from './styles'; import Navigation from '../../lib/navigation/appNavigation'; import I18n from '../../i18n'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; interface ITable { children: React.ReactElement | null; diff --git a/app/containers/markdown/TableCell.tsx b/app/containers/markdown/TableCell.tsx index bc8c89b84..dba820b96 100644 --- a/app/containers/markdown/TableCell.tsx +++ b/app/containers/markdown/TableCell.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { Text, View, ViewStyle } from 'react-native'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import styles from './styles'; interface ITableCell { diff --git a/app/containers/markdown/TableRow.tsx b/app/containers/markdown/TableRow.tsx index 7874c48d7..bd001fb6e 100644 --- a/app/containers/markdown/TableRow.tsx +++ b/app/containers/markdown/TableRow.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { View, ViewStyle } from 'react-native'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import styles from './styles'; interface ITableRow { diff --git a/app/containers/markdown/index.tsx b/app/containers/markdown/index.tsx index e4c942d1e..f1360c810 100644 --- a/app/containers/markdown/index.tsx +++ b/app/containers/markdown/index.tsx @@ -5,7 +5,6 @@ import Renderer from 'commonmark-react-renderer'; import { MarkdownAST } from '@rocket.chat/message-parser'; import I18n from '../../i18n'; -import { themes } from '../../constants/colors'; import MarkdownLink from './Link'; import MarkdownList from './List'; import MarkdownListItem from './ListItem'; @@ -24,6 +23,7 @@ import { formatText } from './formatText'; import { IUserMention, IUserChannel, TOnLinkPress } from './interfaces'; import { TGetCustomEmoji } from '../../definitions/IEmoji'; import { formatHyperlink } from './formatHyperlink'; +import { themes } from '../../lib/constants'; export { default as MarkdownPreview } from './Preview'; diff --git a/app/containers/markdown/new/Code.tsx b/app/containers/markdown/new/Code.tsx index f3e060125..f8303a2b6 100644 --- a/app/containers/markdown/new/Code.tsx +++ b/app/containers/markdown/new/Code.tsx @@ -3,7 +3,7 @@ import { Text } from 'react-native'; import { Code as CodeProps } from '@rocket.chat/message-parser'; import styles from '../styles'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { useTheme } from '../../../theme'; import CodeLine from './CodeLine'; diff --git a/app/containers/markdown/new/Emoji.tsx b/app/containers/markdown/new/Emoji.tsx index 2d03ab08a..9d101c4ff 100644 --- a/app/containers/markdown/new/Emoji.tsx +++ b/app/containers/markdown/new/Emoji.tsx @@ -3,7 +3,7 @@ import { Text } from 'react-native'; import { Emoji as EmojiProps } from '@rocket.chat/message-parser'; import shortnameToUnicode from '../../../utils/shortnameToUnicode'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { useTheme } from '../../../theme'; import styles from '../styles'; import CustomEmoji from '../../EmojiPicker/CustomEmoji'; diff --git a/app/containers/markdown/new/Heading.tsx b/app/containers/markdown/new/Heading.tsx index a949f52c8..56db6a7fd 100644 --- a/app/containers/markdown/new/Heading.tsx +++ b/app/containers/markdown/new/Heading.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Text } from 'react-native'; import { Heading as HeadingProps } from '@rocket.chat/message-parser'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import styles from '../styles'; import { useTheme } from '../../../theme'; diff --git a/app/containers/markdown/new/Image.tsx b/app/containers/markdown/new/Image.tsx index 94bcfac91..00d1b3e9d 100644 --- a/app/containers/markdown/new/Image.tsx +++ b/app/containers/markdown/new/Image.tsx @@ -5,7 +5,7 @@ import * as Progress from 'react-native-progress'; import FastImage from '@rocket.chat/react-native-fast-image'; import { useTheme } from '../../../theme'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import styles from '../../message/styles'; interface IImageProps { diff --git a/app/containers/markdown/new/InlineCode.tsx b/app/containers/markdown/new/InlineCode.tsx index 123eca379..c66996db5 100644 --- a/app/containers/markdown/new/InlineCode.tsx +++ b/app/containers/markdown/new/InlineCode.tsx @@ -3,7 +3,7 @@ import { Text } from 'react-native'; import { InlineCode as InlineCodeProps } from '@rocket.chat/message-parser'; import styles from '../styles'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { useTheme } from '../../../theme'; interface IInlineCodeProps { diff --git a/app/containers/markdown/new/Link.tsx b/app/containers/markdown/new/Link.tsx index 3a8a03b67..096d9e7f0 100644 --- a/app/containers/markdown/new/Link.tsx +++ b/app/containers/markdown/new/Link.tsx @@ -9,7 +9,7 @@ import { LISTENER } from '../../Toast'; import { useTheme } from '../../../theme'; import openLink from '../../../utils/openLink'; import EventEmitter from '../../../utils/events'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import Strike from './Strike'; import Italic from './Italic'; import Bold from './Bold'; diff --git a/app/containers/markdown/new/OrderedList.tsx b/app/containers/markdown/new/OrderedList.tsx index d4226c54e..b71c086ff 100644 --- a/app/containers/markdown/new/OrderedList.tsx +++ b/app/containers/markdown/new/OrderedList.tsx @@ -4,7 +4,7 @@ import { OrderedList as OrderedListProps } from '@rocket.chat/message-parser'; import Inline from './Inline'; import styles from '../styles'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { useTheme } from '../../../theme'; interface IOrderedListProps { diff --git a/app/containers/markdown/new/Paragraph.tsx b/app/containers/markdown/new/Paragraph.tsx index 93cb81e44..c58d4be5d 100644 --- a/app/containers/markdown/new/Paragraph.tsx +++ b/app/containers/markdown/new/Paragraph.tsx @@ -5,7 +5,7 @@ import { Paragraph as ParagraphProps } from '@rocket.chat/message-parser'; import Inline from './Inline'; import styles from '../styles'; import { useTheme } from '../../../theme'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; interface IParagraphProps { value: ParagraphProps['value']; diff --git a/app/containers/markdown/new/Plain.tsx b/app/containers/markdown/new/Plain.tsx index 784bef63a..c63c725b9 100644 --- a/app/containers/markdown/new/Plain.tsx +++ b/app/containers/markdown/new/Plain.tsx @@ -4,7 +4,7 @@ import { Plain as PlainProps } from '@rocket.chat/message-parser'; import styles from '../styles'; import { useTheme } from '../../../theme'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; interface IPlainProps { value: PlainProps['value']; diff --git a/app/containers/markdown/new/Quote.tsx b/app/containers/markdown/new/Quote.tsx index d3005845a..8578097b3 100644 --- a/app/containers/markdown/new/Quote.tsx +++ b/app/containers/markdown/new/Quote.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { View } from 'react-native'; import { Quote as QuoteProps } from '@rocket.chat/message-parser'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { useTheme } from '../../../theme'; import styles from '../styles'; import Paragraph from './Paragraph'; diff --git a/app/containers/markdown/new/TaskList.tsx b/app/containers/markdown/new/TaskList.tsx index 4359ba42c..8104ba5e3 100644 --- a/app/containers/markdown/new/TaskList.tsx +++ b/app/containers/markdown/new/TaskList.tsx @@ -4,7 +4,7 @@ import { Tasks as TasksProps } from '@rocket.chat/message-parser'; import Inline from './Inline'; import styles from '../styles'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { useTheme } from '../../../theme'; interface ITasksProps { diff --git a/app/containers/markdown/new/UnorderedList.tsx b/app/containers/markdown/new/UnorderedList.tsx index 09e16cdc7..8df46edf7 100644 --- a/app/containers/markdown/new/UnorderedList.tsx +++ b/app/containers/markdown/new/UnorderedList.tsx @@ -4,7 +4,7 @@ import { View, Text } from 'react-native'; import Inline from './Inline'; import styles from '../styles'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { useTheme } from '../../../theme'; interface IUnorderedListProps { diff --git a/app/containers/message/Attachments.tsx b/app/containers/message/Attachments.tsx index 3989c212a..397620e1d 100644 --- a/app/containers/message/Attachments.tsx +++ b/app/containers/message/Attachments.tsx @@ -14,7 +14,7 @@ import { useTheme } from '../../theme'; import { IAttachment } from '../../definitions'; import CollapsibleQuote from './Components/CollapsibleQuote'; import openLink from '../../utils/openLink'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; export type TElement = { type: string; diff --git a/app/containers/message/Audio.tsx b/app/containers/message/Audio.tsx index 30d564098..c1a129459 100644 --- a/app/containers/message/Audio.tsx +++ b/app/containers/message/Audio.tsx @@ -11,7 +11,7 @@ import Touchable from './Touchable'; import Markdown from '../markdown'; import { CustomIcon } from '../../lib/Icons'; import sharedStyles from '../../views/Styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { isAndroid, isIOS } from '../../utils/deviceInfo'; import MessageContext from './Context'; import ActivityIndicator from '../ActivityIndicator'; diff --git a/app/containers/message/Broadcast.tsx b/app/containers/message/Broadcast.tsx index 267b62822..6a0efdaf8 100644 --- a/app/containers/message/Broadcast.tsx +++ b/app/containers/message/Broadcast.tsx @@ -6,7 +6,7 @@ import { CustomIcon } from '../../lib/Icons'; import styles from './styles'; import { BUTTON_HIT_SLOP } from './utils'; import I18n from '../../i18n'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import MessageContext from './Context'; import { IMessageBroadcast } from './interfaces'; import { useTheme } from '../../theme'; diff --git a/app/containers/message/CallButton.tsx b/app/containers/message/CallButton.tsx index 7df5a7d12..240e56189 100644 --- a/app/containers/message/CallButton.tsx +++ b/app/containers/message/CallButton.tsx @@ -6,7 +6,7 @@ import { BUTTON_HIT_SLOP } from './utils'; import styles from './styles'; import I18n from '../../i18n'; import { CustomIcon } from '../../lib/Icons'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { IMessageCallButton } from './interfaces'; import { useTheme } from '../../theme'; diff --git a/app/containers/message/Components/CollapsibleQuote/index.tsx b/app/containers/message/Components/CollapsibleQuote/index.tsx index 484e690ba..2def3340c 100644 --- a/app/containers/message/Components/CollapsibleQuote/index.tsx +++ b/app/containers/message/Components/CollapsibleQuote/index.tsx @@ -3,7 +3,7 @@ import { dequal } from 'dequal'; import React, { useContext, useState } from 'react'; import { StyleSheet, Text, View } from 'react-native'; -import { themes } from '../../../../constants/colors'; +import { themes } from '../../../../lib/constants'; import { IAttachment } from '../../../../definitions/IAttachment'; import { TGetCustomEmoji } from '../../../../definitions/IEmoji'; import { CustomIcon } from '../../../../lib/Icons'; diff --git a/app/containers/message/Content.tsx b/app/containers/message/Content.tsx index db664d2cc..243e80948 100644 --- a/app/containers/message/Content.tsx +++ b/app/containers/message/Content.tsx @@ -7,12 +7,11 @@ import styles from './styles'; import Markdown, { MarkdownPreview } from '../markdown'; import User from './User'; import { SYSTEM_MESSAGE_TYPES_WITH_AUTHOR_NAME, getInfoMessage } from './utils'; -import { themes } from '../../constants/colors'; import MessageContext from './Context'; import Encrypted from './Encrypted'; -import { E2E_MESSAGE_TYPE } from '../../lib/constants'; import { IMessageContent } from './interfaces'; import { useTheme } from '../../theme'; +import { E2E_MESSAGE_TYPE, themes } from '../../lib/constants'; const Content = React.memo( (props: IMessageContent) => { diff --git a/app/containers/message/Discussion.tsx b/app/containers/message/Discussion.tsx index 6ef8f13b6..1e6e9ed55 100644 --- a/app/containers/message/Discussion.tsx +++ b/app/containers/message/Discussion.tsx @@ -7,7 +7,7 @@ import styles from './styles'; import I18n from '../../i18n'; import { CustomIcon } from '../../lib/Icons'; import { DISCUSSION } from './constants'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import MessageContext from './Context'; import { formatDateThreads } from '../../utils/room'; import { IMessage } from '../../definitions'; diff --git a/app/containers/message/Encrypted.tsx b/app/containers/message/Encrypted.tsx index 5896f4b36..d86add6ec 100644 --- a/app/containers/message/Encrypted.tsx +++ b/app/containers/message/Encrypted.tsx @@ -1,13 +1,12 @@ import React, { useContext } from 'react'; import Touchable from './Touchable'; -import { E2E_MESSAGE_TYPE } from '../../lib/constants'; import { CustomIcon } from '../../lib/Icons'; -import { themes } from '../../constants/colors'; import { BUTTON_HIT_SLOP } from './utils'; import MessageContext from './Context'; import styles from './styles'; import { useTheme } from '../../theme'; +import { E2E_MESSAGE_TYPE, themes } from '../../lib/constants'; const Encrypted = React.memo(({ type }: { type: string }) => { const { theme } = useTheme(); diff --git a/app/containers/message/Image.tsx b/app/containers/message/Image.tsx index f7f123f97..45dc331eb 100644 --- a/app/containers/message/Image.tsx +++ b/app/containers/message/Image.tsx @@ -8,7 +8,7 @@ import * as Progress from 'react-native-progress'; import Touchable from './Touchable'; import Markdown from '../markdown'; import styles from './styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import MessageContext from './Context'; import { TGetCustomEmoji } from '../../definitions/IEmoji'; import { IAttachment } from '../../definitions'; diff --git a/app/containers/message/Message.tsx b/app/containers/message/Message.tsx index 5c22293b0..f99b11a41 100644 --- a/app/containers/message/Message.tsx +++ b/app/containers/message/Message.tsx @@ -17,7 +17,7 @@ import Discussion from './Discussion'; import Content from './Content'; import ReadReceipt from './ReadReceipt'; import CallButton from './CallButton'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { IMessage, IMessageInner, IMessageTouchable } from './interfaces'; import { useTheme } from '../../theme'; diff --git a/app/containers/message/MessageError.tsx b/app/containers/message/MessageError.tsx index d72c8c911..d5f4fef98 100644 --- a/app/containers/message/MessageError.tsx +++ b/app/containers/message/MessageError.tsx @@ -4,7 +4,7 @@ import Touchable from './Touchable'; import { CustomIcon } from '../../lib/Icons'; import styles from './styles'; import { BUTTON_HIT_SLOP } from './utils'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import MessageContext from './Context'; import { useTheme } from '../../theme'; diff --git a/app/containers/message/Reactions.tsx b/app/containers/message/Reactions.tsx index 346b24002..0e013fc4b 100644 --- a/app/containers/message/Reactions.tsx +++ b/app/containers/message/Reactions.tsx @@ -6,7 +6,7 @@ import { CustomIcon } from '../../lib/Icons'; import styles from './styles'; import Emoji from './Emoji'; import { BUTTON_HIT_SLOP } from './utils'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { useTheme } from '../../theme'; import MessageContext from './Context'; import { TGetCustomEmoji } from '../../definitions/IEmoji'; diff --git a/app/containers/message/ReadReceipt.tsx b/app/containers/message/ReadReceipt.tsx index 4a68acf16..5556b781f 100644 --- a/app/containers/message/ReadReceipt.tsx +++ b/app/containers/message/ReadReceipt.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { CustomIcon } from '../../lib/Icons'; import styles from './styles'; import { useTheme } from '../../theme'; diff --git a/app/containers/message/RepliedThread.tsx b/app/containers/message/RepliedThread.tsx index fc0f92577..b681264dc 100644 --- a/app/containers/message/RepliedThread.tsx +++ b/app/containers/message/RepliedThread.tsx @@ -3,7 +3,7 @@ import { View } from 'react-native'; import { CustomIcon } from '../../lib/Icons'; import styles from './styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import I18n from '../../i18n'; import { MarkdownPreview } from '../markdown'; import { IMessageRepliedThread } from './interfaces'; diff --git a/app/containers/message/Reply.tsx b/app/containers/message/Reply.tsx index a080988bf..f3d45f51e 100644 --- a/app/containers/message/Reply.tsx +++ b/app/containers/message/Reply.tsx @@ -8,7 +8,7 @@ import Touchable from './Touchable'; import Markdown from '../markdown'; import openLink from '../../utils/openLink'; import sharedStyles from '../../views/Styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import MessageContext from './Context'; import { fileDownloadAndPreview } from '../../utils/fileDownload'; import { IAttachment } from '../../definitions/IAttachment'; diff --git a/app/containers/message/Thread.tsx b/app/containers/message/Thread.tsx index 4bfed49ac..00d9e5ab5 100644 --- a/app/containers/message/Thread.tsx +++ b/app/containers/message/Thread.tsx @@ -2,7 +2,7 @@ import React, { useContext } from 'react'; import { Text, View } from 'react-native'; import styles from './styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import MessageContext from './Context'; import ThreadDetails from '../ThreadDetails'; import I18n from '../../i18n'; diff --git a/app/containers/message/Urls.tsx b/app/containers/message/Urls.tsx index 65da7cd52..91846e1bb 100644 --- a/app/containers/message/Urls.tsx +++ b/app/containers/message/Urls.tsx @@ -7,7 +7,7 @@ import { dequal } from 'dequal'; import Touchable from './Touchable'; import openLink from '../../utils/openLink'; import sharedStyles from '../../views/Styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { useTheme, withTheme } from '../../theme'; import { LISTENER } from '../Toast'; import EventEmitter from '../../utils/events'; diff --git a/app/containers/message/User.tsx b/app/containers/message/User.tsx index ed42c225c..e8a7ee7de 100644 --- a/app/containers/message/User.tsx +++ b/app/containers/message/User.tsx @@ -2,7 +2,7 @@ import React, { useContext } from 'react'; import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'; import moment from 'moment'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { useTheme } from '../../theme'; import MessageError from './MessageError'; import sharedStyles from '../../views/Styles'; diff --git a/app/containers/message/Video.tsx b/app/containers/message/Video.tsx index b651b5dcd..69870c7eb 100644 --- a/app/containers/message/Video.tsx +++ b/app/containers/message/Video.tsx @@ -6,7 +6,7 @@ import Touchable from './Touchable'; import Markdown from '../markdown'; import { isIOS } from '../../utils/deviceInfo'; import { CustomIcon } from '../../lib/Icons'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import MessageContext from './Context'; import { fileDownload } from '../../utils/fileDownload'; import EventEmitter from '../../utils/events'; diff --git a/app/containers/message/index.tsx b/app/containers/message/index.tsx index 804794196..37ed92cac 100644 --- a/app/containers/message/index.tsx +++ b/app/containers/message/index.tsx @@ -6,13 +6,12 @@ import Message from './Message'; import MessageContext from './Context'; import debounce from '../../utils/debounce'; import { SYSTEM_MESSAGES, getMessageTranslation } from './utils'; -import { E2E_MESSAGE_TYPE, E2E_STATUS } from '../../lib/constants'; -import messagesStatus from '../../constants/messagesStatus'; import { useTheme, withTheme } from '../../theme'; import openLink from '../../utils/openLink'; import { TGetCustomEmoji } from '../../definitions/IEmoji'; import { IAttachment, TAnyMessageModel } from '../../definitions'; import { IRoomInfoParam } from '../../views/SearchMessagesView'; +import { E2E_MESSAGE_TYPE, E2E_STATUS, messagesStatus } from '../../lib/constants'; interface IMessageContainerProps { item: TAnyMessageModel; diff --git a/app/definitions/IMessage.ts b/app/definitions/IMessage.ts index 7a6cf234d..ff32100c0 100644 --- a/app/definitions/IMessage.ts +++ b/app/definitions/IMessage.ts @@ -1,7 +1,7 @@ import Model from '@nozbe/watermelondb/Model'; import { MarkdownAST } from '@rocket.chat/message-parser'; -import { MessageTypeLoad } from '../constants/messageTypeLoad'; +import { MessageTypeLoad } from '../lib/constants'; import { IAttachment } from './IAttachment'; import { IReaction } from './IReaction'; import { TThreadMessageModel } from './IThreadMessage'; diff --git a/app/definitions/IPreferences.ts b/app/definitions/IPreferences.ts index d444dd7e4..c71253081 100644 --- a/app/definitions/IPreferences.ts +++ b/app/definitions/IPreferences.ts @@ -1,4 +1,4 @@ -import { SortBy, DisplayMode } from '../constants/constantDisplayMode'; +import { SortBy, DisplayMode } from '../lib/constants'; export interface IPreferences { sortBy: SortBy; diff --git a/app/ee/omnichannel/containers/OmnichannelStatus.tsx b/app/ee/omnichannel/containers/OmnichannelStatus.tsx index 33d99efd5..3df4e544d 100644 --- a/app/ee/omnichannel/containers/OmnichannelStatus.tsx +++ b/app/ee/omnichannel/containers/OmnichannelStatus.tsx @@ -3,7 +3,7 @@ import { Switch, View } from 'react-native'; import * as List from '../../../containers/List'; import styles from '../../../views/RoomsListView/styles'; -import { SWITCH_TRACK_COLOR, themes } from '../../../constants/colors'; +import { SWITCH_TRACK_COLOR, themes } from '../../../lib/constants'; import { useTheme } from '../../../theme'; import UnreadBadge from '../../../presentation/UnreadBadge'; import RocketChat from '../../../lib/rocketchat'; diff --git a/app/ee/omnichannel/views/QueueListView.tsx b/app/ee/omnichannel/views/QueueListView.tsx index bb898e13f..bb5c0a316 100644 --- a/app/ee/omnichannel/views/QueueListView.tsx +++ b/app/ee/omnichannel/views/QueueListView.tsx @@ -7,13 +7,11 @@ import { dequal } from 'dequal'; import I18n from '../../../i18n'; import RoomItem, { ROW_HEIGHT } from '../../../presentation/RoomItem'; -import { MAX_SIDEBAR_WIDTH } from '../../../constants/tablet'; import { isIOS, isTablet } from '../../../utils/deviceInfo'; import { getUserSelector } from '../../../selectors/login'; import { withTheme } from '../../../theme'; import { withDimensions } from '../../../dimensions'; import SafeAreaView from '../../../containers/SafeAreaView'; -import { themes } from '../../../constants/colors'; import StatusBar from '../../../containers/StatusBar'; import { goRoom } from '../../../utils/goRoom'; import * as HeaderButton from '../../../containers/HeaderButton'; @@ -21,7 +19,7 @@ import RocketChat from '../../../lib/rocketchat'; import { events, logEvent } from '../../../utils/log'; import { getInquiryQueueSelector } from '../selectors/inquiry'; import { IOmnichannelRoom, IApplicationState } from '../../../definitions'; -import { DisplayMode } from '../../../constants/constantDisplayMode'; +import { DisplayMode, MAX_SIDEBAR_WIDTH, themes } from '../../../lib/constants'; import { ChatsStackParamList } from '../../../stacks/types'; import { MasterDetailInsideStackParamList } from '../../../stacks/MasterDetailStack/types'; import { TSettingsValues } from '../../../reducers/settings'; diff --git a/app/index.tsx b/app/index.tsx index 218098447..6d3dd9b2e 100644 --- a/app/index.tsx +++ b/app/index.tsx @@ -17,7 +17,6 @@ import { toggleAnalyticsEventsReport, toggleCrashErrorsReport } from './utils/lo import { ThemeContext, TSupportedThemes } from './theme'; import { DimensionsContext } from './dimensions'; import RocketChat from './lib/rocketchat'; -import { MIN_WIDTH_MASTER_DETAIL_LAYOUT } from './constants/tablet'; import { isTablet } from './utils/deviceInfo'; import { KEY_COMMAND } from './commands'; import AppContainer from './AppContainer'; @@ -28,11 +27,10 @@ import Toast from './containers/Toast'; import InAppNotification from './containers/InAppNotification'; import { ActionSheetProvider } from './containers/ActionSheet'; import debounce from './utils/debounce'; -import { isFDroidBuild } from './constants/environment'; +import { isFDroidBuild, MIN_WIDTH_MASTER_DETAIL_LAYOUT, colors, themes } from './lib/constants'; import { IThemePreference } from './definitions/ITheme'; import { ICommand } from './definitions/ICommand'; import { initStore } from './lib/auxStore'; -import { colors, themes } from './constants/colors'; RNScreens.enableScreens(); initStore(store); diff --git a/app/constants/colors.ts b/app/lib/constants/colors.ts similarity index 100% rename from app/constants/colors.ts rename to app/lib/constants/colors.ts diff --git a/app/constants/constantDisplayMode.ts b/app/lib/constants/constantDisplayMode.ts similarity index 100% rename from app/constants/constantDisplayMode.ts rename to app/lib/constants/constantDisplayMode.ts diff --git a/app/constants/settings.ts b/app/lib/constants/defaultSettings.ts similarity index 99% rename from app/constants/settings.ts rename to app/lib/constants/defaultSettings.ts index b84779427..8b1eed2a6 100644 --- a/app/constants/settings.ts +++ b/app/lib/constants/defaultSettings.ts @@ -1,4 +1,4 @@ -export default { +export const defaultSettings = { Accounts_AllowEmailChange: { type: 'valueAsBoolean' }, diff --git a/app/constants/environment.ts b/app/lib/constants/environment.ts similarity index 100% rename from app/constants/environment.ts rename to app/lib/constants/environment.ts diff --git a/app/lib/constants/index.ts b/app/lib/constants/index.ts new file mode 100644 index 000000000..7d273a803 --- /dev/null +++ b/app/lib/constants/index.ts @@ -0,0 +1,11 @@ +export * from './colors'; +export * from './constantDisplayMode'; +export * from './environment'; +export * from './keys'; +export * from './links'; +export * from './localAuthentication'; +export * from './localPath'; +export * from './messagesStatus'; +export * from './messageTypeLoad'; +export * from './defaultSettings'; +export * from './tablet'; diff --git a/app/lib/constants.ts b/app/lib/constants/keys.ts similarity index 100% rename from app/lib/constants.ts rename to app/lib/constants/keys.ts diff --git a/app/constants/links.ts b/app/lib/constants/links.ts similarity index 90% rename from app/constants/links.ts rename to app/lib/constants/links.ts index af93b5e39..cedad74a1 100644 --- a/app/constants/links.ts +++ b/app/lib/constants/links.ts @@ -1,4 +1,4 @@ -import { getBundleId, isIOS } from '../utils/deviceInfo'; +import { getBundleId, isIOS } from '../../utils/deviceInfo'; const APP_STORE_ID = '1148741252'; diff --git a/app/constants/localAuthentication.ts b/app/lib/constants/localAuthentication.ts similarity index 100% rename from app/constants/localAuthentication.ts rename to app/lib/constants/localAuthentication.ts diff --git a/app/constants/localPath.ts b/app/lib/constants/localPath.ts similarity index 100% rename from app/constants/localPath.ts rename to app/lib/constants/localPath.ts diff --git a/app/constants/messageTypeLoad.ts b/app/lib/constants/messageTypeLoad.ts similarity index 100% rename from app/constants/messageTypeLoad.ts rename to app/lib/constants/messageTypeLoad.ts diff --git a/app/constants/messagesStatus.ts b/app/lib/constants/messagesStatus.ts similarity index 50% rename from app/constants/messagesStatus.ts rename to app/lib/constants/messagesStatus.ts index 4f945f939..366d8b0e8 100644 --- a/app/constants/messagesStatus.ts +++ b/app/lib/constants/messagesStatus.ts @@ -1,4 +1,4 @@ -export default { +export const messagesStatus = { SENT: 0, TEMP: 1, ERROR: 2 diff --git a/app/constants/tablet.ts b/app/lib/constants/tablet.ts similarity index 100% rename from app/constants/tablet.ts rename to app/lib/constants/tablet.ts diff --git a/app/lib/database/index.ts b/app/lib/database/index.ts index d85e826d6..0f3f5e7f5 100644 --- a/app/lib/database/index.ts +++ b/app/lib/database/index.ts @@ -4,7 +4,7 @@ import logger from '@nozbe/watermelondb/utils/common/logger'; import { isIOS } from '../../utils/deviceInfo'; import appGroup from '../../utils/appGroup'; -import { isOfficial } from '../../constants/environment'; +import { isOfficial } from '../constants'; import Subscription from './model/Subscription'; import Room from './model/Room'; import Message from './model/Message'; diff --git a/app/lib/encryption/encryption.ts b/app/lib/encryption/encryption.ts index d4231c4dc..ff1727185 100644 --- a/app/lib/encryption/encryption.ts +++ b/app/lib/encryption/encryption.ts @@ -10,6 +10,9 @@ import protectedFunction from '../methods/helpers/protectedFunction'; import Deferred from '../../utils/deferred'; import log from '../../utils/log'; import { store } from '../auxStore'; +import { joinVectorData, randomPassword, splitVectorData, toString, utf8ToBuffer } from './utils'; +import { EncryptionRoom } from './index'; +import { IMessage, ISubscription, TMessageModel, TSubscriptionModel, TThreadMessageModel, TThreadModel } from '../../definitions'; import { E2E_BANNER_TYPE, E2E_MESSAGE_TYPE, @@ -18,9 +21,6 @@ import { E2E_RANDOM_PASSWORD_KEY, E2E_STATUS } from '../constants'; -import { joinVectorData, randomPassword, splitVectorData, toString, utf8ToBuffer } from './utils'; -import { EncryptionRoom } from './index'; -import { IMessage, ISubscription, TMessageModel, TSubscriptionModel, TThreadMessageModel, TThreadModel } from '../../definitions'; class Encryption { ready: boolean; diff --git a/app/lib/encryption/room.ts b/app/lib/encryption/room.ts index 45907aa98..f2ed355d9 100644 --- a/app/lib/encryption/room.ts +++ b/app/lib/encryption/room.ts @@ -9,7 +9,6 @@ import Deferred from '../../utils/deferred'; import debounce from '../../utils/debounce'; import database from '../database'; import log from '../../utils/log'; -import { E2E_MESSAGE_TYPE, E2E_STATUS } from '../constants'; import { b64ToBuffer, bufferToB64, @@ -22,6 +21,7 @@ import { } from './utils'; import { Encryption } from './index'; import { IUser } from '../../definitions/IUser'; +import { E2E_MESSAGE_TYPE, E2E_STATUS } from '../constants'; export default class EncryptionRoom { ready: boolean; diff --git a/app/lib/methods/helpers/buildMessage.ts b/app/lib/methods/helpers/buildMessage.ts index 96ee8ccbe..96bc28f17 100644 --- a/app/lib/methods/helpers/buildMessage.ts +++ b/app/lib/methods/helpers/buildMessage.ts @@ -1,5 +1,5 @@ import { ILastMessage, IMessage, IThreadResult } from '../../../definitions'; -import messagesStatus from '../../../constants/messagesStatus'; +import { messagesStatus } from '../../constants'; import normalizeMessage from './normalizeMessage'; export default (message: Partial | IThreadResult | ILastMessage): IMessage | IThreadResult | null => { diff --git a/app/lib/methods/loadMessagesForRoom.ts b/app/lib/methods/loadMessagesForRoom.ts index e74e754c3..234434b77 100644 --- a/app/lib/methods/loadMessagesForRoom.ts +++ b/app/lib/methods/loadMessagesForRoom.ts @@ -1,6 +1,6 @@ import moment from 'moment'; -import { MessageTypeLoad } from '../../constants/messageTypeLoad'; +import { MessageTypeLoad } from '../constants'; import { IMessage, TMessageModel } from '../../definitions'; import log from '../../utils/log'; import { getMessageById } from '../database/services/Message'; diff --git a/app/lib/methods/loadNextMessages.ts b/app/lib/methods/loadNextMessages.ts index 6331c8774..a7a729ad3 100644 --- a/app/lib/methods/loadNextMessages.ts +++ b/app/lib/methods/loadNextMessages.ts @@ -4,7 +4,7 @@ import orderBy from 'lodash/orderBy'; import log from '../../utils/log'; import { getMessageById } from '../database/services/Message'; -import { MessageTypeLoad } from '../../constants/messageTypeLoad'; +import { MessageTypeLoad } from '../constants'; import updateMessages from './updateMessages'; import { TMessageModel } from '../../definitions'; import sdk from '../rocketchat/services/sdk'; diff --git a/app/lib/methods/loadSurroundingMessages.ts b/app/lib/methods/loadSurroundingMessages.ts index a125edd90..81ea1523d 100644 --- a/app/lib/methods/loadSurroundingMessages.ts +++ b/app/lib/methods/loadSurroundingMessages.ts @@ -4,7 +4,7 @@ import orderBy from 'lodash/orderBy'; import log from '../../utils/log'; import { getMessageById } from '../database/services/Message'; -import { MessageTypeLoad } from '../../constants/messageTypeLoad'; +import { MessageTypeLoad } from '../constants'; import sdk from '../rocketchat/services/sdk'; import { IMessage } from '../../definitions'; import updateMessages from './updateMessages'; diff --git a/app/lib/methods/sendMessage.ts b/app/lib/methods/sendMessage.ts index aaf03ea8d..95a3537d0 100644 --- a/app/lib/methods/sendMessage.ts +++ b/app/lib/methods/sendMessage.ts @@ -1,14 +1,13 @@ import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord'; import { Model } from '@nozbe/watermelondb'; -import messagesStatus from '../../constants/messagesStatus'; import database from '../database'; import log from '../../utils/log'; import random from '../../utils/random'; import { Encryption } from '../encryption'; -import { E2E_MESSAGE_TYPE, E2E_STATUS } from '../constants'; import { E2EType, IMessage, IUser, TMessageModel } from '../../definitions'; import sdk from '../rocketchat/services/sdk'; +import { E2E_MESSAGE_TYPE, E2E_STATUS, messagesStatus } from '../constants'; const changeMessageStatus = async (id: string, status: number, tmid?: string, message?: IMessage) => { const db = database.active; diff --git a/app/lib/methods/subscriptions/rooms.ts b/app/lib/methods/subscriptions/rooms.ts index fa7f3a734..4a41475cb 100644 --- a/app/lib/methods/subscriptions/rooms.ts +++ b/app/lib/methods/subscriptions/rooms.ts @@ -17,7 +17,6 @@ import { removedRoom } from '../../../actions/room'; import { setUser } from '../../../actions/login'; import { INAPP_NOTIFICATION_EMITTER } from '../../../containers/InAppNotification'; import { Encryption } from '../../encryption'; -import { E2E_MESSAGE_TYPE } from '../../constants'; import updateMessages from '../updateMessages'; import { IMessage, @@ -33,6 +32,7 @@ import sdk from '../../rocketchat/services/sdk'; import { IDDPMessage } from '../../../definitions/IDDPMessage'; import { getSubscriptionByRoomId } from '../../database/services/Subscription'; import { getMessageById } from '../../database/services/Message'; +import { E2E_MESSAGE_TYPE } from '../../constants'; const removeListener = (listener: { stop: () => void }) => listener.stop(); diff --git a/app/lib/methods/updateMessages.ts b/app/lib/methods/updateMessages.ts index b95fbd125..6acbdce14 100644 --- a/app/lib/methods/updateMessages.ts +++ b/app/lib/methods/updateMessages.ts @@ -1,7 +1,7 @@ import { Q } from '@nozbe/watermelondb'; import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord'; -import { MESSAGE_TYPE_ANY_LOAD } from '../../constants/messageTypeLoad'; +import { MESSAGE_TYPE_ANY_LOAD } from '../constants'; import { IMessage, TMessageModel, TSubscriptionModel, TThreadMessageModel, TThreadModel } from '../../definitions'; import database from '../database'; import { getSubscriptionByRoomId } from '../database/services/Subscription'; diff --git a/app/lib/rocketchat/methods/getSettings.ts b/app/lib/rocketchat/methods/getSettings.ts index cae346c15..01b549690 100644 --- a/app/lib/rocketchat/methods/getSettings.ts +++ b/app/lib/rocketchat/methods/getSettings.ts @@ -2,8 +2,7 @@ import { Q } from '@nozbe/watermelondb'; import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord'; import { addSettings, clearSettings } from '../../../actions/settings'; -import { DEFAULT_AUTO_LOCK } from '../../../constants/localAuthentication'; -import settings from '../../../constants/settings'; +import { DEFAULT_AUTO_LOCK, defaultSettings } from '../../constants'; import { IPreparedSettings, ISettingsIcon } from '../../../definitions'; import fetch from '../../../utils/fetch'; import log from '../../../utils/log'; @@ -144,7 +143,7 @@ type IData = ISettingsIcon | IPreparedSettings; export async function getSettings(): Promise { try { const db = database.active; - const settingsParams = Object.keys(settings).filter(key => !loginSettings.includes(key)); + const settingsParams = Object.keys(defaultSettings).filter(key => !loginSettings.includes(key)); // RC 0.60.0 const result = await fetch( `${sdk.current.client.host}/api/v1/settings.public?query={"_id":{"$in":${JSON.stringify(settingsParams)}}}&count=${ diff --git a/app/lib/rocketchat/methods/helpers.ts b/app/lib/rocketchat/methods/helpers.ts index a0fcd64cf..4a06e50ef 100644 --- a/app/lib/rocketchat/methods/helpers.ts +++ b/app/lib/rocketchat/methods/helpers.ts @@ -3,10 +3,9 @@ import AsyncStorage from '@react-native-community/async-storage'; import log from '../../../utils/log'; import { store as reduxStore } from '../../auxStore'; -import { ANALYTICS_EVENTS_KEY, CRASH_REPORT_KEY } from '../../constants'; -import defaultSettings from '../../../constants/settings'; import database from '../../database'; import subscribeRoomsTmp from '../../methods/subscriptions/rooms'; +import { ANALYTICS_EVENTS_KEY, CRASH_REPORT_KEY, defaultSettings } from '../../constants'; export function isGroupChat(room): boolean { return ((room.uids && room.uids.length > 2) || (room.usernames && room.usernames.length > 2)) ?? false; diff --git a/app/lib/rocketchat/methods/logout.ts b/app/lib/rocketchat/methods/logout.ts index 4fe5e05d6..d070002a3 100644 --- a/app/lib/rocketchat/methods/logout.ts +++ b/app/lib/rocketchat/methods/logout.ts @@ -9,10 +9,10 @@ import database, { getDatabase } from '../../database'; 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 '../../methods/userPreferences'; import { ICertificate, IRocketChat } from '../../../definitions'; import sdk from '../services/sdk'; +import { E2E_PRIVATE_KEY, E2E_PUBLIC_KEY, E2E_RANDOM_PASSWORD_KEY } from '../../constants'; function removeServerKeys({ server, userId }: { server: string; userId?: string | null }) { UserPreferences.removeItem(`${RocketChat.TOKEN_KEY}-${server}`); diff --git a/app/lib/rocketchat/services/connect.ts b/app/lib/rocketchat/services/connect.ts index 636f45a68..f8f2c1f64 100644 --- a/app/lib/rocketchat/services/connect.ts +++ b/app/lib/rocketchat/services/connect.ts @@ -22,8 +22,7 @@ import { connectRequest, connectSuccess, disconnect as disconnectAction } from ' import { updatePermission } from '../../../actions/permissions'; import EventEmitter from '../../../utils/events'; import { updateSettings } from '../../../actions/settings'; -import defaultSettings from '../../../constants/settings'; -import { MIN_ROCKETCHAT_VERSION } from '../../constants'; +import { defaultSettings, MIN_ROCKETCHAT_VERSION } from '../../constants'; import { compareServerVersion } from '../../methods/helpers/compareServerVersion'; interface IServices { diff --git a/app/notifications/push/index.ts b/app/notifications/push/index.ts index 749517642..e9ac11fba 100644 --- a/app/notifications/push/index.ts +++ b/app/notifications/push/index.ts @@ -2,7 +2,7 @@ import EJSON from 'ejson'; import { store } from '../../lib/auxStore'; import { deepLinkingOpen } from '../../actions/deepLinking'; -import { isFDroidBuild } from '../../constants/environment'; +import { isFDroidBuild } from '../../lib/constants'; import PushNotification from './push'; import { INotification, SubscriptionType } from '../../definitions'; diff --git a/app/presentation/DirectoryItem/index.tsx b/app/presentation/DirectoryItem/index.tsx index 234c1e312..1cdbe63e8 100644 --- a/app/presentation/DirectoryItem/index.tsx +++ b/app/presentation/DirectoryItem/index.tsx @@ -5,7 +5,7 @@ import Touch from '../../utils/touch'; import Avatar from '../../containers/Avatar'; import RoomTypeIcon from '../../containers/RoomTypeIcon'; import styles, { ROW_HEIGHT } from './styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; export { ROW_HEIGHT }; diff --git a/app/presentation/ImageViewer/ImageViewer.android.tsx b/app/presentation/ImageViewer/ImageViewer.android.tsx index cbb79c7fe..158e76938 100644 --- a/app/presentation/ImageViewer/ImageViewer.android.tsx +++ b/app/presentation/ImageViewer/ImageViewer.android.tsx @@ -4,7 +4,7 @@ import { PanGestureHandler, PinchGestureHandler, State } from 'react-native-gest import Animated, { EasingNode } from 'react-native-reanimated'; import { ImageComponent } from './ImageComponent'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; const styles = StyleSheet.create({ flex: { diff --git a/app/presentation/ImageViewer/ImageViewer.tsx b/app/presentation/ImageViewer/ImageViewer.tsx index 117bf95dd..74a58ea79 100644 --- a/app/presentation/ImageViewer/ImageViewer.tsx +++ b/app/presentation/ImageViewer/ImageViewer.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { ScrollView, StyleSheet } from 'react-native'; import { ImageComponent } from './ImageComponent'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; const styles = StyleSheet.create({ scrollContent: { diff --git a/app/presentation/RoomItem/Actions.tsx b/app/presentation/RoomItem/Actions.tsx index 2b53955a9..21c7fe9c3 100644 --- a/app/presentation/RoomItem/Actions.tsx +++ b/app/presentation/RoomItem/Actions.tsx @@ -4,8 +4,7 @@ import { RectButton } from 'react-native-gesture-handler'; import { isRTL } from '../../i18n'; import { CustomIcon } from '../../lib/Icons'; -import { themes } from '../../constants/colors'; -import { DisplayMode } from '../../constants/constantDisplayMode'; +import { DisplayMode, themes } from '../../lib/constants'; import styles, { ACTION_WIDTH, LONG_SWIPE, ROW_HEIGHT_CONDENSED } from './styles'; interface ILeftActions { diff --git a/app/presentation/RoomItem/IconOrAvatar.js b/app/presentation/RoomItem/IconOrAvatar.js index 29343477a..567c4a6e1 100644 --- a/app/presentation/RoomItem/IconOrAvatar.js +++ b/app/presentation/RoomItem/IconOrAvatar.js @@ -3,7 +3,7 @@ import { View } from 'react-native'; import PropTypes from 'prop-types'; import Avatar from '../../containers/Avatar'; -import { DisplayMode } from '../../constants/constantDisplayMode'; +import { DisplayMode } from '../../lib/constants'; import TypeIcon from './TypeIcon'; import styles from './styles'; diff --git a/app/presentation/RoomItem/LastMessage.tsx b/app/presentation/RoomItem/LastMessage.tsx index b2715bb42..beab95ea5 100644 --- a/app/presentation/RoomItem/LastMessage.tsx +++ b/app/presentation/RoomItem/LastMessage.tsx @@ -4,8 +4,7 @@ import { dequal } from 'dequal'; import I18n from '../../i18n'; import styles from './styles'; import { MarkdownPreview } from '../../containers/markdown'; -import { themes } from '../../constants/colors'; -import { E2E_MESSAGE_TYPE, E2E_STATUS } from '../../lib/constants'; +import { E2E_MESSAGE_TYPE, E2E_STATUS, themes } from '../../lib/constants'; interface ILastMessage { theme: string; diff --git a/app/presentation/RoomItem/RoomItem.tsx b/app/presentation/RoomItem/RoomItem.tsx index 497cf91a2..b4e8d133e 100644 --- a/app/presentation/RoomItem/RoomItem.tsx +++ b/app/presentation/RoomItem/RoomItem.tsx @@ -11,7 +11,7 @@ import UpdatedAt from './UpdatedAt'; import Touchable from './Touchable'; import Tag from './Tag'; import I18n from '../../i18n'; -import { DisplayMode } from '../../constants/constantDisplayMode'; +import { DisplayMode } from '../../lib/constants'; import { TUserStatus } from '../../definitions'; interface IRoomItem { diff --git a/app/presentation/RoomItem/Tag.tsx b/app/presentation/RoomItem/Tag.tsx index 084e03e88..0b07b8060 100644 --- a/app/presentation/RoomItem/Tag.tsx +++ b/app/presentation/RoomItem/Tag.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { Text, View } from 'react-native'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { useTheme } from '../../theme'; import styles from './styles'; diff --git a/app/presentation/RoomItem/Title.tsx b/app/presentation/RoomItem/Title.tsx index 93f74bf21..d4f8253c5 100644 --- a/app/presentation/RoomItem/Title.tsx +++ b/app/presentation/RoomItem/Title.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Text } from 'react-native'; import styles from './styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; interface ITitle { name: string; diff --git a/app/presentation/RoomItem/Touchable.tsx b/app/presentation/RoomItem/Touchable.tsx index b40436aaa..03fbc31d1 100644 --- a/app/presentation/RoomItem/Touchable.tsx +++ b/app/presentation/RoomItem/Touchable.tsx @@ -5,7 +5,7 @@ import { LongPressGestureHandler, PanGestureHandler, State } from 'react-native- import Touch from '../../utils/touch'; import { ACTION_WIDTH, LONG_SWIPE, SMALL_SWIPE } from './styles'; import { isRTL } from '../../i18n'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { LeftActions, RightActions } from './Actions'; interface ITouchableProps { diff --git a/app/presentation/RoomItem/UpdatedAt.tsx b/app/presentation/RoomItem/UpdatedAt.tsx index eed4416aa..d5a0babad 100644 --- a/app/presentation/RoomItem/UpdatedAt.tsx +++ b/app/presentation/RoomItem/UpdatedAt.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Text } from 'react-native'; import styles from './styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { capitalize } from '../../utils/room'; interface IUpdatedAt { diff --git a/app/presentation/RoomItem/Wrapper.tsx b/app/presentation/RoomItem/Wrapper.tsx index d0d2b150e..222934c25 100644 --- a/app/presentation/RoomItem/Wrapper.tsx +++ b/app/presentation/RoomItem/Wrapper.tsx @@ -1,8 +1,7 @@ import React from 'react'; import { View } from 'react-native'; -import { themes } from '../../constants/colors'; -import { DisplayMode } from '../../constants/constantDisplayMode'; +import { DisplayMode, themes } from '../../lib/constants'; import IconOrAvatar from './IconOrAvatar'; import styles from './styles'; diff --git a/app/presentation/ServerItem/index.tsx b/app/presentation/ServerItem/index.tsx index f46223a45..a70aaf858 100644 --- a/app/presentation/ServerItem/index.tsx +++ b/app/presentation/ServerItem/index.tsx @@ -5,7 +5,7 @@ import FastImage from '@rocket.chat/react-native-fast-image'; import Check from '../../containers/Check'; import styles, { ROW_HEIGHT } from './styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { isIOS } from '../../utils/deviceInfo'; import { withTheme } from '../../theme'; diff --git a/app/presentation/TextInput.tsx b/app/presentation/TextInput.tsx index 6f1ac31b3..27996244d 100644 --- a/app/presentation/TextInput.tsx +++ b/app/presentation/TextInput.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { I18nManager, StyleProp, StyleSheet, TextInput, TextStyle } from 'react-native'; import { IRCTextInputProps } from '../containers/TextInput'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; const styles = StyleSheet.create({ input: { diff --git a/app/presentation/UnreadBadge/getUnreadStyle.test.js b/app/presentation/UnreadBadge/getUnreadStyle.test.js index 8ac3ea047..03dd850af 100644 --- a/app/presentation/UnreadBadge/getUnreadStyle.test.js +++ b/app/presentation/UnreadBadge/getUnreadStyle.test.js @@ -1,5 +1,5 @@ /* eslint-disable no-undef */ -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { getUnreadStyle } from './getUnreadStyle'; const testsForTheme = theme => { diff --git a/app/presentation/UnreadBadge/getUnreadStyle.ts b/app/presentation/UnreadBadge/getUnreadStyle.ts index 94e7acca4..442979fb0 100644 --- a/app/presentation/UnreadBadge/getUnreadStyle.ts +++ b/app/presentation/UnreadBadge/getUnreadStyle.ts @@ -1,4 +1,4 @@ -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; export const getUnreadStyle = ({ unread, userMentions, groupMentions, theme, tunread, tunreadUser, tunreadGroup }: any) => { if ((!unread || unread <= 0) && !tunread?.length) { diff --git a/app/presentation/UserItem.tsx b/app/presentation/UserItem.tsx index b2e9d0b16..0c2a456c0 100644 --- a/app/presentation/UserItem.tsx +++ b/app/presentation/UserItem.tsx @@ -5,7 +5,7 @@ import { Pressable, StyleProp, StyleSheet, Text, View, ViewStyle } from 'react-n import Avatar from '../containers/Avatar'; import { CustomIcon } from '../lib/Icons'; import sharedStyles from '../views/Styles'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import { isIOS } from '../utils/deviceInfo'; const styles = StyleSheet.create({ diff --git a/app/reducers/settings.ts b/app/reducers/settings.ts index 090cf73a2..a8ea96a9d 100644 --- a/app/reducers/settings.ts +++ b/app/reducers/settings.ts @@ -1,8 +1,8 @@ import { IActionSettings } from '../actions/settings'; import { SETTINGS } from '../actions/actionsTypes'; -import settings from '../constants/settings'; +import { defaultSettings } from '../lib/constants'; -export type TSupportedSettings = keyof typeof settings; +export type TSupportedSettings = keyof typeof defaultSettings; export type TSettingsValues = string | number | boolean | string[]; export type TSettingsState = { diff --git a/app/reducers/sortPreferences.test.ts b/app/reducers/sortPreferences.test.ts index 5de29933d..5ef0ff94d 100644 --- a/app/reducers/sortPreferences.test.ts +++ b/app/reducers/sortPreferences.test.ts @@ -2,7 +2,7 @@ import { IPreferences } from '../definitions'; import { setAllPreferences, setPreference } from '../actions/sortPreferences'; import { mockedStore } from './mockedStore'; import { initialState } from './sortPreferences'; -import { DisplayMode, SortBy } from '../constants/constantDisplayMode'; +import { DisplayMode, SortBy } from '../lib/constants'; describe('test sortPreferences reducer', () => { it('should return initial state', () => { diff --git a/app/reducers/sortPreferences.ts b/app/reducers/sortPreferences.ts index 2083e8f7a..32771a3e4 100644 --- a/app/reducers/sortPreferences.ts +++ b/app/reducers/sortPreferences.ts @@ -1,5 +1,5 @@ import { SORT_PREFERENCES } from '../actions/actionsTypes'; -import { DisplayMode, SortBy } from '../constants/constantDisplayMode'; +import { DisplayMode, SortBy } from '../lib/constants'; import { IPreferences, TApplicationActions } from '../definitions'; export const initialState: IPreferences = { diff --git a/app/sagas/encryption.js b/app/sagas/encryption.js index 4ab7e83d7..d363c5054 100644 --- a/app/sagas/encryption.js +++ b/app/sagas/encryption.js @@ -5,7 +5,6 @@ import { ENCRYPTION } from '../actions/actionsTypes'; import { encryptionSet } from '../actions/encryption'; import { Encryption } from '../lib/encryption'; import Navigation from '../lib/navigation/appNavigation'; -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/methods/userPreferences'; @@ -13,6 +12,7 @@ import { getUserSelector } from '../selectors/login'; import { showErrorAlert } from '../utils/info'; import I18n from '../i18n'; import log from '../utils/log'; +import { E2E_BANNER_TYPE, E2E_PRIVATE_KEY, E2E_PUBLIC_KEY, E2E_RANDOM_PASSWORD_KEY } from '../lib/constants'; const getServer = state => state.share.server.server || state.server.server; const getE2eEnable = state => state.settings.E2E_Enable; diff --git a/app/sagas/init.js b/app/sagas/init.js index 87196a7f0..78f2de3d7 100644 --- a/app/sagas/init.js +++ b/app/sagas/init.js @@ -1,7 +1,7 @@ import { put, takeLatest } from 'redux-saga/effects'; import RNBootSplash from 'react-native-bootsplash'; -import { BIOMETRY_ENABLED_KEY } from '../constants/localAuthentication'; +import { BIOMETRY_ENABLED_KEY } from '../lib/constants'; import UserPreferences from '../lib/methods/userPreferences'; import { selectServerRequest } from '../actions/server'; import { setAllPreferences } from '../actions/sortPreferences'; diff --git a/app/share.tsx b/app/share.tsx index 8a4ca1f1d..94075a830 100644 --- a/app/share.tsx +++ b/app/share.tsx @@ -28,7 +28,7 @@ import AuthLoadingView from './views/AuthLoadingView'; import { DimensionsContext } from './dimensions'; import debounce from './utils/debounce'; import { ShareInsideStackParamList, ShareOutsideStackParamList, ShareAppStackParamList } from './definitions/navigationTypes'; -import { colors } from './constants/colors'; +import { colors } from './lib/constants'; initStore(store); diff --git a/app/stacks/InsideStack.tsx b/app/stacks/InsideStack.tsx index ec3ae318e..6c6c0249a 100644 --- a/app/stacks/InsideStack.tsx +++ b/app/stacks/InsideStack.tsx @@ -30,7 +30,7 @@ import MarkdownTableView from '../views/MarkdownTableView'; import ReadReceiptsView from '../views/ReadReceiptView'; import CannedResponsesListView from '../views/CannedResponsesListView'; import CannedResponseDetail from '../views/CannedResponseDetail'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; // Profile Stack import ProfileView from '../views/ProfileView'; import UserPreferencesView from '../views/UserPreferencesView'; diff --git a/app/stacks/MasterDetailStack/ModalContainer.tsx b/app/stacks/MasterDetailStack/ModalContainer.tsx index 376ff8769..c6120e335 100644 --- a/app/stacks/MasterDetailStack/ModalContainer.tsx +++ b/app/stacks/MasterDetailStack/ModalContainer.tsx @@ -4,7 +4,7 @@ import { StackNavigationProp } from '@react-navigation/stack'; import { NavigationContainerProps } from '@react-navigation/core'; import sharedStyles from '../../views/Styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; interface IModalContainer extends NavigationContainerProps { navigation: StackNavigationProp; diff --git a/app/theme.tsx b/app/theme.tsx index e06c4ec00..c9b4326de 100644 --- a/app/theme.tsx +++ b/app/theme.tsx @@ -1,9 +1,9 @@ import hoistNonReactStatics from 'hoist-non-react-statics'; import React from 'react'; -import { colors } from './constants/colors'; import { IThemePreference } from './definitions/ITheme'; import { TNavigationOptions } from './definitions/navigationTypes'; +import { colors } from './lib/constants'; export type TSupportedThemes = keyof typeof colors; export type TColors = typeof colors[TSupportedThemes]; diff --git a/app/utils/fileDownload/index.ts b/app/utils/fileDownload/index.ts index 279d3b3a5..c087875de 100644 --- a/app/utils/fileDownload/index.ts +++ b/app/utils/fileDownload/index.ts @@ -4,7 +4,7 @@ import FileViewer from 'react-native-file-viewer'; import EventEmitter from '../events'; import { LISTENER } from '../../containers/Toast'; import I18n from '../../i18n'; -import { DOCUMENTS_PATH, DOWNLOAD_PATH } from '../../constants/localPath'; +import { DOCUMENTS_PATH, DOWNLOAD_PATH } from '../../lib/constants'; import { IAttachment } from '../../definitions/IAttachment'; export const getLocalFilePathFromFile = (localPath: string, attachment: IAttachment): string => `${localPath}${attachment.title}`; diff --git a/app/utils/localAuthentication.ts b/app/utils/localAuthentication.ts index aac73a456..35704374d 100644 --- a/app/utils/localAuthentication.ts +++ b/app/utils/localAuthentication.ts @@ -15,7 +15,7 @@ import { LOCAL_AUTHENTICATE_EMITTER, LOCKED_OUT_TIMER_KEY, PASSCODE_KEY -} from '../constants/localAuthentication'; +} from '../lib/constants'; import I18n from '../i18n'; import { setLocalAuthenticated } from '../actions/login'; import { TServerModel } from '../definitions/IServer'; diff --git a/app/utils/log/index.ts b/app/utils/log/index.ts index bebbf147a..88ccc8d36 100644 --- a/app/utils/log/index.ts +++ b/app/utils/log/index.ts @@ -1,6 +1,6 @@ import firebaseAnalytics from '@react-native-firebase/analytics'; -import { isFDroidBuild } from '../../constants/environment'; +import { isFDroidBuild } from '../../lib/constants'; import events from './events'; const analytics = firebaseAnalytics || ''; diff --git a/app/utils/navigation/index.ts b/app/utils/navigation/index.ts index 9314e88e8..21ede13a1 100644 --- a/app/utils/navigation/index.ts +++ b/app/utils/navigation/index.ts @@ -1,7 +1,7 @@ import { StyleSheet } from 'react-native'; import { DarkTheme, DefaultTheme } from '@react-navigation/native'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; export * from './animations'; diff --git a/app/utils/openLink.ts b/app/utils/openLink.ts index b0305f775..d90a06932 100644 --- a/app/utils/openLink.ts +++ b/app/utils/openLink.ts @@ -2,8 +2,8 @@ import { Linking } from 'react-native'; import * as WebBrowser from 'expo-web-browser'; import parse from 'url-parse'; +import { themes } from '../lib/constants'; import UserPreferences from '../lib/methods/userPreferences'; -import { themes } from '../constants/colors'; export const DEFAULT_BROWSER_KEY = 'DEFAULT_BROWSER_KEY'; diff --git a/app/utils/review.ts b/app/utils/review.ts index bbbb498be..8b58e8593 100644 --- a/app/utils/review.ts +++ b/app/utils/review.ts @@ -2,8 +2,7 @@ import { Alert, Linking } from 'react-native'; import AsyncStorage from '@react-native-community/async-storage'; import I18n from '../i18n'; -import { STORE_REVIEW_LINK } from '../constants/links'; -import { isFDroidBuild } from '../constants/environment'; +import { isFDroidBuild, STORE_REVIEW_LINK } from '../lib/constants'; import { showErrorAlert } from './info'; import { isIOS } from './deviceInfo'; import { events, logEvent } from './log'; diff --git a/app/utils/room.ts b/app/utils/room.ts index bf6cd0804..c79681855 100644 --- a/app/utils/room.ts +++ b/app/utils/room.ts @@ -1,6 +1,6 @@ import moment from 'moment'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import I18n from '../i18n'; import { IAttachment } from '../definitions/IAttachment'; import { SubscriptionType, TSubscriptionModel } from '../definitions/ISubscription'; diff --git a/app/utils/theme.ts b/app/utils/theme.ts index 1678a156e..3f8779135 100644 --- a/app/utils/theme.ts +++ b/app/utils/theme.ts @@ -3,11 +3,10 @@ import changeNavigationBarColor from 'react-native-navigation-bar-color'; import setRootViewColor from 'rn-root-view'; import { IThemePreference, TThemeMode } from '../definitions/ITheme'; -import { themes } from '../constants/colors'; -import { isAndroid } from './deviceInfo'; +import { themes, THEME_PREFERENCES_KEY } from '../lib/constants'; import UserPreferences from '../lib/methods/userPreferences'; -import { THEME_PREFERENCES_KEY } from '../lib/constants'; import { TSupportedThemes } from '../theme'; +import { isAndroid } from './deviceInfo'; let themeListener: { remove: () => void } | null; diff --git a/app/utils/touch.tsx b/app/utils/touch.tsx index 3573c87c5..00cdbd4ad 100644 --- a/app/utils/touch.tsx +++ b/app/utils/touch.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { RectButton, RectButtonProps } from 'react-native-gesture-handler'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; interface ITouchProps extends RectButtonProps { children: React.ReactNode; diff --git a/app/views/AddExistingChannelView.tsx b/app/views/AddExistingChannelView.tsx index 69af6b57b..ad08a368c 100644 --- a/app/views/AddExistingChannelView.tsx +++ b/app/views/AddExistingChannelView.tsx @@ -13,7 +13,7 @@ import log, { events, logEvent } from '../utils/log'; import SearchBox from '../containers/SearchBox'; import * as HeaderButton from '../containers/HeaderButton'; import StatusBar from '../containers/StatusBar'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import { withTheme } from '../theme'; import SafeAreaView from '../containers/SafeAreaView'; import Loading from '../containers/Loading'; diff --git a/app/views/AttachmentView.tsx b/app/views/AttachmentView.tsx index b93106a40..a7a3a23d3 100644 --- a/app/views/AttachmentView.tsx +++ b/app/views/AttachmentView.tsx @@ -15,7 +15,7 @@ import EventEmitter from '../utils/events'; import I18n from '../i18n'; import { withTheme } from '../theme'; import { ImageViewer } from '../presentation/ImageViewer'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import RCActivityIndicator from '../containers/ActivityIndicator'; import * as HeaderButton from '../containers/HeaderButton'; import { isAndroid } from '../utils/deviceInfo'; diff --git a/app/views/AuthLoadingView.tsx b/app/views/AuthLoadingView.tsx index ef6e7b943..9ffb4fdf6 100644 --- a/app/views/AuthLoadingView.tsx +++ b/app/views/AuthLoadingView.tsx @@ -5,7 +5,7 @@ import { connect } from 'react-redux'; import I18n from '../i18n'; import StatusBar from '../containers/StatusBar'; import { withTheme } from '../theme'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import sharedStyles from './Styles'; const styles = StyleSheet.create({ diff --git a/app/views/AutoTranslateView/index.tsx b/app/views/AutoTranslateView/index.tsx index 07acef800..6c59a7fbd 100644 --- a/app/views/AutoTranslateView/index.tsx +++ b/app/views/AutoTranslateView/index.tsx @@ -7,7 +7,7 @@ import RocketChat from '../../lib/rocketchat'; import I18n from '../../i18n'; import StatusBar from '../../containers/StatusBar'; import * as List from '../../containers/List'; -import { SWITCH_TRACK_COLOR, themes } from '../../constants/colors'; +import { SWITCH_TRACK_COLOR, themes } from '../../lib/constants'; import { withTheme } from '../../theme'; import SafeAreaView from '../../containers/SafeAreaView'; import { events, logEvent } from '../../utils/log'; diff --git a/app/views/CannedResponseDetail.tsx b/app/views/CannedResponseDetail.tsx index 91ea72c14..a4ef763f4 100644 --- a/app/views/CannedResponseDetail.tsx +++ b/app/views/CannedResponseDetail.tsx @@ -12,7 +12,7 @@ import { useTheme } from '../theme'; import RocketChat from '../lib/rocketchat'; import Navigation from '../lib/navigation/appNavigation'; import { goRoom } from '../utils/goRoom'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import Markdown from '../containers/markdown'; import { ICannedResponse } from '../definitions/ICannedResponse'; import { ChatsStackParamList } from '../stacks/types'; diff --git a/app/views/CannedResponsesListView/CannedResponseItem.tsx b/app/views/CannedResponsesListView/CannedResponseItem.tsx index d81e0e366..3b099a4f7 100644 --- a/app/views/CannedResponsesListView/CannedResponseItem.tsx +++ b/app/views/CannedResponsesListView/CannedResponseItem.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { View, Text } from 'react-native'; import Touchable from 'react-native-platform-touchable'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import Button from '../../containers/Button'; import I18n from '../../i18n'; import styles from './styles'; diff --git a/app/views/CannedResponsesListView/Dropdown/DropdownItem.tsx b/app/views/CannedResponsesListView/Dropdown/DropdownItem.tsx index ebae90378..274a9cef6 100644 --- a/app/views/CannedResponsesListView/Dropdown/DropdownItem.tsx +++ b/app/views/CannedResponsesListView/Dropdown/DropdownItem.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { useTheme } from '../../../theme'; import Touch from '../../../utils/touch'; import { CustomIcon } from '../../../lib/Icons'; diff --git a/app/views/CannedResponsesListView/Dropdown/index.tsx b/app/views/CannedResponsesListView/Dropdown/index.tsx index d723bc4c8..d0f295a0e 100644 --- a/app/views/CannedResponsesListView/Dropdown/index.tsx +++ b/app/views/CannedResponsesListView/Dropdown/index.tsx @@ -3,7 +3,7 @@ import { Animated, Easing, FlatList, TouchableWithoutFeedback } from 'react-nati import { withSafeAreaInsets } from 'react-native-safe-area-context'; import styles from '../styles'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { withTheme } from '../../../theme'; import * as List from '../../../containers/List'; import { IDepartment } from '../../../definitions/ICannedResponse'; diff --git a/app/views/CannedResponsesListView/index.tsx b/app/views/CannedResponsesListView/index.tsx index c273efd4a..f8514f2dc 100644 --- a/app/views/CannedResponsesListView/index.tsx +++ b/app/views/CannedResponsesListView/index.tsx @@ -20,7 +20,7 @@ import Navigation from '../../lib/navigation/appNavigation'; import { goRoom } from '../../utils/goRoom'; import * as HeaderButton from '../../containers/HeaderButton'; import * as List from '../../containers/List'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import log from '../../utils/log'; import CannedResponseItem from './CannedResponseItem'; import Dropdown from './Dropdown'; diff --git a/app/views/ChangePasscodeView.tsx b/app/views/ChangePasscodeView.tsx index a69d8f557..a10da7a76 100644 --- a/app/views/ChangePasscodeView.tsx +++ b/app/views/ChangePasscodeView.tsx @@ -11,8 +11,7 @@ import { hasNotch, isTablet } from '../utils/deviceInfo'; import { PasscodeChoose } from '../containers/Passcode'; import EventEmitter from '../utils/events'; import { CustomIcon } from '../lib/Icons'; -import { CHANGE_PASSCODE_EMITTER } from '../constants/localAuthentication'; -import { themes } from '../constants/colors'; +import { CHANGE_PASSCODE_EMITTER, themes } from '../lib/constants'; const styles = StyleSheet.create({ modal: { diff --git a/app/views/CreateChannelView.tsx b/app/views/CreateChannelView.tsx index 43df75fbf..e7893ba12 100644 --- a/app/views/CreateChannelView.tsx +++ b/app/views/CreateChannelView.tsx @@ -14,7 +14,7 @@ import I18n from '../i18n'; import UserItem from '../presentation/UserItem'; import * as HeaderButton from '../containers/HeaderButton'; import StatusBar from '../containers/StatusBar'; -import { SWITCH_TRACK_COLOR, themes } from '../constants/colors'; +import { SWITCH_TRACK_COLOR, themes } from '../lib/constants'; import { withTheme } from '../theme'; import { Review } from '../utils/review'; import { getUserSelector } from '../selectors/login'; diff --git a/app/views/CreateDiscussionView/SelectChannel.tsx b/app/views/CreateDiscussionView/SelectChannel.tsx index 641a53f47..c97f2c360 100644 --- a/app/views/CreateDiscussionView/SelectChannel.tsx +++ b/app/views/CreateDiscussionView/SelectChannel.tsx @@ -1,7 +1,7 @@ import React, { useState } from 'react'; import { Text } from 'react-native'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { MultiSelect } from '../../containers/UIKit/MultiSelect'; import { ISearchLocal } from '../../definitions'; import I18n from '../../i18n'; diff --git a/app/views/CreateDiscussionView/SelectUsers.tsx b/app/views/CreateDiscussionView/SelectUsers.tsx index cee43dfb5..39d77f479 100644 --- a/app/views/CreateDiscussionView/SelectUsers.tsx +++ b/app/views/CreateDiscussionView/SelectUsers.tsx @@ -9,7 +9,7 @@ import RocketChat from '../../lib/rocketchat'; import database from '../../lib/database'; import I18n from '../../i18n'; import { MultiSelect } from '../../containers/UIKit/MultiSelect'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import styles from './styles'; import { ICreateDiscussionViewSelectUsers } from './interfaces'; import { SubscriptionType } from '../../definitions/ISubscription'; diff --git a/app/views/CreateDiscussionView/index.tsx b/app/views/CreateDiscussionView/index.tsx index 936ce3f3e..67e467b27 100644 --- a/app/views/CreateDiscussionView/index.tsx +++ b/app/views/CreateDiscussionView/index.tsx @@ -9,7 +9,6 @@ import scrollPersistTaps from '../../utils/scrollPersistTaps'; import I18n from '../../i18n'; import * as HeaderButton from '../../containers/HeaderButton'; import StatusBar from '../../containers/StatusBar'; -import { SWITCH_TRACK_COLOR, themes } from '../../constants/colors'; import { withTheme } from '../../theme'; import { getUserSelector } from '../../selectors/login'; import TextInput from '../../containers/TextInput'; @@ -20,12 +19,12 @@ import { showErrorAlert } from '../../utils/info'; import SafeAreaView from '../../containers/SafeAreaView'; import { goRoom } from '../../utils/goRoom'; import { events, logEvent } from '../../utils/log'; -import { E2E_ROOM_TYPES } from '../../lib/constants'; import styles from './styles'; import SelectUsers from './SelectUsers'; import SelectChannel from './SelectChannel'; import { ICreateChannelViewProps, IResult, IError } from './interfaces'; import { IApplicationState } from '../../definitions'; +import { E2E_ROOM_TYPES, SWITCH_TRACK_COLOR, themes } from '../../lib/constants'; class CreateChannelView extends React.Component { private channel: any; diff --git a/app/views/DefaultBrowserView.tsx b/app/views/DefaultBrowserView.tsx index 23ef073bf..ddc1906fc 100644 --- a/app/views/DefaultBrowserView.tsx +++ b/app/views/DefaultBrowserView.tsx @@ -4,7 +4,7 @@ import { FlatList, Linking } from 'react-native'; import I18n from '../i18n'; import { withTheme } from '../theme'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import StatusBar from '../containers/StatusBar'; import * as List from '../containers/List'; import { DEFAULT_BROWSER_KEY } from '../utils/openLink'; diff --git a/app/views/DirectoryView/Options.tsx b/app/views/DirectoryView/Options.tsx index ed7a6526e..efe0d2f38 100644 --- a/app/views/DirectoryView/Options.tsx +++ b/app/views/DirectoryView/Options.tsx @@ -5,7 +5,7 @@ import Touch from '../../utils/touch'; import { CustomIcon } from '../../lib/Icons'; import Check from '../../containers/Check'; import I18n from '../../i18n'; -import { SWITCH_TRACK_COLOR, themes } from '../../constants/colors'; +import { SWITCH_TRACK_COLOR, themes } from '../../lib/constants'; import styles from './styles'; const ANIMATION_DURATION = 200; diff --git a/app/views/DirectoryView/index.tsx b/app/views/DirectoryView/index.tsx index 7e7efafca..9cc0c3749 100644 --- a/app/views/DirectoryView/index.tsx +++ b/app/views/DirectoryView/index.tsx @@ -18,7 +18,7 @@ import * as HeaderButton from '../../containers/HeaderButton'; import debounce from '../../utils/debounce'; import log, { events, logEvent } from '../../utils/log'; import { withTheme } from '../../theme'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { getUserSelector } from '../../selectors/login'; import SafeAreaView from '../../containers/SafeAreaView'; import { goRoom } from '../../utils/goRoom'; diff --git a/app/views/DiscussionsView/DiscussionDetails.tsx b/app/views/DiscussionsView/DiscussionDetails.tsx index 9ef19bbe9..169c13481 100644 --- a/app/views/DiscussionsView/DiscussionDetails.tsx +++ b/app/views/DiscussionsView/DiscussionDetails.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; import { CustomIcon } from '../../lib/Icons'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import sharedStyles from '../Styles'; import { useTheme } from '../../theme'; import { IMessageFromServer } from '../../definitions'; diff --git a/app/views/DiscussionsView/Item.stories.js b/app/views/DiscussionsView/Item.stories.js index f909600db..d47ecd71e 100644 --- a/app/views/DiscussionsView/Item.stories.js +++ b/app/views/DiscussionsView/Item.stories.js @@ -5,7 +5,7 @@ import { ScrollView } from 'react-native'; import { Provider } from 'react-redux'; import * as List from '../../containers/List'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { ThemeContext } from '../../theme'; import { store } from '../../../storybook/stories'; import Item from './Item'; diff --git a/app/views/DiscussionsView/Item.tsx b/app/views/DiscussionsView/Item.tsx index 41c3174c1..c86bf42e0 100644 --- a/app/views/DiscussionsView/Item.tsx +++ b/app/views/DiscussionsView/Item.tsx @@ -6,7 +6,7 @@ import moment from 'moment'; import { useTheme } from '../../theme'; import Avatar from '../../containers/Avatar'; import sharedStyles from '../Styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { MarkdownPreview } from '../../containers/markdown'; import { formatDateThreads, makeThreadName } from '../../utils/room'; import DiscussionDetails from './DiscussionDetails'; diff --git a/app/views/DiscussionsView/index.tsx b/app/views/DiscussionsView/index.tsx index 93963b0c5..f2be34802 100644 --- a/app/views/DiscussionsView/index.tsx +++ b/app/views/DiscussionsView/index.tsx @@ -12,7 +12,7 @@ import I18n from '../../i18n'; import StatusBar from '../../containers/StatusBar'; import log from '../../utils/log'; import debounce from '../../utils/debounce'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import SafeAreaView from '../../containers/SafeAreaView'; import * as HeaderButton from '../../containers/HeaderButton'; import * as List from '../../containers/List'; diff --git a/app/views/DisplayPrefsView.tsx b/app/views/DisplayPrefsView.tsx index 4405cd0a7..2c0565f7b 100644 --- a/app/views/DisplayPrefsView.tsx +++ b/app/views/DisplayPrefsView.tsx @@ -5,8 +5,7 @@ import { RadioButton } from 'react-native-ui-lib'; import { useDispatch, useSelector } from 'react-redux'; import { setPreference } from '../actions/sortPreferences'; -import { themes } from '../constants/colors'; -import { DisplayMode, SortBy } from '../constants/constantDisplayMode'; +import { DisplayMode, SortBy, themes } from '../lib/constants'; import * as HeaderButton from '../containers/HeaderButton'; import * as List from '../containers/List'; import { ICON_SIZE } from '../containers/List/constants'; diff --git a/app/views/E2EEncryptionSecurityView.tsx b/app/views/E2EEncryptionSecurityView.tsx index 5c7cbac09..7cf1dcba0 100644 --- a/app/views/E2EEncryptionSecurityView.tsx +++ b/app/views/E2EEncryptionSecurityView.tsx @@ -14,7 +14,7 @@ import TextInput from '../containers/TextInput'; import Button from '../containers/Button'; import { getUserSelector } from '../selectors/login'; import { PADDING_HORIZONTAL } from '../containers/List/constants'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import { Encryption } from '../lib/encryption'; import RocketChat from '../lib/rocketchat'; import { logout as logoutAction } from '../actions/login'; diff --git a/app/views/E2EEnterYourPasswordView.tsx b/app/views/E2EEnterYourPasswordView.tsx index 7b43e14c3..0486247ca 100644 --- a/app/views/E2EEnterYourPasswordView.tsx +++ b/app/views/E2EEnterYourPasswordView.tsx @@ -4,7 +4,7 @@ import { ScrollView, StyleSheet, Text, TextInput as RNTextInput } from 'react-na import { connect } from 'react-redux'; import { encryptionDecodeKey } from '../actions/encryption'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import Button from '../containers/Button'; import * as HeaderButton from '../containers/HeaderButton'; import SafeAreaView from '../containers/SafeAreaView'; diff --git a/app/views/E2EHowItWorksView.tsx b/app/views/E2EHowItWorksView.tsx index 607a196e7..8e1ed4245 100644 --- a/app/views/E2EHowItWorksView.tsx +++ b/app/views/E2EHowItWorksView.tsx @@ -4,7 +4,7 @@ import { RouteProp } from '@react-navigation/native'; import { StyleSheet } from 'react-native'; import SafeAreaView from '../containers/SafeAreaView'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import * as HeaderButton from '../containers/HeaderButton'; import Markdown from '../containers/markdown'; import { withTheme } from '../theme'; diff --git a/app/views/E2ESaveYourPasswordView.tsx b/app/views/E2ESaveYourPasswordView.tsx index 3d59fdfa3..663d05709 100644 --- a/app/views/E2ESaveYourPasswordView.tsx +++ b/app/views/E2ESaveYourPasswordView.tsx @@ -4,7 +4,6 @@ import Clipboard from '@react-native-clipboard/clipboard'; import { connect } from 'react-redux'; import { encryptionSetBanner } from '../actions/encryption'; -import { themes } from '../constants/colors'; import Button from '../containers/Button'; import * as HeaderButton from '../containers/HeaderButton'; import SafeAreaView from '../containers/SafeAreaView'; @@ -12,7 +11,7 @@ import StatusBar from '../containers/StatusBar'; import { LISTENER } from '../containers/Toast'; import { IApplicationState, IBaseScreen } from '../definitions'; import I18n from '../i18n'; -import { E2E_RANDOM_PASSWORD_KEY } from '../lib/constants'; +import { E2E_RANDOM_PASSWORD_KEY, themes } from '../lib/constants'; import UserPreferences from '../lib/methods/userPreferences'; import { E2ESaveYourPasswordStackParamList } from '../stacks/types'; import { withTheme } from '../theme'; diff --git a/app/views/ForgotPasswordView.tsx b/app/views/ForgotPasswordView.tsx index 0153f81fd..10a74e395 100644 --- a/app/views/ForgotPasswordView.tsx +++ b/app/views/ForgotPasswordView.tsx @@ -10,7 +10,7 @@ import isValidEmail from '../utils/isValidEmail'; import I18n from '../i18n'; import RocketChat from '../lib/rocketchat'; import { withTheme } from '../theme'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import FormContainer, { FormContainerInner } from '../containers/FormContainer'; import { events, logEvent } from '../utils/log'; import sharedStyles from './Styles'; diff --git a/app/views/ForwardLivechatView.tsx b/app/views/ForwardLivechatView.tsx index 9361e45f5..0df66356c 100644 --- a/app/views/ForwardLivechatView.tsx +++ b/app/views/ForwardLivechatView.tsx @@ -4,7 +4,7 @@ import { StyleSheet, View } from 'react-native'; import { useDispatch } from 'react-redux'; import { forwardRoom, ITransferData } from '../actions/room'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import OrSeparator from '../containers/OrSeparator'; import Input from '../containers/UIKit/MultiSelect/Input'; import { IBaseScreen, IServerRoom } from '../definitions'; diff --git a/app/views/InviteUsersEditView/index.tsx b/app/views/InviteUsersEditView/index.tsx index 10f356ae3..7e984d60c 100644 --- a/app/views/InviteUsersEditView/index.tsx +++ b/app/views/InviteUsersEditView/index.tsx @@ -5,7 +5,7 @@ import RNPickerSelect from 'react-native-picker-select'; import { connect } from 'react-redux'; import { inviteLinksCreate, inviteLinksSetParams } from '../../actions/inviteLinks'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import Button from '../../containers/Button'; import * as List from '../../containers/List'; import SafeAreaView from '../../containers/SafeAreaView'; diff --git a/app/views/InviteUsersView/index.tsx b/app/views/InviteUsersView/index.tsx index 5f10b32be..c7a6f225d 100644 --- a/app/views/InviteUsersView/index.tsx +++ b/app/views/InviteUsersView/index.tsx @@ -5,7 +5,7 @@ import { ScrollView, Share, View } from 'react-native'; import { connect } from 'react-redux'; import { inviteLinksClear, inviteLinksCreate } from '../../actions/inviteLinks'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import Button from '../../containers/Button'; import Markdown from '../../containers/markdown'; import SafeAreaView from '../../containers/SafeAreaView'; diff --git a/app/views/LanguageView/index.tsx b/app/views/LanguageView/index.tsx index af45f41ab..bd68834f6 100644 --- a/app/views/LanguageView/index.tsx +++ b/app/views/LanguageView/index.tsx @@ -5,7 +5,7 @@ import { connect } from 'react-redux'; import { appStart } from '../../actions/app'; import { setUser } from '../../actions/login'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import * as List from '../../containers/List'; import SafeAreaView from '../../containers/SafeAreaView'; import StatusBar from '../../containers/StatusBar'; diff --git a/app/views/LivechatEditView.tsx b/app/views/LivechatEditView.tsx index bbd0d8ac7..4201168a0 100644 --- a/app/views/LivechatEditView.tsx +++ b/app/views/LivechatEditView.tsx @@ -6,7 +6,7 @@ import { connect } from 'react-redux'; import { BLOCK_CONTEXT } from '@rocket.chat/ui-kit'; import { withTheme } from '../theme'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import TextInput from '../containers/TextInput'; import KeyboardView from '../presentation/KeyboardView'; import RocketChat from '../lib/rocketchat'; diff --git a/app/views/LoginView.tsx b/app/views/LoginView.tsx index 0f66cba65..fcb548f25 100644 --- a/app/views/LoginView.tsx +++ b/app/views/LoginView.tsx @@ -4,7 +4,7 @@ import { Alert, Keyboard, StyleSheet, Text, View } from 'react-native'; import { connect } from 'react-redux'; import { loginRequest } from '../actions/login'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import Button from '../containers/Button'; import FormContainer, { FormContainerInner } from '../containers/FormContainer'; import * as HeaderButton from '../containers/HeaderButton'; diff --git a/app/views/MarkdownTableView.tsx b/app/views/MarkdownTableView.tsx index e260199e0..fa0f16a24 100644 --- a/app/views/MarkdownTableView.tsx +++ b/app/views/MarkdownTableView.tsx @@ -5,7 +5,7 @@ import { RouteProp } from '@react-navigation/native'; import I18n from '../i18n'; import { isIOS } from '../utils/deviceInfo'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import { withTheme } from '../theme'; import { ChatsStackParamList } from '../stacks/types'; diff --git a/app/views/MessagesView/index.tsx b/app/views/MessagesView/index.tsx index 4eef9e8f7..a3f1ce658 100644 --- a/app/views/MessagesView/index.tsx +++ b/app/views/MessagesView/index.tsx @@ -12,7 +12,7 @@ import I18n from '../../i18n'; import RocketChat from '../../lib/rocketchat'; import StatusBar from '../../containers/StatusBar'; import getFileUrlFromMessage from '../../lib/methods/helpers/getFileUrlFromMessage'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { withTheme } from '../../theme'; import { getUserSelector } from '../../selectors/login'; import { withActionSheet } from '../../containers/ActionSheet'; diff --git a/app/views/ModalBlockView.tsx b/app/views/ModalBlockView.tsx index 119f45d7f..3aa134c8e 100644 --- a/app/views/ModalBlockView.tsx +++ b/app/views/ModalBlockView.tsx @@ -7,7 +7,7 @@ import { KeyboardAwareScrollView } from '@codler/react-native-keyboard-aware-scr import { withTheme } from '../theme'; import EventEmitter from '../utils/events'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import * as HeaderButton from '../containers/HeaderButton'; import { modalBlockWithContext } from '../containers/UIKit/MessageBlock'; import RocketChat from '../lib/rocketchat'; diff --git a/app/views/NewMessageView.tsx b/app/views/NewMessageView.tsx index cfc7f0c7c..0304b7007 100644 --- a/app/views/NewMessageView.tsx +++ b/app/views/NewMessageView.tsx @@ -6,7 +6,7 @@ import { FlatList, StyleSheet, Text, View } from 'react-native'; import { connect } from 'react-redux'; import { createChannelRequest } from '../actions/createChannel'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import * as HeaderButton from '../containers/HeaderButton'; import * as List from '../containers/List'; import SafeAreaView from '../containers/SafeAreaView'; diff --git a/app/views/NewServerView/ServerInput/Item.tsx b/app/views/NewServerView/ServerInput/Item.tsx index a73f455a0..b873bbba3 100644 --- a/app/views/NewServerView/ServerInput/Item.tsx +++ b/app/views/NewServerView/ServerInput/Item.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; import { BorderlessButton } from 'react-native-gesture-handler'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { CustomIcon } from '../../../lib/Icons'; import sharedStyles from '../../Styles'; import Touch from '../../../utils/touch'; diff --git a/app/views/NewServerView/ServerInput/index.tsx b/app/views/NewServerView/ServerInput/index.tsx index 7868754f3..fd7961762 100644 --- a/app/views/NewServerView/ServerInput/index.tsx +++ b/app/views/NewServerView/ServerInput/index.tsx @@ -3,7 +3,7 @@ import { FlatList, StyleSheet, TextInputProps, View } from 'react-native'; import TextInput from '../../../containers/TextInput'; import * as List from '../../../containers/List'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import I18n from '../../../i18n'; import { TServerHistoryModel } from '../../../definitions/IServerHistory'; import Item from './Item'; diff --git a/app/views/NewServerView/index.tsx b/app/views/NewServerView/index.tsx index e5e775ab6..20da385f2 100644 --- a/app/views/NewServerView/index.tsx +++ b/app/views/NewServerView/index.tsx @@ -9,7 +9,7 @@ import parse from 'url-parse'; import { inviteLinksClear } from '../../actions/inviteLinks'; import { selectServerRequest, serverFinishAdd, serverRequest } from '../../actions/server'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import Button from '../../containers/Button'; import FormContainer, { FormContainerInner } from '../../containers/FormContainer'; import * as HeaderButton from '../../containers/HeaderButton'; diff --git a/app/views/NotificationPreferencesView/index.tsx b/app/views/NotificationPreferencesView/index.tsx index bf76d9e38..34590a7e8 100644 --- a/app/views/NotificationPreferencesView/index.tsx +++ b/app/views/NotificationPreferencesView/index.tsx @@ -6,7 +6,7 @@ import Model from '@nozbe/watermelondb/Model'; import { Observable, Subscription } from 'rxjs'; import database from '../../lib/database'; -import { SWITCH_TRACK_COLOR, themes } from '../../constants/colors'; +import { SWITCH_TRACK_COLOR, themes } from '../../lib/constants'; import StatusBar from '../../containers/StatusBar'; import * as List from '../../containers/List'; import I18n from '../../i18n'; diff --git a/app/views/PickerView.tsx b/app/views/PickerView.tsx index c00d00c83..3bb480b15 100644 --- a/app/views/PickerView.tsx +++ b/app/views/PickerView.tsx @@ -5,7 +5,7 @@ import { FlatList, StyleSheet, Text, View } from 'react-native'; import I18n from '../i18n'; import { withTheme } from '../theme'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import debounce from '../utils/debounce'; import * as List from '../containers/List'; import SearchBox from '../containers/SearchBox'; diff --git a/app/views/ProfileView/index.tsx b/app/views/ProfileView/index.tsx index d7ecbc399..2d0724f8f 100644 --- a/app/views/ProfileView/index.tsx +++ b/app/views/ProfileView/index.tsx @@ -26,7 +26,7 @@ import { setUser as setUserAction } from '../../actions/login'; import { CustomIcon } from '../../lib/Icons'; import * as HeaderButton from '../../containers/HeaderButton'; import StatusBar from '../../containers/StatusBar'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { withTheme } from '../../theme'; import { getUserSelector } from '../../selectors/login'; import SafeAreaView from '../../containers/SafeAreaView'; diff --git a/app/views/ReadReceiptView/index.tsx b/app/views/ReadReceiptView/index.tsx index 01e628302..e997538cb 100644 --- a/app/views/ReadReceiptView/index.tsx +++ b/app/views/ReadReceiptView/index.tsx @@ -13,7 +13,7 @@ import I18n from '../../i18n'; import RocketChat from '../../lib/rocketchat'; import StatusBar from '../../containers/StatusBar'; import { withTheme } from '../../theme'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import SafeAreaView from '../../containers/SafeAreaView'; import styles from './styles'; import { ChatsStackParamList } from '../../stacks/types'; diff --git a/app/views/RegisterView.tsx b/app/views/RegisterView.tsx index b9e43bec3..b0dd24af6 100644 --- a/app/views/RegisterView.tsx +++ b/app/views/RegisterView.tsx @@ -4,7 +4,7 @@ import RNPickerSelect from 'react-native-picker-select'; import { connect } from 'react-redux'; import { loginRequest } from '../actions/login'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import Button from '../containers/Button'; import FormContainer, { FormContainerInner } from '../containers/FormContainer'; import * as HeaderButton from '../containers/HeaderButton'; diff --git a/app/views/RoomActionsView/index.tsx b/app/views/RoomActionsView/index.tsx index d3e2d3e88..8b668e735 100644 --- a/app/views/RoomActionsView/index.tsx +++ b/app/views/RoomActionsView/index.tsx @@ -8,7 +8,6 @@ import { Observable, Subscription } from 'rxjs'; import { closeRoom, leaveRoom } from '../../actions/room'; import { setLoading } from '../../actions/selectedUsers'; -import { SWITCH_TRACK_COLOR, themes } from '../../constants/colors'; import Avatar from '../../containers/Avatar'; import * as HeaderButton from '../../containers/HeaderButton'; import * as List from '../../containers/List'; @@ -21,7 +20,6 @@ import { IApplicationState, IBaseScreen, IRoom, ISubscription, IUser, TSubscript import { withDimensions } from '../../dimensions'; import I18n from '../../i18n'; 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 { getUserSelector } from '../../selectors/login'; @@ -33,6 +31,7 @@ import Touch from '../../utils/touch'; import sharedStyles from '../Styles'; import styles from './styles'; import { ERoomType } from '../../definitions/ERoomType'; +import { E2E_ROOM_TYPES, SWITCH_TRACK_COLOR, themes } from '../../lib/constants'; import { compareServerVersion } from '../../lib/methods/helpers/compareServerVersion'; interface IRoomActionsViewProps extends IBaseScreen { diff --git a/app/views/RoomInfoEditView/SwitchContainer.tsx b/app/views/RoomInfoEditView/SwitchContainer.tsx index 0ae854e7e..7010a6bd1 100644 --- a/app/views/RoomInfoEditView/SwitchContainer.tsx +++ b/app/views/RoomInfoEditView/SwitchContainer.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { Switch, Text, TextStyle, View, ViewStyle } from 'react-native'; -import { SWITCH_TRACK_COLOR, themes } from '../../constants/colors'; +import { SWITCH_TRACK_COLOR, themes } from '../../lib/constants'; import styles from './styles'; interface ISwitchContainer { diff --git a/app/views/RoomInfoEditView/index.tsx b/app/views/RoomInfoEditView/index.tsx index bebd8f502..d96b1553b 100644 --- a/app/views/RoomInfoEditView/index.tsx +++ b/app/views/RoomInfoEditView/index.tsx @@ -8,7 +8,7 @@ import ImagePicker, { Image } from 'react-native-image-crop-picker'; import { connect } from 'react-redux'; import { deleteRoom } from '../../actions/room'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import Avatar from '../../containers/Avatar'; import Loading from '../../containers/Loading'; import SafeAreaView from '../../containers/SafeAreaView'; diff --git a/app/views/RoomInfoView/Direct.tsx b/app/views/RoomInfoView/Direct.tsx index b9e9e0da7..a3dffced3 100644 --- a/app/views/RoomInfoView/Direct.tsx +++ b/app/views/RoomInfoView/Direct.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { Text, View } from 'react-native'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import I18n from '../../i18n'; import { useTheme } from '../../theme'; import Timezone from './Timezone'; diff --git a/app/views/RoomInfoView/Item.tsx b/app/views/RoomInfoView/Item.tsx index 7296f6542..bc37e6b60 100644 --- a/app/views/RoomInfoView/Item.tsx +++ b/app/views/RoomInfoView/Item.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Text, View } from 'react-native'; import Markdown from '../../containers/markdown'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { useTheme } from '../../theme'; import styles from './styles'; diff --git a/app/views/RoomInfoView/Livechat.tsx b/app/views/RoomInfoView/Livechat.tsx index ddc630979..e0d8ba316 100644 --- a/app/views/RoomInfoView/Livechat.tsx +++ b/app/views/RoomInfoView/Livechat.tsx @@ -4,7 +4,7 @@ import { StyleSheet, Text } from 'react-native'; import RocketChat from '../../lib/rocketchat'; import { useTheme } from '../../theme'; import sharedStyles from '../Styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import I18n from '../../i18n'; import { ISubscription } from '../../definitions'; import { ILivechatVisitorModified } from './index'; diff --git a/app/views/RoomInfoView/index.tsx b/app/views/RoomInfoView/index.tsx index dfcbd95ed..528b9e067 100644 --- a/app/views/RoomInfoView/index.tsx +++ b/app/views/RoomInfoView/index.tsx @@ -18,7 +18,7 @@ import I18n from '../../i18n'; import * as HeaderButton from '../../containers/HeaderButton'; import StatusBar from '../../containers/StatusBar'; import log, { events, logEvent } from '../../utils/log'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { withTheme } from '../../theme'; import { MarkdownPreview } from '../../containers/markdown'; import { LISTENER } from '../../containers/Toast'; diff --git a/app/views/RoomMembersView/index.tsx b/app/views/RoomMembersView/index.tsx index 866924cbe..61a2be851 100644 --- a/app/views/RoomMembersView/index.tsx +++ b/app/views/RoomMembersView/index.tsx @@ -4,7 +4,7 @@ import { FlatList } from 'react-native'; import { connect } from 'react-redux'; import { Observable, Subscription } from 'rxjs'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { withActionSheet } from '../../containers/ActionSheet'; import ActivityIndicator from '../../containers/ActivityIndicator'; import * as HeaderButton from '../../containers/HeaderButton'; diff --git a/app/views/RoomView/Banner.tsx b/app/views/RoomView/Banner.tsx index e88cfe7e2..bbfe254e0 100644 --- a/app/views/RoomView/Banner.tsx +++ b/app/views/RoomView/Banner.tsx @@ -5,7 +5,7 @@ import Modal from 'react-native-modal'; import Markdown, { MarkdownPreview } from '../../containers/markdown'; import { CustomIcon } from '../../lib/Icons'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import styles from './styles'; import { useTheme } from '../../theme'; diff --git a/app/views/RoomView/JoinCode.tsx b/app/views/RoomView/JoinCode.tsx index 741de6218..8b6bb7e87 100644 --- a/app/views/RoomView/JoinCode.tsx +++ b/app/views/RoomView/JoinCode.tsx @@ -8,7 +8,7 @@ import Button from '../../containers/Button'; import TextInput from '../../containers/TextInput'; import RocketChat from '../../lib/rocketchat'; import sharedStyles from '../Styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { IApplicationState } from '../../definitions'; const styles = StyleSheet.create({ diff --git a/app/views/RoomView/LeftButtons.tsx b/app/views/RoomView/LeftButtons.tsx index b57409c10..a1639e652 100644 --- a/app/views/RoomView/LeftButtons.tsx +++ b/app/views/RoomView/LeftButtons.tsx @@ -2,7 +2,7 @@ import React, { useCallback } from 'react'; import { StyleSheet } from 'react-native'; import { HeaderBackButton, StackNavigationProp } from '@react-navigation/stack'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import Avatar from '../../containers/Avatar'; import { ChatsStackParamList } from '../../stacks/types'; diff --git a/app/views/RoomView/List/NavBottomFAB.tsx b/app/views/RoomView/List/NavBottomFAB.tsx index 0fb3c7f19..e1fbdaafa 100644 --- a/app/views/RoomView/List/NavBottomFAB.tsx +++ b/app/views/RoomView/List/NavBottomFAB.tsx @@ -2,7 +2,7 @@ import React, { useState } from 'react'; import { StyleSheet, View } from 'react-native'; import Animated, { call, cond, greaterOrEq, useCode } from 'react-native-reanimated'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { CustomIcon } from '../../../lib/Icons'; import { useTheme } from '../../../theme'; import Touch from '../../../utils/touch'; diff --git a/app/views/RoomView/List/index.tsx b/app/views/RoomView/List/index.tsx index eae6fa8c7..11802973f 100644 --- a/app/views/RoomView/List/index.tsx +++ b/app/views/RoomView/List/index.tsx @@ -6,7 +6,7 @@ import { FlatListProps, RefreshControl, ViewToken } from 'react-native'; import { event, Value } from 'react-native-reanimated'; import { Observable, Subscription } from 'rxjs'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import ActivityIndicator from '../../../containers/ActivityIndicator'; import { TAnyMessageModel, TMessageModel, TThreadMessageModel, TThreadModel } from '../../../definitions'; import database from '../../../lib/database'; diff --git a/app/views/RoomView/LoadMore/LoadMore.stories.js b/app/views/RoomView/LoadMore/LoadMore.stories.js index 7f8137d1c..8d13d55ca 100644 --- a/app/views/RoomView/LoadMore/LoadMore.stories.js +++ b/app/views/RoomView/LoadMore/LoadMore.stories.js @@ -6,8 +6,7 @@ import { storiesOf } from '@storybook/react-native'; import { longText } from '../../../../storybook/utils'; import { ThemeContext } from '../../../theme'; import { Message, MessageDecorator, StoryProvider } from '../../../../storybook/stories/Message'; -import { themes } from '../../../constants/colors'; -import { MessageTypeLoad } from '../../../constants/messageTypeLoad'; +import { MessageTypeLoad, themes } from '../../../lib/constants'; import LoadMore from './index'; const stories = storiesOf('LoadMore', module); diff --git a/app/views/RoomView/LoadMore/index.tsx b/app/views/RoomView/LoadMore/index.tsx index 7dcd85ea6..fcd353924 100644 --- a/app/views/RoomView/LoadMore/index.tsx +++ b/app/views/RoomView/LoadMore/index.tsx @@ -1,8 +1,7 @@ import React, { useCallback, useEffect, useState } from 'react'; import { ActivityIndicator, StyleSheet, Text } from 'react-native'; -import { themes } from '../../../constants/colors'; -import { MessageTypeLoad } from '../../../constants/messageTypeLoad'; +import { MessageTypeLoad, themes } from '../../../lib/constants'; import { MessageType } from '../../../definitions'; import { useTheme } from '../../../theme'; import Touch from '../../../utils/touch'; diff --git a/app/views/RoomView/ReactionPicker.tsx b/app/views/RoomView/ReactionPicker.tsx index b47711b6e..9af5a714a 100644 --- a/app/views/RoomView/ReactionPicker.tsx +++ b/app/views/RoomView/ReactionPicker.tsx @@ -5,7 +5,7 @@ import Modal from 'react-native-modal'; import EmojiPicker from '../../containers/EmojiPicker'; import { isAndroid } from '../../utils/deviceInfo'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { withTheme } from '../../theme'; import styles from './styles'; import { IApplicationState } from '../../definitions'; diff --git a/app/views/RoomView/Separator.tsx b/app/views/RoomView/Separator.tsx index 8a125cf7d..9803ae72b 100644 --- a/app/views/RoomView/Separator.tsx +++ b/app/views/RoomView/Separator.tsx @@ -4,7 +4,7 @@ import moment from 'moment'; import I18n from '../../i18n'; import sharedStyles from '../Styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { useTheme } from '../../theme'; const styles = StyleSheet.create({ diff --git a/app/views/RoomView/UploadProgress.tsx b/app/views/RoomView/UploadProgress.tsx index fba6e9358..28a6b5966 100644 --- a/app/views/RoomView/UploadProgress.tsx +++ b/app/views/RoomView/UploadProgress.tsx @@ -8,7 +8,7 @@ import RocketChat from '../../lib/rocketchat'; import log from '../../utils/log'; import I18n from '../../i18n'; import { CustomIcon } from '../../lib/Icons'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import sharedStyles from '../Styles'; import { withTheme } from '../../theme'; import { IUser, TUploadModel } from '../../definitions'; diff --git a/app/views/RoomView/index.tsx b/app/views/RoomView/index.tsx index 7ff56c8b4..4cd521ad8 100644 --- a/app/views/RoomView/index.tsx +++ b/app/views/RoomView/index.tsx @@ -23,8 +23,6 @@ import EventEmitter from '../../utils/events'; import I18n from '../../i18n'; import RoomHeader from '../../containers/RoomHeader'; import StatusBar from '../../containers/StatusBar'; -import { themes } from '../../constants/colors'; -import { MESSAGE_TYPE_ANY_LOAD, MessageTypeLoad } from '../../constants/messageTypeLoad'; import debounce from '../../utils/debounce'; import ReactionsModal from '../../containers/ReactionsModal'; import { LISTENER } from '../../containers/Toast'; @@ -48,7 +46,6 @@ import Navigation from '../../lib/navigation/appNavigation'; import SafeAreaView from '../../containers/SafeAreaView'; import { withDimensions } from '../../dimensions'; import { getHeaderTitlePosition } from '../../containers/Header'; -import { E2E_MESSAGE_TYPE, E2E_STATUS } from '../../lib/constants'; import { takeInquiry } from '../../ee/omnichannel/lib'; import Loading from '../../containers/Loading'; import { goRoom, TGoRoomItem } from '../../utils/goRoom'; @@ -82,6 +79,7 @@ import { TThreadModel } from '../../definitions'; import { ICustomEmojis } from '../../reducers/customEmojis'; +import { E2E_MESSAGE_TYPE, E2E_STATUS, MESSAGE_TYPE_ANY_LOAD, MessageTypeLoad, themes } from '../../lib/constants'; const stateAttrsUpdate = [ 'joined', diff --git a/app/views/RoomView/services/getMoreMessages.ts b/app/views/RoomView/services/getMoreMessages.ts index 99e22bbc4..d8e5b16e8 100644 --- a/app/views/RoomView/services/getMoreMessages.ts +++ b/app/views/RoomView/services/getMoreMessages.ts @@ -1,7 +1,7 @@ import { SubscriptionType, TAnyMessageModel } from '../../../definitions'; import loadMessagesForRoom from '../../../lib/methods/loadMessagesForRoom'; import loadNextMessages from '../../../lib/methods/loadNextMessages'; -import { MessageTypeLoad } from '../../../constants/messageTypeLoad'; +import { MessageTypeLoad } from '../../../lib/constants'; const getMoreMessages = ({ rid, diff --git a/app/views/RoomsListView/Header/Header.tsx b/app/views/RoomsListView/Header/Header.tsx index 581cfacf8..316cc34bd 100644 --- a/app/views/RoomsListView/Header/Header.tsx +++ b/app/views/RoomsListView/Header/Header.tsx @@ -4,7 +4,7 @@ import { StyleSheet, Text, TextInputProps, TouchableOpacity, TouchableOpacityPro import TextInput from '../../../presentation/TextInput'; import I18n from '../../../i18n'; import sharedStyles from '../../Styles'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { CustomIcon } from '../../../lib/Icons'; import { isIOS, isTablet } from '../../../utils/deviceInfo'; import { useOrientation } from '../../../dimensions'; diff --git a/app/views/RoomsListView/ListHeader/index.tsx b/app/views/RoomsListView/ListHeader/index.tsx index 1dbe9eb3b..57ee9a7bc 100644 --- a/app/views/RoomsListView/ListHeader/index.tsx +++ b/app/views/RoomsListView/ListHeader/index.tsx @@ -2,10 +2,9 @@ import React from 'react'; import { useTheme } from '../../../theme'; import * as List from '../../../containers/List'; -import { E2E_BANNER_TYPE } from '../../../lib/constants'; -import { themes } from '../../../constants/colors'; import OmnichannelStatus from '../../../ee/omnichannel/containers/OmnichannelStatus'; import { IUser } from '../../../definitions'; +import { E2E_BANNER_TYPE, themes } from '../../../lib/constants'; export type TEncryptionBanner = 'REQUEST_PASSWORD' | 'SAVE_PASSWORD'; diff --git a/app/views/RoomsListView/ServerDropdown.tsx b/app/views/RoomsListView/ServerDropdown.tsx index 408088291..e7db06a9b 100644 --- a/app/views/RoomsListView/ServerDropdown.tsx +++ b/app/views/RoomsListView/ServerDropdown.tsx @@ -14,7 +14,7 @@ import I18n from '../../i18n'; import EventEmitter from '../../utils/events'; import ServerItem from '../../presentation/ServerItem'; import database from '../../lib/database'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { withTheme } from '../../theme'; import { KEY_COMMAND, handleCommandSelectServer, IKeyCommandEvent } from '../../commands'; import { isTablet } from '../../utils/deviceInfo'; diff --git a/app/views/RoomsListView/index.tsx b/app/views/RoomsListView/index.tsx index e2367b06d..d26e403ba 100644 --- a/app/views/RoomsListView/index.tsx +++ b/app/views/RoomsListView/index.tsx @@ -23,7 +23,6 @@ import ActivityIndicator from '../../containers/ActivityIndicator'; import { serverInitAdd } from '../../actions/server'; import { animateNextTransition } from '../../utils/layoutAnimation'; import { withTheme } from '../../theme'; -import { themes } from '../../constants/colors'; import EventEmitter from '../../utils/events'; import { KEY_COMMAND, @@ -36,24 +35,22 @@ import { handleCommandShowPreferences, IKeyCommandEvent } from '../../commands'; -import { MAX_SIDEBAR_WIDTH } from '../../constants/tablet'; import { getUserSelector } from '../../selectors/login'; import { goRoom } from '../../utils/goRoom'; import SafeAreaView from '../../containers/SafeAreaView'; import Header, { getHeaderTitlePosition } from '../../containers/Header'; import { withDimensions } from '../../dimensions'; import { showConfirmationAlert, showErrorAlert } from '../../utils/info'; -import { E2E_BANNER_TYPE } from '../../lib/constants'; import { getInquiryQueueSelector } from '../../ee/omnichannel/selectors/inquiry'; import { changeLivechatStatus, isOmnichannelStatusAvailable } from '../../ee/omnichannel/lib'; import { IApplicationState, IBaseScreen, ISubscription, IUser, RootEnum, TSubscriptionModel } from '../../definitions'; -import { DisplayMode, SortBy } from '../../constants/constantDisplayMode'; import styles from './styles'; import ServerDropdown from './ServerDropdown'; import ListHeader, { TEncryptionBanner } from './ListHeader'; import RoomsListHeaderView from './Header'; import { ChatsStackParamList } from '../../stacks/types'; import { RoomTypes } from '../../lib/methods/roomTypeToApiType'; +import { E2E_BANNER_TYPE, DisplayMode, SortBy, MAX_SIDEBAR_WIDTH, themes } from '../../lib/constants'; interface IRoomsListViewProps extends IBaseScreen { [key: string]: any; diff --git a/app/views/ScreenLockConfigView.tsx b/app/views/ScreenLockConfigView.tsx index 0c80123e6..febcbed63 100644 --- a/app/views/ScreenLockConfigView.tsx +++ b/app/views/ScreenLockConfigView.tsx @@ -6,12 +6,11 @@ import { Subscription } from 'rxjs'; import I18n from '../i18n'; import { withTheme } from '../theme'; -import { SWITCH_TRACK_COLOR, themes } from '../constants/colors'; import StatusBar from '../containers/StatusBar'; import * as List from '../containers/List'; import database from '../lib/database'; import { changePasscode, checkHasPasscode, supportedBiometryLabel } from '../utils/localAuthentication'; -import { BIOMETRY_ENABLED_KEY, DEFAULT_AUTO_LOCK } from '../constants/localAuthentication'; +import { BIOMETRY_ENABLED_KEY, DEFAULT_AUTO_LOCK, themes, SWITCH_TRACK_COLOR } from '../lib/constants'; import SafeAreaView from '../containers/SafeAreaView'; import { events, logEvent } from '../utils/log'; import { TServerModel } from '../definitions/IServer'; diff --git a/app/views/ScreenLockedView.tsx b/app/views/ScreenLockedView.tsx index c6e2efa0a..b4306688a 100644 --- a/app/views/ScreenLockedView.tsx +++ b/app/views/ScreenLockedView.tsx @@ -5,7 +5,7 @@ import isEmpty from 'lodash/isEmpty'; import Orientation from 'react-native-orientation-locker'; import EventEmitter from '../utils/events'; -import { LOCAL_AUTHENTICATE_EMITTER } from '../constants/localAuthentication'; +import { LOCAL_AUTHENTICATE_EMITTER } from '../lib/constants'; import { isTablet } from '../utils/deviceInfo'; import { PasscodeEnter } from '../containers/Passcode'; diff --git a/app/views/SearchMessagesView/index.tsx b/app/views/SearchMessagesView/index.tsx index ec8cc6d84..e4c74f93f 100644 --- a/app/views/SearchMessagesView/index.tsx +++ b/app/views/SearchMessagesView/index.tsx @@ -19,7 +19,7 @@ import { IMessage } from '../../containers/message/interfaces'; import I18n from '../../i18n'; import StatusBar from '../../containers/StatusBar'; import log from '../../utils/log'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { withTheme } from '../../theme'; import { getUserSelector } from '../../selectors/login'; import SafeAreaView from '../../containers/SafeAreaView'; diff --git a/app/views/SecurityPrivacyView.tsx b/app/views/SecurityPrivacyView.tsx index 529964752..b62d1ad09 100644 --- a/app/views/SecurityPrivacyView.tsx +++ b/app/views/SecurityPrivacyView.tsx @@ -4,7 +4,6 @@ import { StackNavigationProp } from '@react-navigation/stack'; import AsyncStorage from '@react-native-community/async-storage'; import { useSelector } from 'react-redux'; -import { SWITCH_TRACK_COLOR } from '../constants/colors'; import StatusBar from '../containers/StatusBar'; import * as List from '../containers/List'; import I18n from '../i18n'; @@ -17,8 +16,7 @@ import { getReportAnalyticsEventsValue } from '../utils/log'; import SafeAreaView from '../containers/SafeAreaView'; -import { isFDroidBuild } from '../constants/environment'; -import { ANALYTICS_EVENTS_KEY, CRASH_REPORT_KEY } from '../lib/constants'; +import { ANALYTICS_EVENTS_KEY, CRASH_REPORT_KEY, isFDroidBuild, SWITCH_TRACK_COLOR } from '../lib/constants'; interface ISecurityPrivacyViewProps { navigation: StackNavigationProp; diff --git a/app/views/SelectListView.tsx b/app/views/SelectListView.tsx index 5a3a2d701..fffcecb45 100644 --- a/app/views/SelectListView.tsx +++ b/app/views/SelectListView.tsx @@ -11,7 +11,7 @@ import * as List from '../containers/List'; import I18n from '../i18n'; import * as HeaderButton from '../containers/HeaderButton'; import StatusBar from '../containers/StatusBar'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import { withTheme } from '../theme'; import SafeAreaView from '../containers/SafeAreaView'; import { animateNextTransition } from '../utils/layoutAnimation'; diff --git a/app/views/SelectedUsersView.tsx b/app/views/SelectedUsersView.tsx index 2ce51b35d..dfe62aaf4 100644 --- a/app/views/SelectedUsersView.tsx +++ b/app/views/SelectedUsersView.tsx @@ -6,7 +6,7 @@ import { connect } from 'react-redux'; import { Subscription } from 'rxjs'; import { addUser, removeUser, reset } from '../actions/selectedUsers'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import * as HeaderButton from '../containers/HeaderButton'; import * as List from '../containers/List'; import Loading from '../containers/Loading'; diff --git a/app/views/SetUsernameView.tsx b/app/views/SetUsernameView.tsx index 4c9aa91f0..50b865082 100644 --- a/app/views/SetUsernameView.tsx +++ b/app/views/SetUsernameView.tsx @@ -7,7 +7,7 @@ import { connect } from 'react-redux'; import { Dispatch } from 'redux'; import { loginRequest } from '../actions/login'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import Button from '../containers/Button'; import SafeAreaView from '../containers/SafeAreaView'; import StatusBar from '../containers/StatusBar'; diff --git a/app/views/SettingsView/index.tsx b/app/views/SettingsView/index.tsx index 21e5bfae9..715d8eea9 100644 --- a/app/views/SettingsView/index.tsx +++ b/app/views/SettingsView/index.tsx @@ -9,9 +9,7 @@ import { connect } from 'react-redux'; import { appStart } from '../../actions/app'; import { logout } from '../../actions/login'; import { selectServerRequest } from '../../actions/server'; -import { themes } from '../../constants/colors'; -import { isFDroidBuild } from '../../constants/environment'; -import { APP_STORE_LINK, FDROID_MARKET_LINK, LICENSE_LINK, PLAY_MARKET_LINK } from '../../constants/links'; +import { APP_STORE_LINK, FDROID_MARKET_LINK, LICENSE_LINK, PLAY_MARKET_LINK, isFDroidBuild, themes } from '../../lib/constants'; import * as HeaderButton from '../../containers/HeaderButton'; import * as List from '../../containers/List'; import SafeAreaView from '../../containers/SafeAreaView'; diff --git a/app/views/ShareListView/Header/Header.ios.tsx b/app/views/ShareListView/Header/Header.ios.tsx index c1f5e1166..7b01bd9b2 100644 --- a/app/views/ShareListView/Header/Header.ios.tsx +++ b/app/views/ShareListView/Header/Header.ios.tsx @@ -4,7 +4,7 @@ import ShareExtension from 'rn-extensions-share'; import SearchBox from '../../../containers/SearchBox'; import * as HeaderButton from '../../../containers/HeaderButton'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import sharedStyles from '../../Styles'; import { animateNextTransition } from '../../../utils/layoutAnimation'; import { IShareListHeaderIos } from './interface'; diff --git a/app/views/ShareListView/Header/Header.tsx b/app/views/ShareListView/Header/Header.tsx index 616f3f487..a3b017c48 100644 --- a/app/views/ShareListView/Header/Header.tsx +++ b/app/views/ShareListView/Header/Header.tsx @@ -3,7 +3,7 @@ import { StyleSheet, Text, View } from 'react-native'; import TextInput from '../../../presentation/TextInput'; import I18n from '../../../i18n'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import sharedStyles from '../../Styles'; import { IShareListHeader } from './interface'; diff --git a/app/views/ShareListView/index.tsx b/app/views/ShareListView/index.tsx index b89603242..c41478163 100644 --- a/app/views/ShareListView/index.tsx +++ b/app/views/ShareListView/index.tsx @@ -16,7 +16,7 @@ import ServerItem from '../../presentation/ServerItem'; import * as HeaderButton from '../../containers/HeaderButton'; import ActivityIndicator from '../../containers/ActivityIndicator'; import * as List from '../../containers/List'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { animateNextTransition } from '../../utils/layoutAnimation'; import { withTheme } from '../../theme'; import SafeAreaView from '../../containers/SafeAreaView'; diff --git a/app/views/ShareView/Header.tsx b/app/views/ShareView/Header.tsx index fe6e9087b..ecbbbbe97 100644 --- a/app/views/ShareView/Header.tsx +++ b/app/views/ShareView/Header.tsx @@ -4,7 +4,7 @@ import { StyleSheet, Text, View } from 'react-native'; import I18n from '../../i18n'; import { CustomIcon } from '../../lib/Icons'; import RocketChat from '../../lib/rocketchat'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { useTheme } from '../../theme'; import { isAndroid, isTablet } from '../../utils/deviceInfo'; import sharedStyles from '../Styles'; diff --git a/app/views/ShareView/Preview.tsx b/app/views/ShareView/Preview.tsx index e7600dda6..18f4d3e30 100644 --- a/app/views/ShareView/Preview.tsx +++ b/app/views/ShareView/Preview.tsx @@ -6,15 +6,15 @@ import prettyBytes from 'pretty-bytes'; import { CustomIcon } from '../../lib/Icons'; import { ImageViewer, types } from '../../presentation/ImageViewer'; -import { themes } from '../../constants/colors'; import { useDimensions, useOrientation } from '../../dimensions'; import { getHeaderHeight } from '../../containers/Header'; import sharedStyles from '../Styles'; import I18n from '../../i18n'; import { isAndroid } from '../../utils/deviceInfo'; import { allowPreview } from './utils'; -import { THUMBS_HEIGHT } from './constants'; import { IAttachment, IUseDimensions } from './interfaces'; +import { THUMBS_HEIGHT } from './constants'; +import { themes } from '../../lib/constants'; const MESSAGEBOX_HEIGHT = 56; diff --git a/app/views/ShareView/Thumbs.tsx b/app/views/ShareView/Thumbs.tsx index da0808cc0..c5340d890 100644 --- a/app/views/ShareView/Thumbs.tsx +++ b/app/views/ShareView/Thumbs.tsx @@ -3,7 +3,7 @@ import { FlatList, Image, StyleSheet, View } from 'react-native'; import { RectButton, TouchableNativeFeedback, TouchableOpacity } from 'react-native-gesture-handler'; import { BUTTON_HIT_SLOP } from '../../containers/message/utils'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { CustomIcon } from '../../lib/Icons'; import { isIOS } from '../../utils/deviceInfo'; import { THUMBS_HEIGHT } from './constants'; diff --git a/app/views/ShareView/index.tsx b/app/views/ShareView/index.tsx index 8f06166a2..053573c7b 100644 --- a/app/views/ShareView/index.tsx +++ b/app/views/ShareView/index.tsx @@ -7,7 +7,7 @@ import ShareExtension from 'rn-extensions-share'; import { Q } from '@nozbe/watermelondb'; import { InsideStackParamList } from '../../stacks/types'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import I18n from '../../i18n'; import Loading from '../../containers/Loading'; import * as HeaderButton from '../../containers/HeaderButton'; diff --git a/app/views/SidebarView/SidebarItem.tsx b/app/views/SidebarView/SidebarItem.tsx index 6843732f1..8766e8037 100644 --- a/app/views/SidebarView/SidebarItem.tsx +++ b/app/views/SidebarView/SidebarItem.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Text, View } from 'react-native'; import Touch from '../../utils/touch'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { withTheme } from '../../theme'; import styles from './styles'; diff --git a/app/views/SidebarView/index.tsx b/app/views/SidebarView/index.tsx index 67f1af9bc..77db882db 100644 --- a/app/views/SidebarView/index.tsx +++ b/app/views/SidebarView/index.tsx @@ -11,7 +11,7 @@ import { events, logEvent } from '../../utils/log'; import I18n from '../../i18n'; import scrollPersistTaps from '../../utils/scrollPersistTaps'; import { CustomIcon } from '../../lib/Icons'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { withTheme } from '../../theme'; import { getUserSelector } from '../../selectors/login'; import SafeAreaView from '../../containers/SafeAreaView'; diff --git a/app/views/Styles.js b/app/views/Styles.js index 89b036741..e2344e0ea 100644 --- a/app/views/Styles.js +++ b/app/views/Styles.js @@ -1,6 +1,6 @@ import { Platform, StyleSheet } from 'react-native'; -import { MAX_SCREEN_CONTENT_WIDTH } from '../constants/tablet'; +import { MAX_SCREEN_CONTENT_WIDTH } from '../lib/constants'; export default StyleSheet.create({ container: { diff --git a/app/views/TeamChannelsView.tsx b/app/views/TeamChannelsView.tsx index 330126f74..b4b2c52f2 100644 --- a/app/views/TeamChannelsView.tsx +++ b/app/views/TeamChannelsView.tsx @@ -7,7 +7,7 @@ import { connect } from 'react-redux'; import { Dispatch } from 'redux'; import { deleteRoom } from '../actions/room'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import { withActionSheet } from '../containers/ActionSheet'; import ActivityIndicator from '../containers/ActivityIndicator'; import BackgroundContainer from '../containers/BackgroundContainer'; diff --git a/app/views/ThemeView.tsx b/app/views/ThemeView.tsx index 39bd3e36d..fb05d9dea 100644 --- a/app/views/ThemeView.tsx +++ b/app/views/ThemeView.tsx @@ -3,7 +3,6 @@ import { StackNavigationOptions } from '@react-navigation/stack'; import I18n from '../i18n'; import { withTheme } from '../theme'; -import { themes } from '../constants/colors'; import StatusBar from '../containers/StatusBar'; import * as List from '../containers/List'; import { supportSystemTheme } from '../utils/deviceInfo'; @@ -11,7 +10,7 @@ import SafeAreaView from '../containers/SafeAreaView'; 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'; +import { THEME_PREFERENCES_KEY, themes } from '../lib/constants'; const THEME_GROUP = 'THEME_GROUP'; const DARK_GROUP = 'DARK_GROUP'; diff --git a/app/views/ThreadMessagesView/Dropdown/DropdownItem.tsx b/app/views/ThreadMessagesView/Dropdown/DropdownItem.tsx index c2bbd4960..11e552f85 100644 --- a/app/views/ThreadMessagesView/Dropdown/DropdownItem.tsx +++ b/app/views/ThreadMessagesView/Dropdown/DropdownItem.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { withTheme } from '../../../theme'; import Touch from '../../../utils/touch'; import { CustomIcon } from '../../../lib/Icons'; diff --git a/app/views/ThreadMessagesView/Dropdown/index.tsx b/app/views/ThreadMessagesView/Dropdown/index.tsx index d21a78fc5..ef02c0f09 100644 --- a/app/views/ThreadMessagesView/Dropdown/index.tsx +++ b/app/views/ThreadMessagesView/Dropdown/index.tsx @@ -3,7 +3,7 @@ import { Animated, Easing, TouchableWithoutFeedback } from 'react-native'; import { EdgeInsets, withSafeAreaInsets } from 'react-native-safe-area-context'; import styles from '../styles'; -import { themes } from '../../../constants/colors'; +import { themes } from '../../../lib/constants'; import { withTheme } from '../../../theme'; import { headerHeight } from '../../../containers/Header'; import * as List from '../../../containers/List'; diff --git a/app/views/ThreadMessagesView/Item.stories.js b/app/views/ThreadMessagesView/Item.stories.js index b213f4d7c..5a98fb10c 100644 --- a/app/views/ThreadMessagesView/Item.stories.js +++ b/app/views/ThreadMessagesView/Item.stories.js @@ -5,7 +5,7 @@ import { ScrollView } from 'react-native'; import { Provider } from 'react-redux'; import * as List from '../../containers/List'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { ThemeContext } from '../../theme'; import { store } from '../../../storybook/stories'; import Item from './Item'; diff --git a/app/views/ThreadMessagesView/Item.tsx b/app/views/ThreadMessagesView/Item.tsx index d5b7a2b55..e5339f437 100644 --- a/app/views/ThreadMessagesView/Item.tsx +++ b/app/views/ThreadMessagesView/Item.tsx @@ -5,7 +5,7 @@ import Touchable from 'react-native-platform-touchable'; import { useTheme } from '../../theme'; import Avatar from '../../containers/Avatar'; import sharedStyles from '../Styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { MarkdownPreview } from '../../containers/markdown'; import { formatDateThreads, makeThreadName } from '../../utils/room'; import ThreadDetails from '../../containers/ThreadDetails'; diff --git a/app/views/ThreadMessagesView/index.tsx b/app/views/ThreadMessagesView/index.tsx index 2c6dcc6a4..d967aaafc 100644 --- a/app/views/ThreadMessagesView/index.tsx +++ b/app/views/ThreadMessagesView/index.tsx @@ -18,7 +18,7 @@ import buildMessage from '../../lib/methods/helpers/buildMessage'; import log from '../../utils/log'; import debounce from '../../utils/debounce'; import protectedFunction from '../../lib/methods/helpers/protectedFunction'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { withTheme } from '../../theme'; import { getUserSelector } from '../../selectors/login'; import SafeAreaView from '../../containers/SafeAreaView'; diff --git a/app/views/UserNotificationPreferencesView/index.tsx b/app/views/UserNotificationPreferencesView/index.tsx index 1b9a5cd83..fe4bdece8 100644 --- a/app/views/UserNotificationPreferencesView/index.tsx +++ b/app/views/UserNotificationPreferencesView/index.tsx @@ -3,7 +3,7 @@ import { StyleSheet, Text } from 'react-native'; import { StackNavigationOptions, StackNavigationProp } from '@react-navigation/stack'; import { connect } from 'react-redux'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import StatusBar from '../../containers/StatusBar'; import * as List from '../../containers/List'; import I18n from '../../i18n'; diff --git a/app/views/UserPreferencesView/index.tsx b/app/views/UserPreferencesView/index.tsx index 4a2b1b042..a2319c036 100644 --- a/app/views/UserPreferencesView/index.tsx +++ b/app/views/UserPreferencesView/index.tsx @@ -9,7 +9,7 @@ import log, { logEvent, events } from '../../utils/log'; import SafeAreaView from '../../containers/SafeAreaView'; import StatusBar from '../../containers/StatusBar'; import * as List from '../../containers/List'; -import { SWITCH_TRACK_COLOR } from '../../constants/colors'; +import { SWITCH_TRACK_COLOR } from '../../lib/constants'; import { getUserSelector } from '../../selectors/login'; import RocketChat from '../../lib/rocketchat'; import { ProfileStackParamList } from '../../stacks/types'; diff --git a/app/views/WithoutServersView.tsx b/app/views/WithoutServersView.tsx index 43ceacc2d..2fc342ffd 100644 --- a/app/views/WithoutServersView.tsx +++ b/app/views/WithoutServersView.tsx @@ -5,7 +5,7 @@ import ShareExtension from 'rn-extensions-share'; import * as HeaderButton from '../containers/HeaderButton'; import sharedStyles from './Styles'; import I18n from '../i18n'; -import { themes } from '../constants/colors'; +import { themes } from '../lib/constants'; import { withTheme } from '../theme'; const styles = StyleSheet.create({ diff --git a/app/views/WorkspaceView/ServerAvatar.tsx b/app/views/WorkspaceView/ServerAvatar.tsx index 54b90b9bb..435c23488 100644 --- a/app/views/WorkspaceView/ServerAvatar.tsx +++ b/app/views/WorkspaceView/ServerAvatar.tsx @@ -5,7 +5,7 @@ import * as Progress from 'react-native-progress'; import FastImage from '@rocket.chat/react-native-fast-image'; import sharedStyles from '../Styles'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { isTablet } from '../../utils/deviceInfo'; const ImageProgress = createImageProgress(FastImage); diff --git a/app/views/WorkspaceView/index.tsx b/app/views/WorkspaceView/index.tsx index ed7155a02..12ff38396 100644 --- a/app/views/WorkspaceView/index.tsx +++ b/app/views/WorkspaceView/index.tsx @@ -7,7 +7,7 @@ import { CompositeNavigationProp } from '@react-navigation/core'; import { OutsideModalParamList, OutsideParamList } from '../../stacks/types'; import I18n from '../../i18n'; import Button from '../../containers/Button'; -import { themes } from '../../constants/colors'; +import { themes } from '../../lib/constants'; import { withTheme } from '../../theme'; import FormContainer, { FormContainerInner } from '../../containers/FormContainer'; import { getShowLoginButton } from '../../selectors/login'; diff --git a/storybook/stories/Markdown.tsx b/storybook/stories/Markdown.tsx index 771d939cc..3b0bff80b 100644 --- a/storybook/stories/Markdown.tsx +++ b/storybook/stories/Markdown.tsx @@ -3,7 +3,7 @@ import { ScrollView, StyleSheet, View } from 'react-native'; import { storiesOf } from '@storybook/react-native'; import Markdown, { MarkdownPreview } from '../../app/containers/markdown'; -import { themes } from '../../app/constants/colors'; +import { themes } from '../../app/lib/constants'; import { TGetCustomEmoji, IEmoji } from '../../app/definitions/IEmoji'; const theme = 'light'; diff --git a/storybook/stories/Message.js b/storybook/stories/Message.js index 610055082..81b298fa2 100644 --- a/storybook/stories/Message.js +++ b/storybook/stories/Message.js @@ -3,13 +3,11 @@ import React from 'react'; import { ScrollView, StyleSheet } from 'react-native'; import { Provider } from 'react-redux'; import { storiesOf } from '@storybook/react-native'; -// import moment from 'moment'; import MessageComponent from '../../app/containers/message/Message'; -import messagesStatus from '../../app/constants/messagesStatus'; +import { messagesStatus, themes } from '../../app/lib/constants'; import MessageSeparator from '../../app/views/RoomView/Separator'; import MessageContext from '../../app/containers/message/Context'; -import { themes } from '../../app/constants/colors'; import { store } from './index'; const _theme = 'light'; diff --git a/storybook/stories/NewMarkdown.js b/storybook/stories/NewMarkdown.js index e6d6be320..04799e5f5 100644 --- a/storybook/stories/NewMarkdown.js +++ b/storybook/stories/NewMarkdown.js @@ -4,7 +4,7 @@ import { StyleSheet, View } from 'react-native'; import { storiesOf } from '@storybook/react-native'; import NewMarkdown from '../../app/containers/markdown/new'; -import { themes } from '../../app/constants/colors'; +import { themes } from '../../app/lib/constants'; import { longText } from '../utils'; const stories = storiesOf('NewMarkdown', module); diff --git a/storybook/stories/RoomItem.js b/storybook/stories/RoomItem.js index e6ae40e7b..46ecddd25 100644 --- a/storybook/stories/RoomItem.js +++ b/storybook/stories/RoomItem.js @@ -4,10 +4,9 @@ import { Dimensions, ScrollView } from 'react-native'; import { storiesOf } from '@storybook/react-native'; import { Provider } from 'react-redux'; -import { themes } from '../../app/constants/colors'; import RoomItemComponent from '../../app/presentation/RoomItem/RoomItem'; import { longText } from '../utils'; -import { DisplayMode } from '../../app/constants/constantDisplayMode'; +import { DisplayMode, themes } from '../../app/lib/constants'; import { store } from './index'; const baseUrl = 'https://open.rocket.chat'; diff --git a/storybook/stories/UiKitMessage.js b/storybook/stories/UiKitMessage.js index a9a9aba94..9e05621ca 100644 --- a/storybook/stories/UiKitMessage.js +++ b/storybook/stories/UiKitMessage.js @@ -5,7 +5,7 @@ import { storiesOf } from '@storybook/react-native'; import MessageContext from '../../app/containers/message/Context'; import { UiKitMessage } from '../../app/containers/UIKit'; -import { themes } from '../../app/constants/colors'; +import { themes } from '../../app/lib/constants'; const styles = StyleSheet.create({ container: { diff --git a/storybook/stories/UiKitModal.js b/storybook/stories/UiKitModal.js index 6b3c22f40..6c417b58c 100644 --- a/storybook/stories/UiKitModal.js +++ b/storybook/stories/UiKitModal.js @@ -6,7 +6,7 @@ import { storiesOf } from '@storybook/react-native'; import { UiKitComponent, UiKitModal } from '../../app/containers/UIKit'; import { KitContext, defaultContext } from '../../app/containers/UIKit/utils'; import MessageContext from '../../app/containers/message/Context'; -import { themes } from '../../app/constants/colors'; +import { themes } from '../../app/lib/constants'; const styles = StyleSheet.create({ container: { From d38c17bcd8a9d7f55d0ccfd5fae90412ce755b5f Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Silva Date: Thu, 7 Apr 2022 11:19:54 -0300 Subject: [PATCH 5/9] Chore: Create app/lib/store folder (#4028) Co-authored-by: Diego Mello --- app/containers/MessageBox/EmojiKeyboard.tsx | 2 +- app/ee/omnichannel/lib/subscriptions/inquiry.ts | 2 +- app/index.tsx | 4 ++-- app/lib/encryption/encryption.ts | 2 +- app/lib/methods/canOpenRoom.ts | 2 +- app/lib/methods/helpers/mergeSubscriptionsRooms.ts | 2 +- app/lib/methods/subscriptions/room.ts | 2 +- app/lib/methods/subscriptions/rooms.ts | 2 +- app/lib/rocketchat/methods/callJitsi.ts | 2 +- app/lib/rocketchat/methods/enterpriseModules.ts | 2 +- app/lib/rocketchat/methods/getCustomEmojis.ts | 2 +- app/lib/rocketchat/methods/getPermalinks.ts | 2 +- app/lib/rocketchat/methods/getPermissions.ts | 2 +- app/lib/rocketchat/methods/getRoles.ts | 2 +- app/lib/rocketchat/methods/getSettings.ts | 2 +- app/lib/rocketchat/methods/getUsersPresence.ts | 2 +- app/lib/rocketchat/methods/helpers.ts | 2 +- app/lib/rocketchat/methods/setUser.ts | 2 +- app/lib/rocketchat/services/connect.ts | 2 +- app/lib/rocketchat/services/restApi.ts | 2 +- app/lib/rocketchat/services/sdk.ts | 2 +- app/lib/rocketchat/services/shareExtension.ts | 2 +- .../appStateMiddleware.ts} | 8 ++++---- app/lib/{ => store}/auxStore.ts | 2 +- app/lib/{createStore.js => store/index.ts} | 4 ++-- app/notifications/push/index.ts | 2 +- app/notifications/push/push.ios.ts | 2 +- app/share.tsx | 4 ++-- app/utils/isReadOnly.ts | 2 +- app/utils/localAuthentication.ts | 2 +- 30 files changed, 36 insertions(+), 36 deletions(-) rename app/lib/{appStateMiddleware.js => store/appStateMiddleware.ts} (84%) rename app/lib/{ => store}/auxStore.ts (82%) rename app/lib/{createStore.js => store/index.ts} (92%) diff --git a/app/containers/MessageBox/EmojiKeyboard.tsx b/app/containers/MessageBox/EmojiKeyboard.tsx index e38660a9b..acf5dd863 100644 --- a/app/containers/MessageBox/EmojiKeyboard.tsx +++ b/app/containers/MessageBox/EmojiKeyboard.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { View } from 'react-native'; import { KeyboardRegistry } from 'react-native-ui-lib/keyboard'; -import { store } from '../../lib/auxStore'; +import { store } from '../../lib/store/auxStore'; import EmojiPicker from '../EmojiPicker'; import styles from './styles'; import { themes } from '../../lib/constants'; diff --git a/app/ee/omnichannel/lib/subscriptions/inquiry.ts b/app/ee/omnichannel/lib/subscriptions/inquiry.ts index 69953e378..480677f2e 100644 --- a/app/ee/omnichannel/lib/subscriptions/inquiry.ts +++ b/app/ee/omnichannel/lib/subscriptions/inquiry.ts @@ -1,5 +1,5 @@ import log from '../../../../utils/log'; -import { store } from '../../../../lib/auxStore'; +import { store } from '../../../../lib/store/auxStore'; import RocketChat from '../../../../lib/rocketchat'; import { inquiryQueueAdd, inquiryQueueRemove, inquiryQueueUpdate, inquiryRequest } from '../../actions/inquiry'; import sdk from '../../../../lib/rocketchat/services/sdk'; diff --git a/app/index.tsx b/app/index.tsx index 6d3dd9b2e..22446d9ce 100644 --- a/app/index.tsx +++ b/app/index.tsx @@ -12,7 +12,6 @@ import { appInit, appInitLocalSettings, setMasterDetail as setMasterDetailAction import { deepLinkingOpen } from './actions/deepLinking'; import parseQuery from './lib/methods/helpers/parseQuery'; import { initializePushNotifications, onNotification } from './notifications/push'; -import store from './lib/createStore'; import { toggleAnalyticsEventsReport, toggleCrashErrorsReport } from './utils/log'; import { ThemeContext, TSupportedThemes } from './theme'; import { DimensionsContext } from './dimensions'; @@ -30,7 +29,8 @@ import debounce from './utils/debounce'; import { isFDroidBuild, MIN_WIDTH_MASTER_DETAIL_LAYOUT, colors, themes } from './lib/constants'; import { IThemePreference } from './definitions/ITheme'; import { ICommand } from './definitions/ICommand'; -import { initStore } from './lib/auxStore'; +import store from './lib/store'; +import { initStore } from './lib/store/auxStore'; RNScreens.enableScreens(); initStore(store); diff --git a/app/lib/encryption/encryption.ts b/app/lib/encryption/encryption.ts index ff1727185..4d0cd68fa 100644 --- a/app/lib/encryption/encryption.ts +++ b/app/lib/encryption/encryption.ts @@ -9,7 +9,7 @@ import database from '../database'; import protectedFunction from '../methods/helpers/protectedFunction'; import Deferred from '../../utils/deferred'; import log from '../../utils/log'; -import { store } from '../auxStore'; +import { store } from '../store/auxStore'; import { joinVectorData, randomPassword, splitVectorData, toString, utf8ToBuffer } from './utils'; import { EncryptionRoom } from './index'; import { IMessage, ISubscription, TMessageModel, TSubscriptionModel, TThreadMessageModel, TThreadModel } from '../../definitions'; diff --git a/app/lib/methods/canOpenRoom.ts b/app/lib/methods/canOpenRoom.ts index 93f297180..404afa8a2 100644 --- a/app/lib/methods/canOpenRoom.ts +++ b/app/lib/methods/canOpenRoom.ts @@ -1,5 +1,5 @@ import { ERoomTypes } from '../../definitions'; -import { store } from '../auxStore'; +import { store } from '../store/auxStore'; import database from '../database'; import RocketChat from '../rocketchat'; import sdk from '../rocketchat/services/sdk'; diff --git a/app/lib/methods/helpers/mergeSubscriptionsRooms.ts b/app/lib/methods/helpers/mergeSubscriptionsRooms.ts index 9d108b9f9..e39bf2287 100644 --- a/app/lib/methods/helpers/mergeSubscriptionsRooms.ts +++ b/app/lib/methods/helpers/mergeSubscriptionsRooms.ts @@ -1,7 +1,7 @@ import EJSON from 'ejson'; import { Encryption } from '../../encryption'; -import { store as reduxStore } from '../../auxStore'; +import { store as reduxStore } from '../../store/auxStore'; import findSubscriptionsRooms from './findSubscriptionsRooms'; import normalizeMessage from './normalizeMessage'; import { ISubscription, IServerSubscription, IServerRoom, IRoom } from '../../../definitions'; diff --git a/app/lib/methods/subscriptions/room.ts b/app/lib/methods/subscriptions/room.ts index baac2b72c..296180686 100644 --- a/app/lib/methods/subscriptions/room.ts +++ b/app/lib/methods/subscriptions/room.ts @@ -9,7 +9,7 @@ import database from '../../database'; import { getMessageById } from '../../database/services/Message'; import { getThreadById } from '../../database/services/Thread'; import { getThreadMessageById } from '../../database/services/ThreadMessage'; -import reduxStore from '../../createStore'; +import { store as reduxStore } from '../../store/auxStore'; import { addUserTyping, clearUserTyping, removeUserTyping } from '../../../actions/usersTyping'; import debounce from '../../../utils/debounce'; import RocketChat from '../../rocketchat'; diff --git a/app/lib/methods/subscriptions/rooms.ts b/app/lib/methods/subscriptions/rooms.ts index 4a41475cb..e03ec4805 100644 --- a/app/lib/methods/subscriptions/rooms.ts +++ b/app/lib/methods/subscriptions/rooms.ts @@ -8,7 +8,7 @@ import { merge } from '../helpers/mergeSubscriptionsRooms'; import protectedFunction from '../helpers/protectedFunction'; import log from '../../../utils/log'; import random from '../../../utils/random'; -import { store } from '../../auxStore'; +import { store } from '../../store/auxStore'; import { handlePayloadUserInteraction } from '../actions'; import buildMessage from '../helpers/buildMessage'; import RocketChat from '../../rocketchat'; diff --git a/app/lib/rocketchat/methods/callJitsi.ts b/app/lib/rocketchat/methods/callJitsi.ts index 7b19bb389..1668802f1 100644 --- a/app/lib/rocketchat/methods/callJitsi.ts +++ b/app/lib/rocketchat/methods/callJitsi.ts @@ -1,6 +1,6 @@ import { ISubscription } from '../../../definitions'; import { events, logEvent } from '../../../utils/log'; -import { store } from '../../auxStore'; +import { store } from '../../store/auxStore'; import Navigation from '../../navigation/appNavigation'; import sdk from '../services/sdk'; diff --git a/app/lib/rocketchat/methods/enterpriseModules.ts b/app/lib/rocketchat/methods/enterpriseModules.ts index 41490e719..a38b99f81 100644 --- a/app/lib/rocketchat/methods/enterpriseModules.ts +++ b/app/lib/rocketchat/methods/enterpriseModules.ts @@ -1,5 +1,5 @@ import sdk from '../services/sdk'; -import { store as reduxStore } from '../../auxStore'; +import { store as reduxStore } from '../../store/auxStore'; import database from '../../database'; import log from '../../../utils/log'; import { clearEnterpriseModules, setEnterpriseModules as setEnterpriseModulesAction } from '../../../actions/enterpriseModules'; diff --git a/app/lib/rocketchat/methods/getCustomEmojis.ts b/app/lib/rocketchat/methods/getCustomEmojis.ts index 94e3d737c..278693d47 100644 --- a/app/lib/rocketchat/methods/getCustomEmojis.ts +++ b/app/lib/rocketchat/methods/getCustomEmojis.ts @@ -2,7 +2,7 @@ import orderBy from 'lodash/orderBy'; import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord'; import { ICustomEmojis } from '../../../reducers/customEmojis'; -import { store as reduxStore } from '../../auxStore'; +import { store as reduxStore } from '../../store/auxStore'; import database from '../../database'; import log from '../../../utils/log'; import { setCustomEmojis as setCustomEmojisAction } from '../../../actions/customEmojis'; diff --git a/app/lib/rocketchat/methods/getPermalinks.ts b/app/lib/rocketchat/methods/getPermalinks.ts index 9bbe89a15..8e66517c1 100644 --- a/app/lib/rocketchat/methods/getPermalinks.ts +++ b/app/lib/rocketchat/methods/getPermalinks.ts @@ -1,6 +1,6 @@ import log from '../../../utils/log'; import { TMessageModel, TSubscriptionModel } from '../../../definitions'; -import { store } from '../../auxStore'; +import { store } from '../../store/auxStore'; import getRoom from '../../methods/getRoom'; import { isGroupChat } from './helpers'; diff --git a/app/lib/rocketchat/methods/getPermissions.ts b/app/lib/rocketchat/methods/getPermissions.ts index 2de011dc1..36199a5c8 100644 --- a/app/lib/rocketchat/methods/getPermissions.ts +++ b/app/lib/rocketchat/methods/getPermissions.ts @@ -5,7 +5,7 @@ import orderBy from 'lodash/orderBy'; import { setPermissions as setPermissionsAction } from '../../../actions/permissions'; import { IPermission, TPermissionModel } from '../../../definitions'; import log from '../../../utils/log'; -import { store as reduxStore } from '../../auxStore'; +import { store as reduxStore } from '../../store/auxStore'; import database from '../../database'; import sdk from '../services/sdk'; import protectedFunction from '../../methods/helpers/protectedFunction'; diff --git a/app/lib/rocketchat/methods/getRoles.ts b/app/lib/rocketchat/methods/getRoles.ts index 97677305a..0382a7bb3 100644 --- a/app/lib/rocketchat/methods/getRoles.ts +++ b/app/lib/rocketchat/methods/getRoles.ts @@ -4,7 +4,7 @@ import Model from '@nozbe/watermelondb/Model'; import database from '../../database'; import { getRoleById } from '../../database/services/Role'; import log from '../../../utils/log'; -import { store as reduxStore } from '../../auxStore'; +import { store as reduxStore } from '../../store/auxStore'; import { removeRoles, setRoles as setRolesAction, updateRoles } from '../../../actions/roles'; import protectedFunction from '../../methods/helpers/protectedFunction'; import { TRoleModel } from '../../../definitions'; diff --git a/app/lib/rocketchat/methods/getSettings.ts b/app/lib/rocketchat/methods/getSettings.ts index 01b549690..f0659c06a 100644 --- a/app/lib/rocketchat/methods/getSettings.ts +++ b/app/lib/rocketchat/methods/getSettings.ts @@ -6,7 +6,7 @@ import { DEFAULT_AUTO_LOCK, defaultSettings } from '../../constants'; import { IPreparedSettings, ISettingsIcon } from '../../../definitions'; import fetch from '../../../utils/fetch'; import log from '../../../utils/log'; -import { store as reduxStore } from '../../auxStore'; +import { store as reduxStore } from '../../store/auxStore'; import database from '../../database'; import RocketChat from '..'; import sdk from '../services/sdk'; diff --git a/app/lib/rocketchat/methods/getUsersPresence.ts b/app/lib/rocketchat/methods/getUsersPresence.ts index 92576a199..e7c24f663 100644 --- a/app/lib/rocketchat/methods/getUsersPresence.ts +++ b/app/lib/rocketchat/methods/getUsersPresence.ts @@ -2,7 +2,7 @@ import { InteractionManager } from 'react-native'; import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord'; import { IActiveUsers } from '../../../reducers/activeUsers'; -import { store as reduxStore } from '../../auxStore'; +import { store as reduxStore } from '../../store/auxStore'; import { setActiveUsers } from '../../../actions/activeUsers'; import { setUser } from '../../../actions/login'; import database from '../../database'; diff --git a/app/lib/rocketchat/methods/helpers.ts b/app/lib/rocketchat/methods/helpers.ts index 4a06e50ef..d62df0062 100644 --- a/app/lib/rocketchat/methods/helpers.ts +++ b/app/lib/rocketchat/methods/helpers.ts @@ -2,7 +2,7 @@ import AsyncStorage from '@react-native-community/async-storage'; import log from '../../../utils/log'; -import { store as reduxStore } from '../../auxStore'; +import { store as reduxStore } from '../../store/auxStore'; import database from '../../database'; import subscribeRoomsTmp from '../../methods/subscriptions/rooms'; import { ANALYTICS_EVENTS_KEY, CRASH_REPORT_KEY, defaultSettings } from '../../constants'; diff --git a/app/lib/rocketchat/methods/setUser.ts b/app/lib/rocketchat/methods/setUser.ts index db95f0a4e..6cc31e5de 100644 --- a/app/lib/rocketchat/methods/setUser.ts +++ b/app/lib/rocketchat/methods/setUser.ts @@ -2,7 +2,7 @@ import { InteractionManager } from 'react-native'; import { setActiveUsers } from '../../../actions/activeUsers'; import { setUser } from '../../../actions/login'; -import { store as reduxStore } from '../../auxStore'; +import { store as reduxStore } from '../../store/auxStore'; import { compareServerVersion } from '../../methods/helpers/compareServerVersion'; // TODO diff --git a/app/lib/rocketchat/services/connect.ts b/app/lib/rocketchat/services/connect.ts index f8f2c1f64..ad9e00f9a 100644 --- a/app/lib/rocketchat/services/connect.ts +++ b/app/lib/rocketchat/services/connect.ts @@ -11,7 +11,7 @@ import protectedFunction from '../../methods/helpers/protectedFunction'; import database from '../../database'; import { selectServerFailure } from '../../../actions/server'; import { twoFactor } from '../../../utils/twoFactor'; -import { store } from '../../auxStore'; +import { store } from '../../store/auxStore'; import { loginRequest, setLoginServices, setUser } from '../../../actions/login'; import sdk from './sdk'; import I18n from '../../../i18n'; diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index 2097b0f75..f82aad305 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -13,7 +13,7 @@ import { ISpotlight } from '../../../definitions/ISpotlight'; import { TEAM_TYPE } from '../../../definitions/ITeam'; import { Encryption } from '../../encryption'; import { TParams } from '../../../definitions/ILivechatEditView'; -import { store as reduxStore } from '../../auxStore'; +import { store as reduxStore } from '../../store/auxStore'; import { getDeviceToken } from '../../../notifications/push'; import { getBundleId, isIOS } from '../../../utils/deviceInfo'; import roomTypeToApiType, { RoomTypes } from '../../methods/roomTypeToApiType'; diff --git a/app/lib/rocketchat/services/sdk.ts b/app/lib/rocketchat/services/sdk.ts index d5aa3cead..fa8ec7de0 100644 --- a/app/lib/rocketchat/services/sdk.ts +++ b/app/lib/rocketchat/services/sdk.ts @@ -4,7 +4,7 @@ import isEmpty from 'lodash/isEmpty'; import { twoFactor } from '../../../utils/twoFactor'; import { useSsl } from '../../../utils/url'; -import reduxStore from '../../createStore'; +import { store as reduxStore } from '../../store/auxStore'; import { Serialized, MatchPathPattern, OperationParams, PathFor, ResultFor } from '../../../definitions/rest/helpers'; class Sdk { diff --git a/app/lib/rocketchat/services/shareExtension.ts b/app/lib/rocketchat/services/shareExtension.ts index 023cd601f..4a35c0629 100644 --- a/app/lib/rocketchat/services/shareExtension.ts +++ b/app/lib/rocketchat/services/shareExtension.ts @@ -8,7 +8,7 @@ import UserPreferences from '../../methods/userPreferences'; import database from '../../database'; import RocketChat from '..'; import { encryptionInit } from '../../../actions/encryption'; -import { store } from '../../auxStore'; +import { store } from '../../store/auxStore'; import sdk from './sdk'; export async function shareExtensionInit(server: string) { diff --git a/app/lib/appStateMiddleware.js b/app/lib/store/appStateMiddleware.ts similarity index 84% rename from app/lib/appStateMiddleware.js rename to app/lib/store/appStateMiddleware.ts index 93fdff95a..7025a8191 100644 --- a/app/lib/appStateMiddleware.js +++ b/app/lib/store/appStateMiddleware.ts @@ -1,16 +1,16 @@ // https://github.com/bamlab/redux-enhancer-react-native-appstate import { AppState } from 'react-native'; -import { APP_STATE } from '../actions/actionsTypes'; +import { APP_STATE } from '../../actions/actionsTypes'; export default () => - createStore => - (...args) => { + (createStore: any) => + (...args: any) => { const store = createStore(...args); let currentState = ''; - const handleAppStateChange = nextAppState => { + const handleAppStateChange = (nextAppState: any) => { if (nextAppState !== 'inactive') { if (currentState !== nextAppState) { let type; diff --git a/app/lib/auxStore.ts b/app/lib/store/auxStore.ts similarity index 82% rename from app/lib/auxStore.ts rename to app/lib/store/auxStore.ts index 2de3f72aa..bdb234af3 100644 --- a/app/lib/auxStore.ts +++ b/app/lib/store/auxStore.ts @@ -1,6 +1,6 @@ import { Store } from 'redux'; -import { IApplicationState } from '../definitions'; +import { IApplicationState } from '../../definitions'; // https://redux.js.org/faq/code-structure#how-can-i-use-the-redux-store-in-non-component-files export let store: Store = null as any; diff --git a/app/lib/createStore.js b/app/lib/store/index.ts similarity index 92% rename from app/lib/createStore.js rename to app/lib/store/index.ts index a9608de6c..1b3520871 100644 --- a/app/lib/createStore.js +++ b/app/lib/store/index.ts @@ -1,8 +1,8 @@ import { applyMiddleware, compose, createStore } from 'redux'; import createSagaMiddleware from 'redux-saga'; -import reducers from '../reducers'; -import sagas from '../sagas'; +import reducers from '../../reducers'; +import sagas from '../../sagas'; import applyAppStateMiddleware from './appStateMiddleware'; let sagaMiddleware; diff --git a/app/notifications/push/index.ts b/app/notifications/push/index.ts index e9ac11fba..6fced7ed3 100644 --- a/app/notifications/push/index.ts +++ b/app/notifications/push/index.ts @@ -1,6 +1,6 @@ import EJSON from 'ejson'; -import { store } from '../../lib/auxStore'; +import { store } from '../../lib/store/auxStore'; import { deepLinkingOpen } from '../../actions/deepLinking'; import { isFDroidBuild } from '../../lib/constants'; import PushNotification from './push'; diff --git a/app/notifications/push/push.ios.ts b/app/notifications/push/push.ios.ts index b9713af2a..00b107b02 100644 --- a/app/notifications/push/push.ios.ts +++ b/app/notifications/push/push.ios.ts @@ -2,7 +2,7 @@ // TODO BUMP LIB VERSION import NotificationsIOS, { NotificationAction, NotificationCategory, Notification } from 'react-native-notifications'; -import { store as reduxStore } from '../../lib/auxStore'; +import { store as reduxStore } from '../../lib/store/auxStore'; import I18n from '../../i18n'; import { INotification } from '../../definitions/INotification'; diff --git a/app/share.tsx b/app/share.tsx index 94075a830..fff29dea2 100644 --- a/app/share.tsx +++ b/app/share.tsx @@ -8,8 +8,8 @@ import { Provider } from 'react-redux'; import { getTheme, initialTheme, newThemeState, subscribeTheme, unsubscribeTheme } from './utils/theme'; import UserPreferences from './lib/methods/userPreferences'; import Navigation from './lib/navigation/shareNavigation'; -import store from './lib/createStore'; -import { initStore } from './lib/auxStore'; +import store from './lib/store'; +import { initStore } from './lib/store/auxStore'; import { closeShareExtension, shareExtensionInit } from './lib/rocketchat/services/shareExtension'; import { defaultHeader, getActiveRouteName, navigationTheme, themedHeader } from './utils/navigation'; import RocketChat from './lib/rocketchat'; diff --git a/app/utils/isReadOnly.ts b/app/utils/isReadOnly.ts index deee17d83..9e41362b5 100644 --- a/app/utils/isReadOnly.ts +++ b/app/utils/isReadOnly.ts @@ -1,5 +1,5 @@ import RocketChat from '../lib/rocketchat'; -import { store as reduxStore } from '../lib/auxStore'; +import { store as reduxStore } from '../lib/store/auxStore'; import { ISubscription } from '../definitions/ISubscription'; const canPostReadOnly = async ({ rid }: { rid: string }) => { diff --git a/app/utils/localAuthentication.ts b/app/utils/localAuthentication.ts index 35704374d..343878f1f 100644 --- a/app/utils/localAuthentication.ts +++ b/app/utils/localAuthentication.ts @@ -5,7 +5,7 @@ import { sha256 } from 'js-sha256'; import moment from 'moment'; import UserPreferences from '../lib/methods/userPreferences'; -import { store } from '../lib/auxStore'; +import { store } from '../lib/store/auxStore'; import database from '../lib/database'; import { getServerTimeSync } from '../lib/rocketchat/services/getServerTimeSync'; import { From 13a2962fa2d25dcdde893a50eb4bf69a871bd8c6 Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Thu, 7 Apr 2022 12:27:45 -0400 Subject: [PATCH 6/9] Chore: evaluate getUserSelector (#4013) * update: type for user * update: LanguageView's user type * update: UserNotificationPreferencesView's user * chore: set `enableMessageParserEarlyAdoption` as non-optional --- app/definitions/ILoggedUser.ts | 4 ++-- app/definitions/IProfileViewInterfaces.ts | 15 +-------------- app/definitions/IUser.ts | 17 ++--------------- app/selectors/login.ts | 9 ++++----- app/views/CreateChannelView.tsx | 8 ++------ app/views/E2EEncryptionSecurityView.tsx | 6 ++---- app/views/JitsiMeetView.tsx | 14 +++++--------- app/views/LanguageView/index.tsx | 11 ++++------- app/views/ProfileView/index.tsx | 6 +++--- app/views/SelectedUsersView.tsx | 11 +++-------- app/views/SettingsView/index.tsx | 7 ++----- app/views/SidebarView/index.tsx | 10 ++-------- app/views/StatusView.tsx | 2 +- .../UserNotificationPreferencesView/index.tsx | 6 ++---- 14 files changed, 35 insertions(+), 91 deletions(-) diff --git a/app/definitions/ILoggedUser.ts b/app/definitions/ILoggedUser.ts index 7aa159403..cf5d65788 100644 --- a/app/definitions/ILoggedUser.ts +++ b/app/definitions/ILoggedUser.ts @@ -7,7 +7,7 @@ export interface ILoggedUser { id: string; token: string; username: string; - name: string; + name?: string; language?: string; status: TUserStatus; statusText?: string; @@ -20,7 +20,7 @@ export interface ILoggedUser { avatarETag?: string; showMessageInMainThread?: boolean; isFromWebView?: boolean; - enableMessageParserEarlyAdoption?: boolean; + enableMessageParserEarlyAdoption: boolean; } export interface ILoggedUserResultFromServer diff --git a/app/definitions/IProfileViewInterfaces.ts b/app/definitions/IProfileViewInterfaces.ts index ba6d0659b..efd001c78 100644 --- a/app/definitions/IProfileViewInterfaces.ts +++ b/app/definitions/IProfileViewInterfaces.ts @@ -2,20 +2,7 @@ import { StackNavigationProp } from '@react-navigation/stack'; import React from 'react'; import { ProfileStackParamList } from '../stacks/types'; - -export interface IUser { - id: string; - name: string; - username: string; - emails: { - [index: number]: { - address: string; - }; - }; - customFields: { - [index: string | number]: string; - }; -} +import { IUser } from './IUser'; export interface IParams { name: string; diff --git a/app/definitions/IUser.ts b/app/definitions/IUser.ts index a9a803bd1..14328f230 100644 --- a/app/definitions/IUser.ts +++ b/app/definitions/IUser.ts @@ -115,33 +115,23 @@ export interface INotificationPreferences { } export interface IUserPreferences { - user: { _id: string }; + user: Pick; settings: { preferences: INotificationPreferences; }; } -export interface IUser extends IRocketChatRecord, Omit { +export interface IUser extends IRocketChatRecord, ILoggedUser { _id: string; - id: string; - token: string; createdAt?: Date; - roles?: string[]; type?: string; active?: boolean; - username: string; - name?: string; services?: IUserServices; - emails?: IUserEmail[]; - status: TUserStatus; statusConnection?: string; lastLogin?: Date; avatarOrigin?: string; - avatarETag?: string; utcOffset?: number; - language?: string; statusDefault?: TUserStatus; - statusText?: string; oauth?: { authorizedClients: string[]; }; @@ -151,9 +141,6 @@ export interface IUser extends IRocketChatRecord, Omit => { +const getUser = (state: IApplicationState): IUser => { if (!isEmpty(state.share?.user)) { - return state.share.user; + return state.share.user as IUser; } - return state.login?.user; + return state.login?.user as IUser; }; const getLoginServices = (state: IApplicationState) => (state.login.services as IServices) || {}; const getShowFormLoginSetting = (state: IApplicationState) => (state.settings.Accounts_ShowFormLogin as boolean) || false; const getIframeEnabledSetting = (state: IApplicationState) => (state.settings.Accounts_iframe_enabled as boolean) || false; -// TODO: we need to change 42 files to fix a correct type, i believe is better to do this later -export const getUserSelector = createSelector([getUser], user => user) as any; +export const getUserSelector = createSelector([getUser], user => user); export const getShowLoginButton = createSelector( [getLoginServices, getShowFormLoginSetting, getIframeEnabledSetting], diff --git a/app/views/CreateChannelView.tsx b/app/views/CreateChannelView.tsx index e7893ba12..17b0f533d 100644 --- a/app/views/CreateChannelView.tsx +++ b/app/views/CreateChannelView.tsx @@ -23,7 +23,7 @@ import SafeAreaView from '../containers/SafeAreaView'; import RocketChat from '../lib/rocketchat'; import sharedStyles from './Styles'; import { ChatsStackParamList } from '../stacks/types'; -import { IApplicationState, IBaseScreen } from '../definitions'; +import { IApplicationState, IBaseScreen, IUser } from '../definitions'; const styles = StyleSheet.create({ container: { @@ -90,11 +90,7 @@ interface ICreateChannelViewProps extends IBaseScreen `${baseUrl}/avatar/${url}?format=png&width=${uriSize}&height=${uriSize}${avatarAuthURLFragment}`; @@ -30,12 +31,7 @@ interface IJitsiMeetViewProps { route: RouteProp; baseUrl: string; theme: string; - user: { - id: string; - username: string; - name: string; - token: string; - }; + user: IUser; } class JitsiMeetView extends React.Component { @@ -50,12 +46,12 @@ class JitsiMeetView extends React.Component ({ +const mapStateToProps = (state: IApplicationState) => ({ user: getUserSelector(state), baseUrl: state.server.server }); diff --git a/app/views/LanguageView/index.tsx b/app/views/LanguageView/index.tsx index bd68834f6..4e1699cbc 100644 --- a/app/views/LanguageView/index.tsx +++ b/app/views/LanguageView/index.tsx @@ -9,7 +9,7 @@ import { themes } from '../../lib/constants'; import * as List from '../../containers/List'; import SafeAreaView from '../../containers/SafeAreaView'; import StatusBar from '../../containers/StatusBar'; -import { IApplicationState, IBaseScreen, RootEnum } from '../../definitions'; +import { IApplicationState, IBaseScreen, IUser, RootEnum } from '../../definitions'; import I18n, { isRTL, LANGUAGES } from '../../i18n'; import database from '../../lib/database'; import RocketChat from '../../lib/rocketchat'; @@ -20,10 +20,7 @@ import { showErrorAlert } from '../../utils/info'; import log, { events, logEvent } from '../../utils/log'; interface ILanguageViewProps extends IBaseScreen { - user: { - id: string; - language: string; - }; + user: IUser; } interface ILanguageViewState { @@ -38,7 +35,7 @@ class LanguageView extends React.Component { try { const userRecord = await usersCollection.find(user.id); - await userRecord.update((record: any) => { + await userRecord.update(record => { record.language = params.language; }); } catch (e) { diff --git a/app/views/ProfileView/index.tsx b/app/views/ProfileView/index.tsx index 2d0724f8f..91a82d9ef 100644 --- a/app/views/ProfileView/index.tsx +++ b/app/views/ProfileView/index.tsx @@ -37,9 +37,9 @@ import { INavigationOptions, IParams, IProfileViewProps, - IProfileViewState, - IUser + IProfileViewState } from '../../definitions/IProfileViewInterfaces'; +import { IUser } from '../../definitions'; class ProfileView extends React.Component { private name: any; @@ -116,7 +116,7 @@ class ProfileView extends React.Component const { name, username, emails, customFields } = user || userProps; this.setState({ - name, + name: name as string, username, email: emails ? emails[0].address : null, newPassword: null, diff --git a/app/views/SelectedUsersView.tsx b/app/views/SelectedUsersView.tsx index dfe62aaf4..5b9b3810f 100644 --- a/app/views/SelectedUsersView.tsx +++ b/app/views/SelectedUsersView.tsx @@ -13,7 +13,7 @@ import Loading from '../containers/Loading'; import SafeAreaView from '../containers/SafeAreaView'; import SearchBox from '../containers/SearchBox'; import StatusBar from '../containers/StatusBar'; -import { IApplicationState, IBaseScreen, ISubscription } from '../definitions'; +import { IApplicationState, IBaseScreen, ISubscription, IUser } from '../definitions'; import I18n from '../i18n'; import database from '../lib/database'; import RocketChat from '../lib/rocketchat'; @@ -39,12 +39,7 @@ interface ISelectedUsersViewProps extends IBaseScreen { server: IServer; isMasterDetail: boolean; - user: { - roles: []; - id: string; - }; + user: IUser; } class SettingsView extends React.Component { diff --git a/app/views/SidebarView/index.tsx b/app/views/SidebarView/index.tsx index 77db882db..5ead8241a 100644 --- a/app/views/SidebarView/index.tsx +++ b/app/views/SidebarView/index.tsx @@ -19,7 +19,7 @@ import Navigation from '../../lib/navigation/appNavigation'; import SidebarItem from './SidebarItem'; import styles from './styles'; import { DrawerParamList } from '../../stacks/types'; -import { TUserStatus } from '../../definitions'; +import { IUser } from '../../definitions'; interface ISeparatorProps { theme: string; @@ -39,13 +39,7 @@ interface ISidebarProps { navigation: DrawerNavigationProp; state: DrawerNavigationState; Site_Name: string; - user: { - statusText: string; - status: TUserStatus; - username: string; - name: string; - roles: string[]; - }; + user: IUser; theme?: string; loadingServer: boolean; useRealName: boolean; diff --git a/app/views/StatusView.tsx b/app/views/StatusView.tsx index 07d7138ca..8a11e12cc 100644 --- a/app/views/StatusView.tsx +++ b/app/views/StatusView.tsx @@ -64,7 +64,7 @@ interface IStatusViewState { } interface IStatusViewProps extends IBaseScreen { - user: Pick; + user: IUser; isMasterDetail: boolean; Accounts_AllowInvisibleStatusOption: boolean; } diff --git a/app/views/UserNotificationPreferencesView/index.tsx b/app/views/UserNotificationPreferencesView/index.tsx index fe4bdece8..9dd1d5c28 100644 --- a/app/views/UserNotificationPreferencesView/index.tsx +++ b/app/views/UserNotificationPreferencesView/index.tsx @@ -15,7 +15,7 @@ import { getUserSelector } from '../../selectors/login'; import sharedStyles from '../Styles'; import { OPTIONS } from './options'; import { ProfileStackParamList } from '../../stacks/types'; -import { INotificationPreferences } from '../../definitions'; +import { INotificationPreferences, IUser } from '../../definitions'; const styles = StyleSheet.create({ pickerText: { @@ -34,9 +34,7 @@ interface IUserNotificationPreferencesViewState { interface IUserNotificationPreferencesViewProps { navigation: StackNavigationProp; theme: string; - user: { - id: string; - }; + user: IUser; } class UserNotificationPreferencesView extends React.Component< From e5253927131c116d1e21d476b7b0dc3a51d646c0 Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Silva Date: Thu, 7 Apr 2022 13:53:07 -0300 Subject: [PATCH 7/9] Chore: Move services and methods away from rocketchat folder (#4033) * move services to lib * move methods to lib * fix imports --- app/ee/omnichannel/lib/index.ts | 2 +- .../omnichannel/lib/subscriptions/inquiry.ts | 2 +- app/lib/methods/actions.ts | 2 +- app/lib/{rocketchat => }/methods/callJitsi.ts | 8 ++-- app/lib/methods/canOpenRoom.ts | 2 +- .../methods/enterpriseModules.ts | 10 ++--- .../methods/getCustomEmojis.ts | 14 +++---- .../{rocketchat => }/methods/getPermalinks.ts | 8 ++-- .../methods/getPermissions.ts | 14 +++---- app/lib/{rocketchat => }/methods/getRoles.ts | 14 +++---- app/lib/methods/getRooms.ts | 2 +- .../{rocketchat => }/methods/getSettings.ts | 26 ++++++------- app/lib/methods/getSlashCommands.ts | 2 +- .../methods/getUsersPresence.ts | 14 +++---- app/lib/{rocketchat => }/methods/helpers.ts | 10 ++--- app/lib/methods/loadMessagesForRoom.ts | 2 +- app/lib/methods/loadMissedMessages.ts | 2 +- app/lib/methods/loadNextMessages.ts | 2 +- app/lib/methods/loadSurroundingMessages.ts | 2 +- app/lib/methods/loadThreadMessages.ts | 2 +- app/lib/{rocketchat => }/methods/logout.ts | 20 +++++----- app/lib/methods/readMessages.ts | 2 +- app/lib/{rocketchat => }/methods/search.ts | 6 +-- .../methods/sendFileMessage.ts | 10 ++--- app/lib/methods/sendMessage.ts | 2 +- app/lib/{rocketchat => }/methods/setUser.ts | 8 ++-- app/lib/methods/subscriptions/room.ts | 2 +- app/lib/methods/subscriptions/rooms.ts | 2 +- .../methods/triggerActions.ts | 8 ++-- .../methods/userPreferencesMethods.ts | 4 +- .../{rocketchat/index.ts => rocketchat.ts} | 26 ++++++------- app/lib/{rocketchat => }/services/connect.ts | 38 +++++++++---------- .../services/getServerTimeSync.ts | 0 app/lib/{rocketchat => }/services/restApi.ts | 22 +++++------ app/lib/{rocketchat => }/services/sdk.ts | 8 ++-- .../services/shareExtension.ts | 18 ++++----- app/reducers/permissions.ts | 2 +- app/sagas/login.js | 2 +- app/share.tsx | 2 +- app/utils/localAuthentication.ts | 2 +- app/views/SelectServerView.tsx | 2 +- 41 files changed, 163 insertions(+), 163 deletions(-) rename app/lib/{rocketchat => }/methods/callJitsi.ts (87%) rename app/lib/{rocketchat => }/methods/enterpriseModules.ts (87%) rename app/lib/{rocketchat => }/methods/getCustomEmojis.ts (91%) rename app/lib/{rocketchat => }/methods/getPermalinks.ts (81%) rename app/lib/{rocketchat => }/methods/getPermissions.ts (91%) rename app/lib/{rocketchat => }/methods/getRoles.ts (90%) rename app/lib/{rocketchat => }/methods/getSettings.ts (87%) rename app/lib/{rocketchat => }/methods/getUsersPresence.ts (88%) rename app/lib/{rocketchat => }/methods/helpers.ts (95%) rename app/lib/{rocketchat => }/methods/logout.ts (87%) rename app/lib/{rocketchat => }/methods/search.ts (93%) rename app/lib/{rocketchat => }/methods/sendFileMessage.ts (93%) rename app/lib/{rocketchat => }/methods/setUser.ts (81%) rename app/lib/{rocketchat => }/methods/triggerActions.ts (77%) rename app/lib/{rocketchat => }/methods/userPreferencesMethods.ts (74%) rename app/lib/{rocketchat/index.ts => rocketchat.ts} (70%) rename app/lib/{rocketchat => }/services/connect.ts (93%) rename app/lib/{rocketchat => }/services/getServerTimeSync.ts (100%) rename app/lib/{rocketchat => }/services/restApi.ts (97%) rename app/lib/{rocketchat => }/services/sdk.ts (95%) rename app/lib/{rocketchat => }/services/shareExtension.ts (84%) diff --git a/app/ee/omnichannel/lib/index.ts b/app/ee/omnichannel/lib/index.ts index c7c45dc65..efe6d5083 100644 --- a/app/ee/omnichannel/lib/index.ts +++ b/app/ee/omnichannel/lib/index.ts @@ -1,4 +1,4 @@ -import sdk from '../../../lib/rocketchat/services/sdk'; +import sdk from '../../../lib/services/sdk'; import { IUser } from '../../../definitions'; import EventEmitter from '../../../utils/events'; import subscribeInquiry from './subscriptions/inquiry'; diff --git a/app/ee/omnichannel/lib/subscriptions/inquiry.ts b/app/ee/omnichannel/lib/subscriptions/inquiry.ts index 480677f2e..e9358133e 100644 --- a/app/ee/omnichannel/lib/subscriptions/inquiry.ts +++ b/app/ee/omnichannel/lib/subscriptions/inquiry.ts @@ -2,7 +2,7 @@ import log from '../../../../utils/log'; import { store } from '../../../../lib/store/auxStore'; import RocketChat from '../../../../lib/rocketchat'; import { inquiryQueueAdd, inquiryQueueRemove, inquiryQueueUpdate, inquiryRequest } from '../../actions/inquiry'; -import sdk from '../../../../lib/rocketchat/services/sdk'; +import sdk from '../../../../lib/services/sdk'; import { IOmnichannelRoom } from '../../../../definitions'; interface IArgsQueueOmnichannel extends IOmnichannelRoom { diff --git a/app/lib/methods/actions.ts b/app/lib/methods/actions.ts index da4c55db7..5425f49c8 100644 --- a/app/lib/methods/actions.ts +++ b/app/lib/methods/actions.ts @@ -4,7 +4,7 @@ import EventEmitter from '../../utils/events'; import fetch from '../../utils/fetch'; import random from '../../utils/random'; import Navigation from '../navigation/appNavigation'; -import sdk from '../rocketchat/services/sdk'; +import sdk from '../services/sdk'; const triggersId = new Map(); diff --git a/app/lib/rocketchat/methods/callJitsi.ts b/app/lib/methods/callJitsi.ts similarity index 87% rename from app/lib/rocketchat/methods/callJitsi.ts rename to app/lib/methods/callJitsi.ts index 1668802f1..fcfd450ed 100644 --- a/app/lib/rocketchat/methods/callJitsi.ts +++ b/app/lib/methods/callJitsi.ts @@ -1,7 +1,7 @@ -import { ISubscription } from '../../../definitions'; -import { events, logEvent } from '../../../utils/log'; -import { store } from '../../store/auxStore'; -import Navigation from '../../navigation/appNavigation'; +import { ISubscription } from '../../definitions'; +import { events, logEvent } from '../../utils/log'; +import { store } from '../store/auxStore'; +import Navigation from '../navigation/appNavigation'; import sdk from '../services/sdk'; async function jitsiURL({ room }: { room: ISubscription }) { diff --git a/app/lib/methods/canOpenRoom.ts b/app/lib/methods/canOpenRoom.ts index 404afa8a2..46c041537 100644 --- a/app/lib/methods/canOpenRoom.ts +++ b/app/lib/methods/canOpenRoom.ts @@ -2,7 +2,7 @@ import { ERoomTypes } from '../../definitions'; import { store } from '../store/auxStore'; import database from '../database'; import RocketChat from '../rocketchat'; -import sdk from '../rocketchat/services/sdk'; +import sdk from '../services/sdk'; const restTypes = { channel: 'channels', diff --git a/app/lib/rocketchat/methods/enterpriseModules.ts b/app/lib/methods/enterpriseModules.ts similarity index 87% rename from app/lib/rocketchat/methods/enterpriseModules.ts rename to app/lib/methods/enterpriseModules.ts index a38b99f81..e33cd7dcf 100644 --- a/app/lib/rocketchat/methods/enterpriseModules.ts +++ b/app/lib/methods/enterpriseModules.ts @@ -1,9 +1,9 @@ import sdk from '../services/sdk'; -import { store as reduxStore } from '../../store/auxStore'; -import database from '../../database'; -import log from '../../../utils/log'; -import { clearEnterpriseModules, setEnterpriseModules as setEnterpriseModulesAction } from '../../../actions/enterpriseModules'; -import { compareServerVersion } from '../../methods/helpers/compareServerVersion'; +import { store as reduxStore } from '../store/auxStore'; +import database from '../database'; +import log from '../../utils/log'; +import { clearEnterpriseModules, setEnterpriseModules as setEnterpriseModulesAction } from '../../actions/enterpriseModules'; +import { compareServerVersion } from './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/methods/getCustomEmojis.ts similarity index 91% rename from app/lib/rocketchat/methods/getCustomEmojis.ts rename to app/lib/methods/getCustomEmojis.ts index 278693d47..4f664efaa 100644 --- a/app/lib/rocketchat/methods/getCustomEmojis.ts +++ b/app/lib/methods/getCustomEmojis.ts @@ -1,14 +1,14 @@ import orderBy from 'lodash/orderBy'; import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord'; -import { ICustomEmojis } from '../../../reducers/customEmojis'; -import { store as reduxStore } from '../../store/auxStore'; -import database from '../../database'; -import log from '../../../utils/log'; -import { setCustomEmojis as setCustomEmojisAction } from '../../../actions/customEmojis'; -import { ICustomEmoji, TCustomEmojiModel } from '../../../definitions'; +import { ICustomEmojis } from '../../reducers/customEmojis'; +import { store as reduxStore } from '../store/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'; +import { compareServerVersion } from './helpers/compareServerVersion'; interface IUpdateEmojis { update: TCustomEmojiModel[]; diff --git a/app/lib/rocketchat/methods/getPermalinks.ts b/app/lib/methods/getPermalinks.ts similarity index 81% rename from app/lib/rocketchat/methods/getPermalinks.ts rename to app/lib/methods/getPermalinks.ts index 8e66517c1..29ec4d2bd 100644 --- a/app/lib/rocketchat/methods/getPermalinks.ts +++ b/app/lib/methods/getPermalinks.ts @@ -1,8 +1,8 @@ -import log from '../../../utils/log'; -import { TMessageModel, TSubscriptionModel } from '../../../definitions'; -import { store } from '../../store/auxStore'; -import getRoom from '../../methods/getRoom'; +import log from '../../utils/log'; +import { TMessageModel, TSubscriptionModel } from '../../definitions'; +import { store } from '../store/auxStore'; import { isGroupChat } from './helpers'; +import getRoom from './getRoom'; type TRoomType = 'p' | 'c' | 'd'; diff --git a/app/lib/rocketchat/methods/getPermissions.ts b/app/lib/methods/getPermissions.ts similarity index 91% rename from app/lib/rocketchat/methods/getPermissions.ts rename to app/lib/methods/getPermissions.ts index 36199a5c8..58aeba0da 100644 --- a/app/lib/rocketchat/methods/getPermissions.ts +++ b/app/lib/methods/getPermissions.ts @@ -2,14 +2,14 @@ import { Q } from '@nozbe/watermelondb'; import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord'; import orderBy from 'lodash/orderBy'; -import { setPermissions as setPermissionsAction } from '../../../actions/permissions'; -import { IPermission, TPermissionModel } from '../../../definitions'; -import log from '../../../utils/log'; -import { store as reduxStore } from '../../store/auxStore'; -import database from '../../database'; +import { setPermissions as setPermissionsAction } from '../../actions/permissions'; +import { IPermission, TPermissionModel } from '../../definitions'; +import log from '../../utils/log'; +import { store as reduxStore } from '../store/auxStore'; +import database from '../database'; import sdk from '../services/sdk'; -import protectedFunction from '../../methods/helpers/protectedFunction'; -import { compareServerVersion } from '../../methods/helpers/compareServerVersion'; +import protectedFunction from './helpers/protectedFunction'; +import { compareServerVersion } from './helpers/compareServerVersion'; export const SUPPORTED_PERMISSIONS = [ 'add-user-to-any-c-room', diff --git a/app/lib/rocketchat/methods/getRoles.ts b/app/lib/methods/getRoles.ts similarity index 90% rename from app/lib/rocketchat/methods/getRoles.ts rename to app/lib/methods/getRoles.ts index 0382a7bb3..93f7596d2 100644 --- a/app/lib/rocketchat/methods/getRoles.ts +++ b/app/lib/methods/getRoles.ts @@ -1,14 +1,14 @@ import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord'; import Model from '@nozbe/watermelondb/Model'; -import database from '../../database'; -import { getRoleById } from '../../database/services/Role'; -import log from '../../../utils/log'; -import { store as reduxStore } from '../../store/auxStore'; -import { removeRoles, setRoles as setRolesAction, updateRoles } from '../../../actions/roles'; -import protectedFunction from '../../methods/helpers/protectedFunction'; -import { TRoleModel } from '../../../definitions'; +import database from '../database'; +import { getRoleById } from '../database/services/Role'; +import log from '../../utils/log'; +import { store as reduxStore } from '../store/auxStore'; +import { removeRoles, setRoles as setRolesAction, updateRoles } from '../../actions/roles'; +import { TRoleModel } from '../../definitions'; import sdk from '../services/sdk'; +import protectedFunction from './helpers/protectedFunction'; export async function setRoles(): Promise { const db = database.active; diff --git a/app/lib/methods/getRooms.ts b/app/lib/methods/getRooms.ts index 8d7f89397..cc7a37d77 100644 --- a/app/lib/methods/getRooms.ts +++ b/app/lib/methods/getRooms.ts @@ -1,4 +1,4 @@ -import sdk from '../rocketchat/services/sdk'; +import sdk from '../services/sdk'; export default function (updatedSince: Date) { // subscriptions.get: Since RC 0.60.0 diff --git a/app/lib/rocketchat/methods/getSettings.ts b/app/lib/methods/getSettings.ts similarity index 87% rename from app/lib/rocketchat/methods/getSettings.ts rename to app/lib/methods/getSettings.ts index f0659c06a..8c53f6faa 100644 --- a/app/lib/rocketchat/methods/getSettings.ts +++ b/app/lib/methods/getSettings.ts @@ -1,16 +1,16 @@ import { Q } from '@nozbe/watermelondb'; import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord'; -import { addSettings, clearSettings } from '../../../actions/settings'; -import { DEFAULT_AUTO_LOCK, defaultSettings } from '../../constants'; -import { IPreparedSettings, ISettingsIcon } from '../../../definitions'; -import fetch from '../../../utils/fetch'; -import log from '../../../utils/log'; -import { store as reduxStore } from '../../store/auxStore'; -import database from '../../database'; -import RocketChat from '..'; +import { addSettings, clearSettings } from '../../actions/settings'; +import { DEFAULT_AUTO_LOCK, defaultSettings } from '../constants'; +import { IPreparedSettings, ISettingsIcon } from '../../definitions'; +import fetch from '../../utils/fetch'; +import log from '../../utils/log'; +import { store as reduxStore } from '../store/auxStore'; +import database from '../database'; import sdk from '../services/sdk'; -import protectedFunction from '../../methods/helpers/protectedFunction'; +import { parseSettings, _prepareSettings } from './helpers'; +import protectedFunction from './helpers/protectedFunction'; const serverInfoKeys = [ 'Site_Name', @@ -112,7 +112,7 @@ export async function getLoginSettings({ server }: { server: string }): Promise< if (result.success && result.settings.length) { reduxStore.dispatch(clearSettings()); - reduxStore.dispatch(addSettings(RocketChat.parseSettings(RocketChat._prepareSettings(result.settings)))); + reduxStore.dispatch(addSettings(parseSettings(_prepareSettings(result.settings)))); } } catch (e) { log(e); @@ -131,7 +131,7 @@ export async function setSettings(): Promise { valueAsArray: item.valueAsArray, _updatedAt: item._updatedAt })); - reduxStore.dispatch(addSettings(RocketChat.parseSettings(parsed.slice(0, parsed.length)))); + reduxStore.dispatch(addSettings(parseSettings(parsed.slice(0, parsed.length)))); } export function subscribeSettings(): void { @@ -155,10 +155,10 @@ export async function getSettings(): Promise { return; } const data: IData[] = result.settings || []; - const filteredSettings: IPreparedSettings[] = RocketChat._prepareSettings(data); + const filteredSettings: IPreparedSettings[] = _prepareSettings(data); const filteredSettingsIds = filteredSettings.map(s => s._id); - reduxStore.dispatch(addSettings(RocketChat.parseSettings(filteredSettings))); + reduxStore.dispatch(addSettings(parseSettings(filteredSettings))); // filter server info const serverInfo = filteredSettings.filter(i1 => serverInfoKeys.includes(i1._id)); diff --git a/app/lib/methods/getSlashCommands.ts b/app/lib/methods/getSlashCommands.ts index ed9f37783..d2fbe2a7b 100644 --- a/app/lib/methods/getSlashCommands.ts +++ b/app/lib/methods/getSlashCommands.ts @@ -4,7 +4,7 @@ import database from '../database'; import log from '../../utils/log'; import protectedFunction from './helpers/protectedFunction'; import { ISlashCommandResult, TSlashCommandModel } from '../../definitions'; -import sdk from '../rocketchat/services/sdk'; +import sdk from '../services/sdk'; export default function getSlashCommands() { const db = database.active; diff --git a/app/lib/rocketchat/methods/getUsersPresence.ts b/app/lib/methods/getUsersPresence.ts similarity index 88% rename from app/lib/rocketchat/methods/getUsersPresence.ts rename to app/lib/methods/getUsersPresence.ts index e7c24f663..b8587e43a 100644 --- a/app/lib/rocketchat/methods/getUsersPresence.ts +++ b/app/lib/methods/getUsersPresence.ts @@ -1,14 +1,14 @@ import { InteractionManager } from 'react-native'; import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord'; -import { IActiveUsers } from '../../../reducers/activeUsers'; -import { store as reduxStore } from '../../store/auxStore'; -import { setActiveUsers } from '../../../actions/activeUsers'; -import { setUser } from '../../../actions/login'; -import database from '../../database'; -import { IRocketChat, IUser } from '../../../definitions'; +import { IActiveUsers } from '../../reducers/activeUsers'; +import { store as reduxStore } from '../store/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'; +import { compareServerVersion } from './helpers/compareServerVersion'; export function subscribeUsersPresence(this: IRocketChat) { const serverVersion = reduxStore.getState().server.version as string; diff --git a/app/lib/rocketchat/methods/helpers.ts b/app/lib/methods/helpers.ts similarity index 95% rename from app/lib/rocketchat/methods/helpers.ts rename to app/lib/methods/helpers.ts index d62df0062..c4c360234 100644 --- a/app/lib/rocketchat/methods/helpers.ts +++ b/app/lib/methods/helpers.ts @@ -1,11 +1,11 @@ // @ts-nocheck - TEMP import AsyncStorage from '@react-native-community/async-storage'; -import log from '../../../utils/log'; -import { store as reduxStore } from '../../store/auxStore'; -import database from '../../database'; -import subscribeRoomsTmp from '../../methods/subscriptions/rooms'; -import { ANALYTICS_EVENTS_KEY, CRASH_REPORT_KEY, defaultSettings } from '../../constants'; +import log from '../../utils/log'; +import { store as reduxStore } from '../store/auxStore'; +import database from '../database'; +import subscribeRoomsTmp from './subscriptions/rooms'; +import { ANALYTICS_EVENTS_KEY, CRASH_REPORT_KEY, defaultSettings } from '../constants'; export function isGroupChat(room): boolean { return ((room.uids && room.uids.length > 2) || (room.usernames && room.usernames.length > 2)) ?? false; diff --git a/app/lib/methods/loadMessagesForRoom.ts b/app/lib/methods/loadMessagesForRoom.ts index 234434b77..87ec9919b 100644 --- a/app/lib/methods/loadMessagesForRoom.ts +++ b/app/lib/methods/loadMessagesForRoom.ts @@ -5,7 +5,7 @@ import { IMessage, TMessageModel } from '../../definitions'; import log from '../../utils/log'; import { getMessageById } from '../database/services/Message'; import roomTypeToApiType, { RoomTypes } from './roomTypeToApiType'; -import sdk from '../rocketchat/services/sdk'; +import sdk from '../services/sdk'; import updateMessages from './updateMessages'; import { generateLoadMoreId } from './helpers/generateLoadMoreId'; diff --git a/app/lib/methods/loadMissedMessages.ts b/app/lib/methods/loadMissedMessages.ts index 5a114269c..cb5e0712d 100644 --- a/app/lib/methods/loadMissedMessages.ts +++ b/app/lib/methods/loadMissedMessages.ts @@ -1,7 +1,7 @@ import { ILastMessage } from '../../definitions'; import log from '../../utils/log'; import database from '../database'; -import sdk from '../rocketchat/services/sdk'; +import sdk from '../services/sdk'; import updateMessages from './updateMessages'; const getLastUpdate = async (rid: string) => { diff --git a/app/lib/methods/loadNextMessages.ts b/app/lib/methods/loadNextMessages.ts index a7a729ad3..533059cdb 100644 --- a/app/lib/methods/loadNextMessages.ts +++ b/app/lib/methods/loadNextMessages.ts @@ -7,7 +7,7 @@ import { getMessageById } from '../database/services/Message'; import { MessageTypeLoad } from '../constants'; import updateMessages from './updateMessages'; import { TMessageModel } from '../../definitions'; -import sdk from '../rocketchat/services/sdk'; +import sdk from '../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 81ea1523d..35abf4083 100644 --- a/app/lib/methods/loadSurroundingMessages.ts +++ b/app/lib/methods/loadSurroundingMessages.ts @@ -5,7 +5,7 @@ import orderBy from 'lodash/orderBy'; import log from '../../utils/log'; import { getMessageById } from '../database/services/Message'; import { MessageTypeLoad } from '../constants'; -import sdk from '../rocketchat/services/sdk'; +import sdk from '../services/sdk'; import { IMessage } from '../../definitions'; import updateMessages from './updateMessages'; import { generateLoadMoreId } from './helpers/generateLoadMoreId'; diff --git a/app/lib/methods/loadThreadMessages.ts b/app/lib/methods/loadThreadMessages.ts index e9390668e..82beeeeac 100644 --- a/app/lib/methods/loadThreadMessages.ts +++ b/app/lib/methods/loadThreadMessages.ts @@ -8,7 +8,7 @@ import { Encryption } from '../encryption'; import protectedFunction from './helpers/protectedFunction'; import buildMessage from './helpers/buildMessage'; import { TThreadMessageModel } from '../../definitions'; -import sdk from '../rocketchat/services/sdk'; +import sdk from '../services/sdk'; async function load({ tmid }: { tmid: string }) { try { diff --git a/app/lib/rocketchat/methods/logout.ts b/app/lib/methods/logout.ts similarity index 87% rename from app/lib/rocketchat/methods/logout.ts rename to app/lib/methods/logout.ts index d070002a3..eac5b8ac9 100644 --- a/app/lib/rocketchat/methods/logout.ts +++ b/app/lib/methods/logout.ts @@ -2,17 +2,17 @@ import * as FileSystem from 'expo-file-system'; import { Rocketchat as RocketchatClient } from '@rocket.chat/sdk'; import Model from '@nozbe/watermelondb/Model'; -import { getDeviceToken } from '../../../notifications/push'; -import { extractHostname } from '../../../utils/server'; -import { BASIC_AUTH_KEY } from '../../../utils/fetch'; -import database, { getDatabase } from '../../database'; -import RocketChat from '..'; -import { useSsl } from '../../../utils/url'; -import log from '../../../utils/log'; -import UserPreferences from '../../methods/userPreferences'; -import { ICertificate, IRocketChat } from '../../../definitions'; +import { getDeviceToken } from '../../notifications/push'; +import { extractHostname } from '../../utils/server'; +import { BASIC_AUTH_KEY } from '../../utils/fetch'; +import database, { getDatabase } from '../database'; +import { useSsl } from '../../utils/url'; +import log from '../../utils/log'; +import { ICertificate, IRocketChat } from '../../definitions'; import sdk from '../services/sdk'; -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 RocketChat from '../rocketchat'; function removeServerKeys({ server, userId }: { server: string; userId?: string | null }) { UserPreferences.removeItem(`${RocketChat.TOKEN_KEY}-${server}`); diff --git a/app/lib/methods/readMessages.ts b/app/lib/methods/readMessages.ts index 339000a3a..27f4808bb 100644 --- a/app/lib/methods/readMessages.ts +++ b/app/lib/methods/readMessages.ts @@ -1,7 +1,7 @@ import database from '../database'; import log from '../../utils/log'; import { TSubscriptionModel } from '../../definitions'; -import sdk from '../rocketchat/services/sdk'; +import sdk from '../services/sdk'; export default async function readMessages(rid: string, ls: Date, updateLastOpen = false): Promise { try { diff --git a/app/lib/rocketchat/methods/search.ts b/app/lib/methods/search.ts similarity index 93% rename from app/lib/rocketchat/methods/search.ts rename to app/lib/methods/search.ts index f094077dd..d8f0f7d1a 100644 --- a/app/lib/rocketchat/methods/search.ts +++ b/app/lib/methods/search.ts @@ -1,9 +1,9 @@ import { Q } from '@nozbe/watermelondb'; -import { sanitizeLikeString } from '../../database/utils'; -import database from '../../database/index'; +import { sanitizeLikeString } from '../database/utils'; +import database from '../database/index'; import { spotlight } from '../services/restApi'; -import { ISearch, ISearchLocal, SubscriptionType } from '../../../definitions'; +import { ISearch, ISearchLocal, SubscriptionType } from '../../definitions'; import { isGroupChat } from './helpers'; let debounce: null | ((reason: string) => void) = null; diff --git a/app/lib/rocketchat/methods/sendFileMessage.ts b/app/lib/methods/sendFileMessage.ts similarity index 93% rename from app/lib/rocketchat/methods/sendFileMessage.ts rename to app/lib/methods/sendFileMessage.ts index 2d5a012e2..e282f5555 100644 --- a/app/lib/rocketchat/methods/sendFileMessage.ts +++ b/app/lib/methods/sendFileMessage.ts @@ -3,11 +3,11 @@ import { settings as RocketChatSettings } from '@rocket.chat/sdk'; import { FetchBlobResponse, StatefulPromise } from 'rn-fetch-blob'; import isEmpty from 'lodash/isEmpty'; -import FileUpload from '../../../utils/fileUpload'; -import database from '../../database'; -import log from '../../../utils/log'; -import { IUpload, IUser, TUploadModel } from '../../../definitions'; -import { IFileUpload } from '../../../utils/fileUpload/interfaces'; +import FileUpload from '../../utils/fileUpload'; +import database from '../database'; +import log from '../../utils/log'; +import { IUpload, IUser, TUploadModel } from '../../definitions'; +import { IFileUpload } from '../../utils/fileUpload/interfaces'; const uploadQueue: { [index: string]: StatefulPromise } = {}; diff --git a/app/lib/methods/sendMessage.ts b/app/lib/methods/sendMessage.ts index 95a3537d0..06738a470 100644 --- a/app/lib/methods/sendMessage.ts +++ b/app/lib/methods/sendMessage.ts @@ -6,7 +6,7 @@ import log from '../../utils/log'; import random from '../../utils/random'; import { Encryption } from '../encryption'; import { E2EType, IMessage, IUser, TMessageModel } from '../../definitions'; -import sdk from '../rocketchat/services/sdk'; +import sdk from '../services/sdk'; import { E2E_MESSAGE_TYPE, E2E_STATUS, messagesStatus } from '../constants'; const changeMessageStatus = async (id: string, status: number, tmid?: string, message?: IMessage) => { diff --git a/app/lib/rocketchat/methods/setUser.ts b/app/lib/methods/setUser.ts similarity index 81% rename from app/lib/rocketchat/methods/setUser.ts rename to app/lib/methods/setUser.ts index 6cc31e5de..5d7f16752 100644 --- a/app/lib/rocketchat/methods/setUser.ts +++ b/app/lib/methods/setUser.ts @@ -1,9 +1,9 @@ import { InteractionManager } from 'react-native'; -import { setActiveUsers } from '../../../actions/activeUsers'; -import { setUser } from '../../../actions/login'; -import { store as reduxStore } from '../../store/auxStore'; -import { compareServerVersion } from '../../methods/helpers/compareServerVersion'; +import { setActiveUsers } from '../../actions/activeUsers'; +import { setUser } from '../../actions/login'; +import { store as reduxStore } from '../store/auxStore'; +import { compareServerVersion } from './helpers/compareServerVersion'; // TODO export function _setUser(this: any, ddpMessage: { fields: any; id: any; cleared: any }) { diff --git a/app/lib/methods/subscriptions/room.ts b/app/lib/methods/subscriptions/room.ts index 296180686..8685fc3aa 100644 --- a/app/lib/methods/subscriptions/room.ts +++ b/app/lib/methods/subscriptions/room.ts @@ -17,7 +17,7 @@ import { subscribeRoom, unsubscribeRoom } from '../../../actions/room'; import { Encryption } from '../../encryption'; import { IMessage, TMessageModel, TSubscriptionModel, TThreadMessageModel, TThreadModel } from '../../../definitions'; import { IDDPMessage } from '../../../definitions/IDDPMessage'; -import sdk from '../../rocketchat/services/sdk'; +import sdk from '../../services/sdk'; const WINDOW_TIME = 1000; diff --git a/app/lib/methods/subscriptions/rooms.ts b/app/lib/methods/subscriptions/rooms.ts index e03ec4805..17ab329fe 100644 --- a/app/lib/methods/subscriptions/rooms.ts +++ b/app/lib/methods/subscriptions/rooms.ts @@ -28,7 +28,7 @@ import { TThreadMessageModel, TThreadModel } from '../../../definitions'; -import sdk from '../../rocketchat/services/sdk'; +import sdk from '../../services/sdk'; import { IDDPMessage } from '../../../definitions/IDDPMessage'; import { getSubscriptionByRoomId } from '../../database/services/Subscription'; import { getMessageById } from '../../database/services/Message'; diff --git a/app/lib/rocketchat/methods/triggerActions.ts b/app/lib/methods/triggerActions.ts similarity index 77% rename from app/lib/rocketchat/methods/triggerActions.ts rename to app/lib/methods/triggerActions.ts index 65a14528e..8815ac6db 100644 --- a/app/lib/rocketchat/methods/triggerActions.ts +++ b/app/lib/methods/triggerActions.ts @@ -4,10 +4,10 @@ import { ITriggerCancel, ITriggerSubmitView, ModalActions -} from '../../../containers/UIKit/interfaces'; -import { TRocketChat } from '../../../definitions'; -import { triggerAction } from '../../methods/actions'; -import Navigation from '../../navigation/appNavigation'; +} from '../../containers/UIKit/interfaces'; +import { TRocketChat } from '../../definitions'; +import Navigation from '../navigation/appNavigation'; +import { triggerAction } from './actions'; export function triggerBlockAction(this: TRocketChat, options: ITriggerBlockAction) { return triggerAction.call(this, { type: ActionTypes.ACTION, ...options }); diff --git a/app/lib/rocketchat/methods/userPreferencesMethods.ts b/app/lib/methods/userPreferencesMethods.ts similarity index 74% rename from app/lib/rocketchat/methods/userPreferencesMethods.ts rename to app/lib/methods/userPreferencesMethods.ts index 7ab5db523..a4a625d29 100644 --- a/app/lib/rocketchat/methods/userPreferencesMethods.ts +++ b/app/lib/methods/userPreferencesMethods.ts @@ -1,5 +1,5 @@ -import { IPreferences } from '../../../definitions'; -import userPreferences from '../../methods/userPreferences'; +import { IPreferences } from '../../definitions'; +import userPreferences from './userPreferences'; const SORT_PREFS_KEY = 'RC_SORT_PREFS_KEY'; diff --git a/app/lib/rocketchat/index.ts b/app/lib/rocketchat.ts similarity index 70% rename from app/lib/rocketchat/index.ts rename to app/lib/rocketchat.ts index 43695952e..15daa9663 100644 --- a/app/lib/rocketchat/index.ts +++ b/app/lib/rocketchat.ts @@ -1,18 +1,18 @@ // Methods -import canOpenRoom from '../methods/canOpenRoom'; -import clearCache from '../methods/clearCache'; -import getRoom from '../methods/getRoom'; -import getRooms from '../methods/getRooms'; -import getSlashCommands from '../methods/getSlashCommands'; -import loadMessagesForRoom from '../methods/loadMessagesForRoom'; -import loadMissedMessages from '../methods/loadMissedMessages'; -import loadNextMessages from '../methods/loadNextMessages'; -import loadSurroundingMessages from '../methods/loadSurroundingMessages'; -import loadThreadMessages from '../methods/loadThreadMessages'; -import readMessages from '../methods/readMessages'; -import roomTypeToApiType from '../methods/roomTypeToApiType'; +import canOpenRoom from './methods/canOpenRoom'; +import clearCache from './methods/clearCache'; +import getRoom from './methods/getRoom'; +import getRooms from './methods/getRooms'; +import getSlashCommands from './methods/getSlashCommands'; +import loadMessagesForRoom from './methods/loadMessagesForRoom'; +import loadMissedMessages from './methods/loadMissedMessages'; +import loadNextMessages from './methods/loadNextMessages'; +import loadSurroundingMessages from './methods/loadSurroundingMessages'; +import loadThreadMessages from './methods/loadThreadMessages'; +import readMessages from './methods/readMessages'; +import roomTypeToApiType from './methods/roomTypeToApiType'; // Spread Methods -import * as sendMessage from '../methods/sendMessage'; +import * as sendMessage from './methods/sendMessage'; import * as callJitsi from './methods/callJitsi'; import * as enterpriseModules from './methods/enterpriseModules'; import * as getCustomEmojis from './methods/getCustomEmojis'; diff --git a/app/lib/rocketchat/services/connect.ts b/app/lib/services/connect.ts similarity index 93% rename from app/lib/rocketchat/services/connect.ts rename to app/lib/services/connect.ts index ad9e00f9a..6575a5bcd 100644 --- a/app/lib/rocketchat/services/connect.ts +++ b/app/lib/services/connect.ts @@ -4,26 +4,26 @@ import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord'; import { InteractionManager } from 'react-native'; import { Q } from '@nozbe/watermelondb'; -import log from '../../../utils/log'; -import { onRolesChanged } from '../methods/getRoles'; -import { setActiveUsers } from '../../../actions/activeUsers'; -import protectedFunction from '../../methods/helpers/protectedFunction'; -import database from '../../database'; -import { selectServerFailure } from '../../../actions/server'; -import { twoFactor } from '../../../utils/twoFactor'; -import { store } from '../../store/auxStore'; -import { loginRequest, setLoginServices, setUser } from '../../../actions/login'; +import log from '../../utils/log'; +import { setActiveUsers } from '../../actions/activeUsers'; +import protectedFunction from '../methods/helpers/protectedFunction'; +import database from '../database'; +import { selectServerFailure } from '../../actions/server'; +import { twoFactor } from '../../utils/twoFactor'; +import { store } from '../store/auxStore'; +import { loginRequest, setLoginServices, setUser } from '../../actions/login'; import sdk from './sdk'; -import I18n from '../../../i18n'; -import RocketChat from '..'; -import { ICredentials, ILoggedUser, IRocketChat, STATUSES } from '../../../definitions'; -import { isIOS } from '../../../utils/deviceInfo'; -import { connectRequest, connectSuccess, disconnect as disconnectAction } from '../../../actions/connect'; -import { updatePermission } from '../../../actions/permissions'; -import EventEmitter from '../../../utils/events'; -import { updateSettings } from '../../../actions/settings'; -import { defaultSettings, MIN_ROCKETCHAT_VERSION } from '../../constants'; -import { compareServerVersion } from '../../methods/helpers/compareServerVersion'; +import I18n from '../../i18n'; +import RocketChat from '../rocketchat'; +import { ICredentials, ILoggedUser, IRocketChat, STATUSES } from '../../definitions'; +import { isIOS } from '../../utils/deviceInfo'; +import { connectRequest, connectSuccess, disconnect as disconnectAction } from '../../actions/connect'; +import { updatePermission } from '../../actions/permissions'; +import EventEmitter from '../../utils/events'; +import { updateSettings } from '../../actions/settings'; +import { defaultSettings, MIN_ROCKETCHAT_VERSION } from '../constants'; +import { compareServerVersion } from '../methods/helpers/compareServerVersion'; +import { onRolesChanged } from '../methods/getRoles'; interface IServices { [index: string]: string | boolean; diff --git a/app/lib/rocketchat/services/getServerTimeSync.ts b/app/lib/services/getServerTimeSync.ts similarity index 100% rename from app/lib/rocketchat/services/getServerTimeSync.ts rename to app/lib/services/getServerTimeSync.ts diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/services/restApi.ts similarity index 97% rename from app/lib/rocketchat/services/restApi.ts rename to app/lib/services/restApi.ts index f82aad305..5f48b459a 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/services/restApi.ts @@ -7,18 +7,18 @@ import { SubscriptionType, IUser, TRocketChat -} from '../../../definitions'; -import { IAvatarSuggestion, IParams } from '../../../definitions/IProfileViewInterfaces'; -import { ISpotlight } from '../../../definitions/ISpotlight'; -import { TEAM_TYPE } from '../../../definitions/ITeam'; -import { Encryption } from '../../encryption'; -import { TParams } from '../../../definitions/ILivechatEditView'; -import { store as reduxStore } from '../../store/auxStore'; -import { getDeviceToken } from '../../../notifications/push'; -import { getBundleId, isIOS } from '../../../utils/deviceInfo'; -import roomTypeToApiType, { RoomTypes } from '../../methods/roomTypeToApiType'; +} from '../../definitions'; +import { IAvatarSuggestion, IParams } from '../../definitions/IProfileViewInterfaces'; +import { ISpotlight } from '../../definitions/ISpotlight'; +import { TEAM_TYPE } from '../../definitions/ITeam'; +import { Encryption } from '../encryption'; +import { TParams } from '../../definitions/ILivechatEditView'; +import { store as reduxStore } from '../store/auxStore'; +import { getDeviceToken } from '../../notifications/push'; +import { getBundleId, isIOS } from '../../utils/deviceInfo'; +import roomTypeToApiType, { RoomTypes } from '../methods/roomTypeToApiType'; import sdk from './sdk'; -import { compareServerVersion } from '../../methods/helpers/compareServerVersion'; +import { compareServerVersion } from '../methods/helpers/compareServerVersion'; export const createChannel = ({ name, diff --git a/app/lib/rocketchat/services/sdk.ts b/app/lib/services/sdk.ts similarity index 95% rename from app/lib/rocketchat/services/sdk.ts rename to app/lib/services/sdk.ts index fa8ec7de0..eb2c56b25 100644 --- a/app/lib/rocketchat/services/sdk.ts +++ b/app/lib/services/sdk.ts @@ -2,10 +2,10 @@ import { Rocketchat } from '@rocket.chat/sdk'; import EJSON from 'ejson'; import isEmpty from 'lodash/isEmpty'; -import { twoFactor } from '../../../utils/twoFactor'; -import { useSsl } from '../../../utils/url'; -import { store as reduxStore } from '../../store/auxStore'; -import { Serialized, MatchPathPattern, OperationParams, PathFor, ResultFor } from '../../../definitions/rest/helpers'; +import { twoFactor } from '../../utils/twoFactor'; +import { useSsl } from '../../utils/url'; +import { store as reduxStore } from '../store/auxStore'; +import { Serialized, MatchPathPattern, OperationParams, PathFor, ResultFor } from '../../definitions/rest/helpers'; class Sdk { private sdk: typeof Rocketchat; diff --git a/app/lib/rocketchat/services/shareExtension.ts b/app/lib/services/shareExtension.ts similarity index 84% rename from app/lib/rocketchat/services/shareExtension.ts rename to app/lib/services/shareExtension.ts index 4a35c0629..4970ab105 100644 --- a/app/lib/rocketchat/services/shareExtension.ts +++ b/app/lib/services/shareExtension.ts @@ -1,14 +1,14 @@ import { Q } from '@nozbe/watermelondb'; -import { shareSetSettings, shareSelectServer, shareSetUser } from '../../../actions/share'; -import SSLPinning from '../../../utils/sslPinning'; -import log from '../../../utils/log'; -import { IShareServer, IShareUser } from '../../../reducers/share'; -import UserPreferences from '../../methods/userPreferences'; -import database from '../../database'; -import RocketChat from '..'; -import { encryptionInit } from '../../../actions/encryption'; -import { store } from '../../store/auxStore'; +import { shareSetSettings, shareSelectServer, shareSetUser } from '../../actions/share'; +import SSLPinning from '../../utils/sslPinning'; +import log from '../../utils/log'; +import { IShareServer, IShareUser } from '../../reducers/share'; +import UserPreferences from '../methods/userPreferences'; +import database from '../database'; +import RocketChat from '../rocketchat'; +import { encryptionInit } from '../../actions/encryption'; +import { store } from '../store/auxStore'; import sdk from './sdk'; export async function shareExtensionInit(server: string) { diff --git a/app/reducers/permissions.ts b/app/reducers/permissions.ts index be97f7936..d2887a555 100644 --- a/app/reducers/permissions.ts +++ b/app/reducers/permissions.ts @@ -1,6 +1,6 @@ import { PERMISSIONS } from '../actions/actionsTypes'; import { TActionPermissions } from '../actions/permissions'; -import { SUPPORTED_PERMISSIONS } from '../lib/rocketchat/methods/getPermissions'; +import { SUPPORTED_PERMISSIONS } from '../lib/methods/getPermissions'; export type TSupportedPermissions = typeof SUPPORTED_PERMISSIONS[number]; diff --git a/app/sagas/login.js b/app/sagas/login.js index fa1c05515..d7cb94c54 100644 --- a/app/sagas/login.js +++ b/app/sagas/login.js @@ -20,7 +20,7 @@ import UserPreferences from '../lib/methods/userPreferences'; import { inquiryRequest, inquiryReset } from '../ee/omnichannel/actions/inquiry'; import { isOmnichannelStatusAvailable } from '../ee/omnichannel/lib'; import { RootEnum } from '../definitions'; -import sdk from '../lib/rocketchat/services/sdk'; +import sdk from '../lib/services/sdk'; const getServer = state => state.server.server; const loginWithPasswordCall = args => RocketChat.loginWithPassword(args); diff --git a/app/share.tsx b/app/share.tsx index fff29dea2..53988c7eb 100644 --- a/app/share.tsx +++ b/app/share.tsx @@ -10,7 +10,7 @@ import UserPreferences from './lib/methods/userPreferences'; import Navigation from './lib/navigation/shareNavigation'; import store from './lib/store'; import { initStore } from './lib/store/auxStore'; -import { closeShareExtension, shareExtensionInit } from './lib/rocketchat/services/shareExtension'; +import { closeShareExtension, shareExtensionInit } from './lib/services/shareExtension'; import { defaultHeader, getActiveRouteName, navigationTheme, themedHeader } from './utils/navigation'; import RocketChat from './lib/rocketchat'; import { ThemeContext, TSupportedThemes } from './theme'; diff --git a/app/utils/localAuthentication.ts b/app/utils/localAuthentication.ts index 343878f1f..f094eee8c 100644 --- a/app/utils/localAuthentication.ts +++ b/app/utils/localAuthentication.ts @@ -7,7 +7,7 @@ import moment from 'moment'; import UserPreferences from '../lib/methods/userPreferences'; import { store } from '../lib/store/auxStore'; import database from '../lib/database'; -import { getServerTimeSync } from '../lib/rocketchat/services/getServerTimeSync'; +import { getServerTimeSync } from '../lib/services/getServerTimeSync'; import { ATTEMPTS_KEY, BIOMETRY_ENABLED_KEY, diff --git a/app/views/SelectServerView.tsx b/app/views/SelectServerView.tsx index fcc4307ed..e94170c1f 100644 --- a/app/views/SelectServerView.tsx +++ b/app/views/SelectServerView.tsx @@ -7,7 +7,7 @@ import { Q, Model } from '@nozbe/watermelondb'; import I18n from '../i18n'; import StatusBar from '../containers/StatusBar'; import ServerItem, { ROW_HEIGHT } from '../presentation/ServerItem'; -import { shareExtensionInit } from '../lib/rocketchat/services/shareExtension'; +import { shareExtensionInit } from '../lib/services/shareExtension'; import database from '../lib/database'; import SafeAreaView from '../containers/SafeAreaView'; import * as List from '../containers/List'; From cd0c8abced220c06f1e19a1ea1ba463213afaad9 Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Thu, 7 Apr 2022 13:07:16 -0400 Subject: [PATCH 8/9] Chore: evaluate ServerItem - TypeScript Migration (#4015) * chore: evaluate ServerItem * update: IServerInfo interface * chore: move `ServerItem` to `containers` folder * update: `ServerItem` import on Storybook * update: `themes` import --- app/containers/ServerItem/index.tsx | 64 ++++++++++++++++++ .../ServerItem/styles.ts | 0 app/definitions/IServer.ts | 7 ++ app/presentation/ServerItem/index.tsx | 67 ------------------- app/views/RoomsListView/ServerDropdown.tsx | 5 +- app/views/SelectServerView.tsx | 2 +- app/views/ShareListView/index.tsx | 9 +-- storybook/stories/ServerItem.js | 3 +- 8 files changed, 77 insertions(+), 80 deletions(-) create mode 100644 app/containers/ServerItem/index.tsx rename app/{presentation => containers}/ServerItem/styles.ts (100%) delete mode 100644 app/presentation/ServerItem/index.tsx diff --git a/app/containers/ServerItem/index.tsx b/app/containers/ServerItem/index.tsx new file mode 100644 index 000000000..156c7f037 --- /dev/null +++ b/app/containers/ServerItem/index.tsx @@ -0,0 +1,64 @@ +import React from 'react'; +// @ts-ignore // TODO: Remove on react-native update +import { Pressable, Text, View } from 'react-native'; +import FastImage from '@rocket.chat/react-native-fast-image'; + +import { IServerInfo } from '../../definitions'; +import Check from '../Check'; +import styles, { ROW_HEIGHT } from './styles'; +import { themes } from '../../lib/constants'; +import { isIOS } from '../../utils/deviceInfo'; +import { useTheme } from '../../theme'; + +export { ROW_HEIGHT }; + +interface IServerItem { + item: IServerInfo; + onPress(): void; + onLongPress?(): void; + hasCheck?: boolean; +} + +const defaultLogo = require('../../static/images/logo.png'); + +const ServerItem = React.memo(({ item, onPress, onLongPress, hasCheck }: IServerItem) => { + const { theme } = useTheme(); + return ( + onLongPress?.()} + testID={`rooms-list-header-server-${item.id}`} + android_ripple={{ color: themes[theme].bannerBackground }} + style={({ pressed }: { pressed: boolean }) => ({ + backgroundColor: isIOS && pressed ? themes[theme].bannerBackground : themes[theme].backgroundColor + })}> + + {item.iconURL ? ( + console.log('err_loading_server_icon')} + /> + ) : ( + + )} + + + {item.name || item.id} + + + {item.id} + + + {hasCheck ? : null} + + + ); +}); + +export default ServerItem; diff --git a/app/presentation/ServerItem/styles.ts b/app/containers/ServerItem/styles.ts similarity index 100% rename from app/presentation/ServerItem/styles.ts rename to app/containers/ServerItem/styles.ts diff --git a/app/definitions/IServer.ts b/app/definitions/IServer.ts index 9eee6ee82..b207f56db 100644 --- a/app/definitions/IServer.ts +++ b/app/definitions/IServer.ts @@ -19,4 +19,11 @@ export interface IServer { E2E_Enable: boolean; } +export interface IServerInfo { + id: string; + iconURL: string; + name: string; + useRealName?: boolean; +} + export type TServerModel = IServer & Model; diff --git a/app/presentation/ServerItem/index.tsx b/app/presentation/ServerItem/index.tsx deleted file mode 100644 index a70aaf858..000000000 --- a/app/presentation/ServerItem/index.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import React from 'react'; -// @ts-ignore -import { Pressable, Text, View } from 'react-native'; -import FastImage from '@rocket.chat/react-native-fast-image'; - -import Check from '../../containers/Check'; -import styles, { ROW_HEIGHT } from './styles'; -import { themes } from '../../lib/constants'; -import { isIOS } from '../../utils/deviceInfo'; -import { withTheme } from '../../theme'; - -export { ROW_HEIGHT }; - -interface IServerItem { - item: { - id: string; - iconURL: string; - name: string; - }; - onPress(): void; - onLongPress?(): void; - hasCheck?: boolean; - theme?: string; -} - -const defaultLogo = require('../../static/images/logo.png'); - -const ServerItem = React.memo(({ item, onPress, onLongPress, hasCheck, theme }: IServerItem) => ( - onLongPress?.()} - testID={`rooms-list-header-server-${item.id}`} - android_ripple={{ - color: themes[theme!].bannerBackground - }} - style={({ pressed }: any) => ({ - backgroundColor: isIOS && pressed ? themes[theme!].bannerBackground : themes[theme!].backgroundColor - })}> - - {item.iconURL ? ( - console.log('err_loading_server_icon')} - /> - ) : ( - - )} - - - {item.name || item.id} - - - {item.id} - - - {hasCheck ? : null} - - -)); - -export default withTheme(ServerItem); diff --git a/app/views/RoomsListView/ServerDropdown.tsx b/app/views/RoomsListView/ServerDropdown.tsx index e7db06a9b..4abef24ae 100644 --- a/app/views/RoomsListView/ServerDropdown.tsx +++ b/app/views/RoomsListView/ServerDropdown.tsx @@ -12,7 +12,7 @@ import { appStart } from '../../actions/app'; import RocketChat from '../../lib/rocketchat'; import I18n from '../../i18n'; import EventEmitter from '../../utils/events'; -import ServerItem from '../../presentation/ServerItem'; +import ServerItem from '../../containers/ServerItem'; import database from '../../lib/database'; import { themes } from '../../lib/constants'; import { withTheme } from '../../theme'; @@ -180,7 +180,7 @@ class ServerDropdown extends Component { - const { server, theme } = this.props; + const { server } = this.props; return ( this.select(item.id, item.version)} onLongPress={() => item.id === server || this.remove(item.id)} hasCheck={item.id === server} - theme={theme} /> ); }; diff --git a/app/views/SelectServerView.tsx b/app/views/SelectServerView.tsx index e94170c1f..6af55ad7c 100644 --- a/app/views/SelectServerView.tsx +++ b/app/views/SelectServerView.tsx @@ -6,7 +6,7 @@ import { Q, Model } from '@nozbe/watermelondb'; import I18n from '../i18n'; import StatusBar from '../containers/StatusBar'; -import ServerItem, { ROW_HEIGHT } from '../presentation/ServerItem'; +import ServerItem, { ROW_HEIGHT } from '../containers/ServerItem'; import { shareExtensionInit } from '../lib/services/shareExtension'; import database from '../lib/database'; import SafeAreaView from '../containers/SafeAreaView'; diff --git a/app/views/ShareListView/index.tsx b/app/views/ShareListView/index.tsx index c41478163..581345e79 100644 --- a/app/views/ShareListView/index.tsx +++ b/app/views/ShareListView/index.tsx @@ -12,7 +12,7 @@ import database from '../../lib/database'; import { isAndroid, isIOS } from '../../utils/deviceInfo'; import I18n from '../../i18n'; import DirectoryItem, { ROW_HEIGHT } from '../../presentation/DirectoryItem'; -import ServerItem from '../../presentation/ServerItem'; +import ServerItem from '../../containers/ServerItem'; import * as HeaderButton from '../../containers/HeaderButton'; import ActivityIndicator from '../../containers/ActivityIndicator'; import * as List from '../../containers/List'; @@ -24,6 +24,7 @@ import RocketChat from '../../lib/rocketchat'; import { sanitizeLikeString } from '../../lib/database/utils'; import styles from './styles'; import ShareListHeader from './Header'; +import { IServerInfo } from '../../definitions'; interface IDataFromShare { value: string; @@ -52,12 +53,6 @@ interface IChat { description: string; } -interface IServerInfo { - id: string; - iconURL: string; - name: string; - useRealName: boolean; -} interface IState { searching: boolean; searchText: string; diff --git a/storybook/stories/ServerItem.js b/storybook/stories/ServerItem.js index d96e4ce74..96a3fee54 100644 --- a/storybook/stories/ServerItem.js +++ b/storybook/stories/ServerItem.js @@ -1,8 +1,7 @@ -/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions, react/prop-types */ import React from 'react'; import { storiesOf } from '@storybook/react-native'; -import ServerItemComponent from '../../app/presentation/ServerItem'; +import ServerItemComponent from '../../app/containers/ServerItem'; import { ThemeContext } from '../../app/theme'; const stories = storiesOf('ServerItem', module); From 5494037f78fcb106398c6646b8ac2381492915c1 Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Silva Date: Thu, 7 Apr 2022 16:14:04 -0300 Subject: [PATCH 9/9] Chore: Upgrade react-native-notifications to 4.2.4 (#3958) Co-authored-by: Diego Mello --- android/app/build.gradle | 4 +- .../rocket/reactnative/AdditionalModules.java | 4 +- android/settings.gradle | 2 - app/definitions/INotification.ts | 24 +++--- app/notifications/push/index.ts | 5 +- app/notifications/push/push.ios.ts | 63 --------------- app/notifications/push/push.ts | 76 +++++++++++++++--- ios/Podfile.lock | 6 +- package.json | 2 +- .../react-native-notifications+2.1.7.patch | 28 ------- .../react-native-notifications+4.2.4.patch | 79 +++++++++++++++++++ react-native.config.js | 5 -- yarn.lock | 16 +--- 13 files changed, 169 insertions(+), 145 deletions(-) delete mode 100644 app/notifications/push/push.ios.ts delete mode 100644 patches/react-native-notifications+2.1.7.patch create mode 100644 patches/react-native-notifications+4.2.4.patch diff --git a/android/app/build.gradle b/android/app/build.gradle index bedf03d37..660ec8855 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -277,14 +277,14 @@ android { dependencies { addUnimodulesDependencies() implementation project(':@react-native-community_viewpager') - playImplementation project(':reactnativenotifications') + playImplementation project(':react-native-notifications') + playImplementation 'com.google.firebase:firebase-core:16.0.0' playImplementation project(':@react-native-firebase_app') playImplementation project(':@react-native-firebase_analytics') playImplementation project(':@react-native-firebase_crashlytics') implementation fileTree(dir: "libs", include: ["*.jar"]) //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules - playImplementation "com.google.firebase:firebase-messaging:18.0.0" implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { exclude group:'com.facebook.fbjni' diff --git a/android/app/src/play/java/chat/rocket/reactnative/AdditionalModules.java b/android/app/src/play/java/chat/rocket/reactnative/AdditionalModules.java index 2b3dd08c9..5a32de49e 100644 --- a/android/app/src/play/java/chat/rocket/reactnative/AdditionalModules.java +++ b/android/app/src/play/java/chat/rocket/reactnative/AdditionalModules.java @@ -3,7 +3,6 @@ package chat.rocket.reactnative; import android.app.Application; import com.facebook.react.ReactPackage; -import com.wix.reactnativenotifications.RNNotificationsPackage; import java.util.Arrays; import java.util.List; @@ -17,8 +16,7 @@ public class AdditionalModules { return Arrays.asList( new ReactNativeFirebaseAnalyticsPackage(), new ReactNativeFirebaseAppPackage(), - new ReactNativeFirebaseCrashlyticsPackage(), - new RNNotificationsPackage(application) + new ReactNativeFirebaseCrashlyticsPackage() ); } } diff --git a/android/settings.gradle b/android/settings.gradle index 98573a99f..85d0fc081 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -2,8 +2,6 @@ apply from: '../node_modules/react-native-unimodules/gradle.groovy' includeUnimodulesProjects() rootProject.name = 'RocketChatRN' -include ':reactnativenotifications' -project(':reactnativenotifications').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-notifications/android/app') include ':@react-native-community_viewpager' project(':@react-native-community_viewpager').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/viewpager/android') include ':@react-native-firebase_app' diff --git a/app/definitions/INotification.ts b/app/definitions/INotification.ts index 4974b0c91..f387786ad 100644 --- a/app/definitions/INotification.ts +++ b/app/definitions/INotification.ts @@ -1,13 +1,15 @@ export interface INotification { - message: string; - style: string; - ejson: string; - collapse_key: string; - notId: string; - msgcnt: string; - title: string; - from: string; - image: string; - soundname: string; - getData: () => INotification; + payload: { + message: string; + style: string; + ejson: string; + collapse_key: string; + notId: string; + msgcnt: string; + title: string; + from: string; + image: string; + soundname: string; + }; + identifier: string; } diff --git a/app/notifications/push/index.ts b/app/notifications/push/index.ts index 6fced7ed3..0928c4199 100644 --- a/app/notifications/push/index.ts +++ b/app/notifications/push/index.ts @@ -17,9 +17,9 @@ interface IEjson { } export const onNotification = (push: INotification): void => { - if (push) { + if (push.payload) { try { - const notification = push?.getData(); + const notification = push.payload; const { rid, name, sender, type, host, messageType, messageId }: IEjson = EJSON.parse(notification.ejson); const types: Record = { @@ -40,7 +40,6 @@ export const onNotification = (push: INotification): void => { path: `${types[type]}/${roomName}`, isCall: messageType === 'jitsi_call_started' }; - // TODO REDUX MIGRATION TO TS store.dispatch(deepLinkingOpen(params)); } catch (e) { console.warn(e); diff --git a/app/notifications/push/push.ios.ts b/app/notifications/push/push.ios.ts deleted file mode 100644 index 00b107b02..000000000 --- a/app/notifications/push/push.ios.ts +++ /dev/null @@ -1,63 +0,0 @@ -// @ts-ignore -// TODO BUMP LIB VERSION -import NotificationsIOS, { NotificationAction, NotificationCategory, Notification } from 'react-native-notifications'; - -import { store as reduxStore } from '../../lib/store/auxStore'; -import I18n from '../../i18n'; -import { INotification } from '../../definitions/INotification'; - -class PushNotification { - onNotification: (notification: Notification) => void; - deviceToken: string; - - constructor() { - this.onNotification = () => {}; - this.deviceToken = ''; - - NotificationsIOS.addEventListener('remoteNotificationsRegistered', (deviceToken: string) => { - this.deviceToken = deviceToken; - }); - - NotificationsIOS.addEventListener('notificationOpened', (notification: Notification, completion: () => void) => { - // TODO REDUX MIGRATION TO TS - const { background } = reduxStore.getState().app; - if (background) { - this.onNotification(notification); - } - completion(); - }); - - const actions = [ - new NotificationCategory({ - identifier: 'MESSAGE', - actions: [ - new NotificationAction({ - activationMode: 'background', - title: I18n.t('Reply'), - textInput: { - buttonTitle: I18n.t('Reply'), - placeholder: I18n.t('Type_message') - }, - identifier: 'REPLY_ACTION' - }) - ] - }) - ]; - NotificationsIOS.requestPermissions(actions); - } - - getDeviceToken() { - return this.deviceToken; - } - - setBadgeCount = (count = 0) => { - NotificationsIOS.setBadgesCount(count); - }; - - async configure(onNotification: (notification: INotification) => void) { - this.onNotification = onNotification; - const initial = await NotificationsIOS.getInitialNotification(); - return Promise.resolve(initial); - } -} -export default new PushNotification(); diff --git a/app/notifications/push/push.ts b/app/notifications/push/push.ts index 11eccbcb5..e4bec45f5 100644 --- a/app/notifications/push/push.ts +++ b/app/notifications/push/push.ts @@ -1,35 +1,87 @@ -// @ts-ignore -// TODO BUMP LIB VERSION -import { NotificationsAndroid, PendingNotifications, Notification } from 'react-native-notifications'; +import { + Notifications, + Registered, + RegistrationError, + NotificationCompletion, + Notification, + NotificationAction, + NotificationCategory +} from 'react-native-notifications'; import { INotification } from '../../definitions/INotification'; +import { isIOS } from '../../utils/deviceInfo'; +import { store as reduxStore } from '../../lib/store/auxStore'; +import I18n from '../../i18n'; class PushNotification { - onNotification: (notification: Notification) => void; + onNotification: (notification: any) => void; deviceToken: string; constructor() { this.onNotification = () => {}; this.deviceToken = ''; + if (isIOS) { + // init + Notifications.ios.registerRemoteNotifications(); - NotificationsAndroid.setRegistrationTokenUpdateListener((deviceToken: string) => { - this.deviceToken = deviceToken; + // setCategories + const notificationAction = new NotificationAction('REPLY_ACTION', 'background', I18n.t('Reply'), true, { + buttonTitle: I18n.t('Reply'), + placeholder: I18n.t('Type_message') + }); + const notificationCategory = new NotificationCategory('MESSAGE', [notificationAction]); + Notifications.setCategories([notificationCategory]); + } else { + // init + Notifications.android.registerRemoteNotifications(); + } + + Notifications.events().registerRemoteNotificationsRegistered((event: Registered) => { + this.deviceToken = event.deviceToken; }); - NotificationsAndroid.setNotificationOpenedListener((notification: Notification) => { - this.onNotification(notification); + Notifications.events().registerRemoteNotificationsRegistrationFailed((event: RegistrationError) => { + // TODO: Handle error + console.log(event); }); + + Notifications.events().registerNotificationReceivedForeground( + (notification: Notification, completion: (response: NotificationCompletion) => void) => { + completion({ alert: true, sound: true, badge: false }); + } + ); + + Notifications.events().registerNotificationOpened((notification: Notification, completion: () => void) => { + if (isIOS) { + const { background } = reduxStore.getState().app; + if (background) { + this.onNotification(notification); + } + } else { + this.onNotification(notification); + } + completion(); + }); + + Notifications.events().registerNotificationReceivedBackground( + (notification: Notification, completion: (response: any) => void) => { + completion({ alert: true, sound: true, badge: false }); + } + ); } getDeviceToken() { return this.deviceToken; } - setBadgeCount = (_?: number) => {}; + setBadgeCount = (count?: number) => { + if (isIOS && count) { + Notifications.ios.setBadgeCount(count); + } + }; - configure(onNotification: (notification: INotification) => void) { + configure(onNotification: (notification: INotification) => void): Promise { this.onNotification = onNotification; - NotificationsAndroid.refreshToken(); - return PendingNotifications.getInitialNotification(); + return Notifications.getInitialNotification(); } } diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 737b35679..b0240783f 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -415,8 +415,8 @@ PODS: - React-Core - react-native-netinfo (6.0.0): - React-Core - - react-native-notifications (2.1.7): - - React + - react-native-notifications (4.2.4): + - React-Core - react-native-orientation-locker (1.1.8): - React - react-native-restart (0.0.22): @@ -1004,7 +1004,7 @@ SPEC CHECKSUMS: react-native-jitsi-meet: 3e3ac5d0445091154119f94342efd55c8b1124ce react-native-mmkv-storage: 88bcb10bbe85a8122061d17d03abcc64a02fe1c9 react-native-netinfo: e849fc21ca2f4128a5726c801a82fc6f4a6db50d - react-native-notifications: ee8fd739853e72694f3af8b374c8ccb106b7b227 + react-native-notifications: 3de8ef9cd800e5db0225d9aa46b228d2b94ce51e react-native-orientation-locker: f0ca1a8e5031dab6b74bfb4ab33a17ed2c2fcb0d react-native-restart: 733a51ad137f15b0f8dc34c4082e55af7da00979 react-native-safe-area-context: f0906bf8bc9835ac9a9d3f97e8bde2a997d8da79 diff --git a/package.json b/package.json index b2ca75937..b25456a9e 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,7 @@ "react-native-mmkv-storage": "0.6.12", "react-native-modal": "11.10.0", "react-native-navigation-bar-color": "2.0.1", - "react-native-notifications": "2.1.7", + "react-native-notifications": "^4.2.4", "react-native-notifier": "1.6.1", "react-native-orientation-locker": "1.1.8", "react-native-picker-select": "^8.0.4", diff --git a/patches/react-native-notifications+2.1.7.patch b/patches/react-native-notifications+2.1.7.patch deleted file mode 100644 index d6784c828..000000000 --- a/patches/react-native-notifications+2.1.7.patch +++ /dev/null @@ -1,28 +0,0 @@ -diff --git a/node_modules/react-native-notifications/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java b/node_modules/react-native-notifications/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java -index 524ff07..70f22d5 100644 ---- a/node_modules/react-native-notifications/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java -+++ b/node_modules/react-native-notifications/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java -@@ -31,7 +31,7 @@ public class PushNotification implements IPushNotification { - final protected AppLifecycleFacade mAppLifecycleFacade; - final protected AppLaunchHelper mAppLaunchHelper; - final protected JsIOHelper mJsIOHelper; -- final protected PushNotificationProps mNotificationProps; -+ protected PushNotificationProps mNotificationProps; - final protected AppVisibilityListener mAppVisibilityListener = new AppVisibilityListener() { - @Override - public void onAppVisible() { -diff --git a/node_modules/react-native-notifications/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java b/node_modules/react-native-notifications/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java -index f9c858b..94ea188 100644 ---- a/node_modules/react-native-notifications/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java -+++ b/node_modules/react-native-notifications/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java -@@ -2,8 +2,8 @@ - package com.wix.reactnativenotifications; - - import android.content.Context; --import android.support.annotation.NonNull; --import android.support.v4.app.NotificationManagerCompat; -+import androidx.annotation.NonNull; -+import androidx.core.app.NotificationManagerCompat; - - public abstract class NotificationManagerCompatFacade { - public static NotificationManagerCompat from(@NonNull Context context) { diff --git a/patches/react-native-notifications+4.2.4.patch b/patches/react-native-notifications+4.2.4.patch new file mode 100644 index 000000000..e2d84d886 --- /dev/null +++ b/patches/react-native-notifications+4.2.4.patch @@ -0,0 +1,79 @@ +diff --git a/node_modules/react-native-notifications/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java b/node_modules/react-native-notifications/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java +index f9c858b..94ea188 100644 +--- a/node_modules/react-native-notifications/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java ++++ b/node_modules/react-native-notifications/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java +@@ -2,8 +2,8 @@ + package com.wix.reactnativenotifications; + + import android.content.Context; +-import android.support.annotation.NonNull; +-import android.support.v4.app.NotificationManagerCompat; ++import androidx.annotation.NonNull; ++import androidx.core.app.NotificationManagerCompat; + + public abstract class NotificationManagerCompatFacade { + public static NotificationManagerCompat from(@NonNull Context context) { +diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java +index b93f762..c2b736a 100644 +--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java ++++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java +@@ -28,7 +28,7 @@ public class PushNotification implements IPushNotification { + final protected AppLifecycleFacade mAppLifecycleFacade; + final protected AppLaunchHelper mAppLaunchHelper; + final protected JsIOHelper mJsIOHelper; +- final protected PushNotificationProps mNotificationProps; ++ protected PushNotificationProps mNotificationProps; + final protected AppVisibilityListener mAppVisibilityListener = new AppVisibilityListener() { + @Override + public void onAppVisible() { +diff --git a/node_modules/react-native-notifications/lib/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java b/node_modules/react-native-notifications/lib/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java +index f9c858b..94ea188 100644 +--- a/node_modules/react-native-notifications/lib/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java ++++ b/node_modules/react-native-notifications/lib/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java +@@ -2,8 +2,8 @@ + package com.wix.reactnativenotifications; + + import android.content.Context; +-import android.support.annotation.NonNull; +-import android.support.v4.app.NotificationManagerCompat; ++import androidx.annotation.NonNull; ++import androidx.core.app.NotificationManagerCompat; + + public abstract class NotificationManagerCompatFacade { + public static NotificationManagerCompat from(@NonNull Context context) { +diff --git a/node_modules/react-native-notifications/lib/ios/RNNotificationCenter.m b/node_modules/react-native-notifications/lib/ios/RNNotificationCenter.m +index 4b33656..36aaa47 100644 +--- a/node_modules/react-native-notifications/lib/ios/RNNotificationCenter.m ++++ b/node_modules/react-native-notifications/lib/ios/RNNotificationCenter.m +@@ -29,18 +29,20 @@ - (void)requestPermissions:(NSDictionary *)options { + authOptions = authOptions | UNAuthorizationOptionAnnouncement; + } + } ++ if(![[[NSBundle mainBundle] bundlePath] hasSuffix:@".appex"]){ ++ [UNUserNotificationCenter.currentNotificationCenter requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error) { ++ if (!error && granted) { ++ [UNUserNotificationCenter.currentNotificationCenter getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) { ++ if (settings.authorizationStatus == UNAuthorizationStatusAuthorized || settings.authorizationStatus == UNAuthorizationStatusProvisional) { ++ dispatch_async(dispatch_get_main_queue(), ^{ ++ [[UIApplication sharedApplication] registerForRemoteNotifications]; ++ }); ++ } ++ }]; ++ } ++ }]; ++ } + +- [UNUserNotificationCenter.currentNotificationCenter requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error) { +- if (!error && granted) { +- [UNUserNotificationCenter.currentNotificationCenter getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) { +- if (settings.authorizationStatus == UNAuthorizationStatusAuthorized || settings.authorizationStatus == UNAuthorizationStatusProvisional) { +- dispatch_async(dispatch_get_main_queue(), ^{ +- [[UIApplication sharedApplication] registerForRemoteNotifications]; +- }); +- } +- }]; +- } +- }]; + } + + - (void)setCategories:(NSArray *)json { diff --git a/react-native.config.js b/react-native.config.js index 6f2362f43..9e78b41ad 100644 --- a/react-native.config.js +++ b/react-native.config.js @@ -1,10 +1,5 @@ module.exports = { dependencies: { - 'react-native-notifications': { - platforms: { - android: null - } - }, '@react-native-firebase/app': { platforms: { android: null diff --git a/yarn.lock b/yarn.lock index b7545bce9..aadfc41f3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14836,13 +14836,10 @@ react-native-navigation-bar-color@2.0.1: resolved "https://registry.yarnpkg.com/react-native-navigation-bar-color/-/react-native-navigation-bar-color-2.0.1.tgz#ee2be25cc37105f7da355717b0a9a32c9c059ae6" integrity sha512-1kE/oxWt+HYjRxdZdvke9tJ365xaee5n3+euOQA1En8zQuSbOxiE4SYEGM7TeaWnmLJ0l37mRnPHaB2H4mGh0A== -react-native-notifications@2.1.7: - version "2.1.7" - resolved "https://registry.yarnpkg.com/react-native-notifications/-/react-native-notifications-2.1.7.tgz#ef836f6f8c12bdc5103598035590347811426a70" - integrity sha512-m9jfpobP1BpqG2w6pN2kKzKJt2bqrLIRS3QAuH0MU0dpRwib/4ehaAUKOiFj+xVCtuKHALpceb97FHuA0i4dkw== - dependencies: - core-js "^1.0.0" - uuid "^2.0.3" +react-native-notifications@^4.2.4: + version "4.2.4" + resolved "https://registry.yarnpkg.com/react-native-notifications/-/react-native-notifications-4.2.4.tgz#0d686eb1576d3d9cb73dd9db1ee4f212e00f7d89" + integrity sha512-ffToxERa2bRUsXShCO19yXY6c6l4Esq7MqRKAb4mPSn+T428X7Je7WYvWOIOVw/BMGJ3R0lPrZk52vDpoYqanw== react-native-notifier@1.6.1: version "1.6.1" @@ -17683,11 +17680,6 @@ utils-merge@1.0.1: resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM= -uuid@^2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.3.tgz#67e2e863797215530dff318e5bf9dcebfd47b21a" - integrity sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho= - uuid@^3.0.1, uuid@^3.3.2, uuid@^3.4.0: version "3.4.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"