From 22feb7b7fdad9e015b030aa2a7a6f7e150816c4e Mon Sep 17 00:00:00 2001 From: GleidsonDaniel Date: Mon, 24 Jan 2022 12:13:43 -0300 Subject: [PATCH 1/9] chore: migrate redux module login to typescript chore: update redux module login tests --- app/actions/login.js | 59 -------------- app/actions/login.ts | 115 ++++++++++++++++++++++++++++ app/definitions/redux/index.ts | 5 +- app/reducers/activeUsers.ts | 2 +- app/reducers/login.test.ts | 106 +++++++++++++++++++++++++ app/reducers/{login.js => login.ts} | 37 ++++++++- app/views/LoginView.tsx | 36 ++++----- app/views/RegisterView.tsx | 47 +++++------- app/views/SetUsernameView.tsx | 39 +++++----- app/views/StatusView.tsx | 2 + 10 files changed, 312 insertions(+), 136 deletions(-) delete mode 100644 app/actions/login.js create mode 100644 app/actions/login.ts create mode 100644 app/reducers/login.test.ts rename app/reducers/{login.js => login.ts} (60%) diff --git a/app/actions/login.js b/app/actions/login.js deleted file mode 100644 index e0f4c1e280a..00000000000 --- a/app/actions/login.js +++ /dev/null @@ -1,59 +0,0 @@ -import * as types from './actionsTypes'; - -export function loginRequest(credentials, logoutOnError, isFromWebView) { - return { - type: types.LOGIN.REQUEST, - credentials, - logoutOnError, - isFromWebView - }; -} - -export function loginSuccess(user) { - return { - type: types.LOGIN.SUCCESS, - user - }; -} - -export function loginFailure(err) { - return { - type: types.LOGIN.FAILURE, - err - }; -} - -export function logout(forcedByServer = false) { - return { - type: types.LOGOUT, - forcedByServer - }; -} - -export function setUser(user) { - return { - type: types.USER.SET, - user - }; -} - -export function setLoginServices(data) { - return { - type: types.LOGIN.SET_SERVICES, - data - }; -} - -export function setPreference(preference) { - return { - type: types.LOGIN.SET_PREFERENCE, - preference - }; -} - -export function setLocalAuthenticated(isLocalAuthenticated) { - return { - type: types.LOGIN.SET_LOCAL_AUTHENTICATED, - isLocalAuthenticated - }; -} diff --git a/app/actions/login.ts b/app/actions/login.ts new file mode 100644 index 00000000000..1c893fe8dcb --- /dev/null +++ b/app/actions/login.ts @@ -0,0 +1,115 @@ +import { Action } from 'redux'; + +import { IUserLogin } from '../reducers/login'; +import * as types from './actionsTypes'; + +interface ICredentials { + resume: string; + user: string; + password: string; +} + +interface ILoginRequest extends Action { + credentials: any; + logoutOnError?: boolean; + isFromWebView?: boolean; +} + +interface ILoginSuccess extends Action { + user: Partial; +} + +interface ILoginFailure extends Action { + err: Partial; +} + +interface ILogout extends Action { + forcedByServer: boolean; +} + +interface ISetUser extends Action { + user: Partial; +} + +interface ISetServices extends Action { + data: Record; +} + +interface ISetPreference extends Action { + preference: Record; +} + +interface ISetLocalAuthenticated extends Action { + isLocalAuthenticated: boolean; +} + +export type TActionsLogin = ILoginRequest & + ILoginSuccess & + ILoginFailure & + ILogout & + ISetUser & + ISetServices & + ISetPreference & + ISetLocalAuthenticated; + +export function loginRequest( + credentials: Partial, + logoutOnError?: boolean, + isFromWebView?: boolean +): ILoginRequest { + return { + type: types.LOGIN.REQUEST, + credentials, + logoutOnError, + isFromWebView + }; +} + +export function loginSuccess(user: Partial): ILoginSuccess { + return { + type: types.LOGIN.SUCCESS, + user + }; +} + +export function loginFailure(err: Record): ILoginFailure { + return { + type: types.LOGIN.FAILURE, + err + }; +} + +export function logout(forcedByServer = false): ILogout { + return { + type: types.LOGOUT, + forcedByServer + }; +} + +export function setUser(user: Partial): ISetUser { + return { + type: types.USER.SET, + user + }; +} + +export function setLoginServices(data: Record): ISetServices { + return { + type: types.LOGIN.SET_SERVICES, + data + }; +} + +export function setPreference(preference: Record): ISetPreference { + return { + type: types.LOGIN.SET_PREFERENCE, + preference + }; +} + +export function setLocalAuthenticated(isLocalAuthenticated: boolean): ISetLocalAuthenticated { + return { + type: types.LOGIN.SET_LOCAL_AUTHENTICATED, + isLocalAuthenticated + }; +} diff --git a/app/definitions/redux/index.ts b/app/definitions/redux/index.ts index e43b1e87853..fef08246f77 100644 --- a/app/definitions/redux/index.ts +++ b/app/definitions/redux/index.ts @@ -9,18 +9,19 @@ import { TActionSortPreferences } from '../../actions/sortPreferences'; import { TActionUserTyping } from '../../actions/usersTyping'; // REDUCERS import { IActiveUsers } from '../../reducers/activeUsers'; +import { IConnect } from '../../reducers/connect'; import { IEncryption } from '../../reducers/encryption'; import { IInviteLinks } from '../../reducers/inviteLinks'; +import { ILogin } from '../../reducers/login'; import { IRoles } from '../../reducers/roles'; import { ISelectedUsers } from '../../reducers/selectedUsers'; -import { IConnect } from '../../reducers/connect'; import { ISettings } from '../../reducers/settings'; export interface IApplicationState { settings: ISettings; - login: any; meteor: IConnect; + login: ILogin; server: any; selectedUsers: ISelectedUsers; createChannel: any; diff --git a/app/reducers/activeUsers.ts b/app/reducers/activeUsers.ts index 1c32a13fb99..34771773130 100644 --- a/app/reducers/activeUsers.ts +++ b/app/reducers/activeUsers.ts @@ -1,7 +1,7 @@ import { TApplicationActions } from '../definitions'; import { SET_ACTIVE_USERS } from '../actions/actionsTypes'; -type TUserStatus = 'online' | 'offline'; +export type TUserStatus = 'online' | 'offline'; export interface IActiveUser { status: TUserStatus; statusText: string; diff --git a/app/reducers/login.test.ts b/app/reducers/login.test.ts new file mode 100644 index 00000000000..2ca1887c7a8 --- /dev/null +++ b/app/reducers/login.test.ts @@ -0,0 +1,106 @@ +import { + loginFailure, + loginRequest, + loginSuccess, + logout, + setLocalAuthenticated, + setLoginServices, + setUser +} from '../actions/login'; +import { initialState } from './login'; +import { mockedStore } from './mockedStore'; + +describe('test selectedUsers reducer', () => { + it('should return initial state', () => { + const state = mockedStore.getState().login; + expect(state).toEqual(initialState); + }); + + it('should return modified store after loginRequest', () => { + mockedStore.dispatch(loginRequest({ user: 'carlitos@email.com', password: '123456' })); + const state = mockedStore.getState().login; + expect(state).toEqual({ ...initialState, isFetching: true, isAuthenticated: false, failure: false, error: {} }); + }); + + it('should return modified store after loginFailure', () => { + mockedStore.dispatch(loginFailure({ error: 'error' })); + const state = mockedStore.getState().login.error.error; + expect(state).toEqual('error'); + }); + + it('should return modified store after loginSuccess', () => { + const user = { + id: 'ajhsiahsa', + token: 'asdasdasdas', + username: 'carlitos', + name: 'Carlitos', + customFields: { + phonenumber: '' + }, + emails: [ + { + address: 'carlitos@email.com', + verified: true + } + ], + roles: ['user'], + isFromWebView: false, + showMessageInMainThread: false, + enableMessageParserEarlyAdoption: false + }; + mockedStore.dispatch(loginSuccess(user)); + const state = mockedStore.getState().login.user; + expect(state).toEqual(user); + }); + + it('should return modified store after setUser', () => { + const user = { + id: 'ajhsiahsa', + token: 'asdasdasdas', + username: 'carlito', + name: 'Carlitos', + customFields: { + phonenumber: '' + }, + emails: [ + { + address: 'carlitos@email.com', + verified: true + } + ], + roles: ['user'], + isFromWebView: false, + showMessageInMainThread: false, + enableMessageParserEarlyAdoption: false + }; + mockedStore.dispatch(setUser(user)); + const state = mockedStore.getState().login.user.username; + expect(state).toEqual(user.username); + }); + + // TODO PREFERENCE REDUCER WITH EMPTY PREFERENCE - NON USED? + // it('should return modified store after setPreference', () => { + // mockedStore.dispatch(setPreference({ showAvatar: true })); + // const state = mockedStore.getState().login; + // console.log(state); + // expect(state).toEqual('error'); + // }); + + it('should return modified store after setLocalAuthenticated', () => { + mockedStore.dispatch(setLocalAuthenticated(true)); + const state = mockedStore.getState().login.isLocalAuthenticated; + expect(state).toEqual(true); + }); + + it('should return modified store after setLoginServices', () => { + mockedStore.dispatch(setLoginServices({ facebook: { clientId: 'xxx' } })); + const state = mockedStore.getState().login.services.facebook.clientId; + expect(state).toEqual('xxx'); + }); + + it('should return modified store after logout', () => { + mockedStore.dispatch(logout()); + const state = mockedStore.getState().login; + expect(state).toEqual(initialState); + }); +}); diff --git a/app/reducers/login.js b/app/reducers/login.ts similarity index 60% rename from app/reducers/login.js rename to app/reducers/login.ts index 664718c4cf9..25e53e2bcf1 100644 --- a/app/reducers/login.js +++ b/app/reducers/login.ts @@ -1,15 +1,46 @@ import * as types from '../actions/actionsTypes'; +import { TActionsLogin } from '../actions/login'; +import { TUserStatus } from './activeUsers'; -const initialState = { +export interface IUserLogin { + id: string; + token: string; + username: string; + name: string; + language: null; + status: TUserStatus; + statusText: string; + roles: string[]; + avatarETag: string; + isFromWebView: boolean; + showMessageInMainThread: boolean; + enableMessageParserEarlyAdoption: boolean; + emails: Record[]; + customFields: Record; + settings: Record; +} + +export interface ILogin { + user: Partial | Record; + isLocalAuthenticated: boolean; + isAuthenticated: boolean; + isFetching: boolean; + error: Record; + services: Record; + failure: boolean; +} + +export const initialState: ILogin = { isLocalAuthenticated: true, isAuthenticated: false, isFetching: false, user: {}, error: {}, - services: {} + services: {}, + failure: false }; -export default function login(state = initialState, action) { +export default function login(state = initialState, action: TActionsLogin): ILogin { switch (action.type) { case types.APP.INIT: return initialState; diff --git a/app/views/LoginView.tsx b/app/views/LoginView.tsx index e43505f3f1e..4395c5b1ada 100644 --- a/app/views/LoginView.tsx +++ b/app/views/LoginView.tsx @@ -1,21 +1,20 @@ +import { dequal } from 'dequal'; import React from 'react'; import { Alert, Keyboard, StyleSheet, Text, View } from 'react-native'; import { connect } from 'react-redux'; -import { dequal } from 'dequal'; -import { StackNavigationProp } from '@react-navigation/stack'; -import { RouteProp } from '@react-navigation/core'; -import Button from '../containers/Button'; -import I18n from '../i18n'; -import * as HeaderButton from '../containers/HeaderButton'; +import { loginRequest } from '../actions/login'; import { themes } from '../constants/colors'; -import { withTheme } from '../theme'; +import Button from '../containers/Button'; import FormContainer, { FormContainerInner } from '../containers/FormContainer'; -import TextInput from '../containers/TextInput'; -import { loginRequest as loginRequestAction } from '../actions/login'; +import * as HeaderButton from '../containers/HeaderButton'; import LoginServices from '../containers/LoginServices'; -import sharedStyles from './Styles'; +import TextInput from '../containers/TextInput'; +import { IApplicationState, IBaseScreen } from '../definitions'; +import I18n from '../i18n'; import { OutsideParamList } from '../stacks/types'; +import { withTheme } from '../theme'; +import sharedStyles from './Styles'; const styles = StyleSheet.create({ registerDisabled: { @@ -48,9 +47,7 @@ const styles = StyleSheet.create({ } }); -interface ILoginViewProps { - navigation: StackNavigationProp; - route: RouteProp; +interface ILoginViewProps extends IBaseScreen { Site_Name: string; Accounts_RegistrationForm: string; Accounts_RegistrationForm_LinkReplacementText: string; @@ -63,7 +60,6 @@ interface ILoginViewProps { error: string; }; failure: boolean; - theme: string; loginRequest: Function; inviteLinkToken: string; } @@ -132,9 +128,9 @@ class LoginView extends React.Component { } const { user, password } = this.state; - const { loginRequest } = this.props; + const { dispatch } = this.props; Keyboard.dismiss(); - loginRequest({ user, password }); + dispatch(loginRequest({ user, password })); }; renderUserForm = () => { @@ -243,7 +239,7 @@ class LoginView extends React.Component { } } -const mapStateToProps = (state: any) => ({ +const mapStateToProps = (state: IApplicationState) => ({ server: state.server.server, Site_Name: state.settings.Site_Name, Accounts_ShowFormLogin: state.settings.Accounts_ShowFormLogin, @@ -258,8 +254,4 @@ const mapStateToProps = (state: any) => ({ inviteLinkToken: state.inviteLinks.token }); -const mapDispatchToProps = (dispatch: any) => ({ - loginRequest: (params: any) => dispatch(loginRequestAction(params)) -}); - -export default connect(mapStateToProps, mapDispatchToProps)(withTheme(LoginView)); +export default connect(mapStateToProps)(withTheme(LoginView)); diff --git a/app/views/RegisterView.tsx b/app/views/RegisterView.tsx index ae5f46bd9e5..ec86a1852b9 100644 --- a/app/views/RegisterView.tsx +++ b/app/views/RegisterView.tsx @@ -1,26 +1,25 @@ import React from 'react'; import { Keyboard, StyleSheet, Text, View } from 'react-native'; -import { StackNavigationProp } from '@react-navigation/stack'; -import { RouteProp } from '@react-navigation/core'; -import { connect } from 'react-redux'; import RNPickerSelect from 'react-native-picker-select'; +import { connect } from 'react-redux'; -import { OutsideParamList } from '../stacks/types'; -import log, { events, logEvent } from '../utils/log'; -import Button from '../containers/Button'; -import I18n from '../i18n'; -import * as HeaderButton from '../containers/HeaderButton'; +import { loginRequest } from '../actions/login'; import { themes } from '../constants/colors'; -import { withTheme } from '../theme'; +import Button from '../containers/Button'; import FormContainer, { FormContainerInner } from '../containers/FormContainer'; +import * as HeaderButton from '../containers/HeaderButton'; +import LoginServices from '../containers/LoginServices'; import TextInput from '../containers/TextInput'; -import isValidEmail from '../utils/isValidEmail'; -import { showErrorAlert } from '../utils/info'; +import { IApplicationState, IBaseScreen } from '../definitions'; +import I18n from '../i18n'; import RocketChat from '../lib/rocketchat'; -import { loginRequest as loginRequestAction } from '../actions/login'; -import openLink from '../utils/openLink'; -import LoginServices from '../containers/LoginServices'; import { getShowLoginButton } from '../selectors/login'; +import { OutsideParamList } from '../stacks/types'; +import { withTheme } from '../theme'; +import { showErrorAlert } from '../utils/info'; +import isValidEmail from '../utils/isValidEmail'; +import log, { events, logEvent } from '../utils/log'; +import openLink from '../utils/openLink'; import sharedStyles from './Styles'; const styles = StyleSheet.create({ @@ -51,9 +50,7 @@ const styles = StyleSheet.create({ } }); -interface IProps { - navigation: StackNavigationProp; - route: RouteProp; +interface IProps extends IBaseScreen { server: string; Site_Name: string; Gitlab_URL: string; @@ -63,8 +60,6 @@ interface IProps { Accounts_EmailVerification: boolean; Accounts_ManuallyApproveNewUsers: boolean; showLoginButton: boolean; - loginRequest: Function; - theme: string; } class RegisterView extends React.Component { @@ -130,7 +125,7 @@ class RegisterView extends React.Component { Keyboard.dismiss(); const { name, email, password, username, customFields } = this.state; - const { loginRequest, Accounts_EmailVerification, navigation, Accounts_ManuallyApproveNewUsers } = this.props; + const { dispatch, Accounts_EmailVerification, navigation, Accounts_ManuallyApproveNewUsers } = this.props; try { await RocketChat.register({ @@ -148,11 +143,11 @@ class RegisterView extends React.Component { await navigation.goBack(); showErrorAlert(I18n.t('Wait_activation_warning'), I18n.t('Registration_Succeeded')); } else { - await loginRequest({ user: email, password }); + dispatch(loginRequest({ user: email, password })); } } catch (e: any) { if (e.data?.errorType === 'username-invalid') { - return loginRequest({ user: email, password }); + return dispatch(loginRequest({ user: email, password })); } if (e.data?.error) { logEvent(events.REGISTER_DEFAULT_SIGN_UP_F); @@ -349,7 +344,7 @@ class RegisterView extends React.Component { } } -const mapStateToProps = (state: any) => ({ +const mapStateToProps = (state: IApplicationState) => ({ server: state.server.server, Site_Name: state.settings.Site_Name, Gitlab_URL: state.settings.API_Gitlab_URL, @@ -361,8 +356,4 @@ const mapStateToProps = (state: any) => ({ showLoginButton: getShowLoginButton(state) }); -const mapDispatchToProps = (dispatch: any) => ({ - loginRequest: (params: any) => dispatch(loginRequestAction(params)) -}); - -export default connect(mapStateToProps, mapDispatchToProps)(withTheme(RegisterView)); +export default connect(mapStateToProps)(withTheme(RegisterView)); diff --git a/app/views/SetUsernameView.tsx b/app/views/SetUsernameView.tsx index 221561697b9..4c9aa91f077 100644 --- a/app/views/SetUsernameView.tsx +++ b/app/views/SetUsernameView.tsx @@ -1,25 +1,26 @@ -import React from 'react'; +import { RouteProp } from '@react-navigation/native'; import { StackNavigationOptions, StackNavigationProp } from '@react-navigation/stack'; -import { Dispatch } from 'redux'; +import React from 'react'; import { ScrollView, StyleSheet, Text } from 'react-native'; -import { connect } from 'react-redux'; import Orientation from 'react-native-orientation-locker'; -import { RouteProp } from '@react-navigation/native'; +import { connect } from 'react-redux'; +import { Dispatch } from 'redux'; -import { loginRequest as loginRequestAction } from '../actions/login'; -import TextInput from '../containers/TextInput'; +import { loginRequest } from '../actions/login'; +import { themes } from '../constants/colors'; import Button from '../containers/Button'; -import KeyboardView from '../presentation/KeyboardView'; -import scrollPersistTaps from '../utils/scrollPersistTaps'; +import SafeAreaView from '../containers/SafeAreaView'; +import StatusBar from '../containers/StatusBar'; +import TextInput from '../containers/TextInput'; +import { IApplicationState } from '../definitions'; import I18n from '../i18n'; import RocketChat from '../lib/rocketchat'; -import StatusBar from '../containers/StatusBar'; +import KeyboardView from '../presentation/KeyboardView'; +import { getUserSelector } from '../selectors/login'; import { withTheme } from '../theme'; -import { themes } from '../constants/colors'; import { isTablet } from '../utils/deviceInfo'; -import { getUserSelector } from '../selectors/login'; import { showErrorAlert } from '../utils/info'; -import SafeAreaView from '../containers/SafeAreaView'; +import scrollPersistTaps from '../utils/scrollPersistTaps'; import sharedStyles from './Styles'; const styles = StyleSheet.create({ @@ -39,9 +40,9 @@ interface ISetUsernameViewProps { route: RouteProp<{ SetUsernameView: { title: string } }, 'SetUsernameView'>; server: string; userId: string; - loginRequest: ({ resume }: { resume: string }) => void; token: string; theme: string; + dispatch: Dispatch; } class SetUsernameView extends React.Component { @@ -86,7 +87,7 @@ class SetUsernameView extends React.Component { const { username } = this.state; - const { loginRequest, token } = this.props; + const { dispatch, token } = this.props; if (!username.trim()) { return; @@ -95,7 +96,7 @@ class SetUsernameView extends React.Component ({ +const mapStateToProps = (state: IApplicationState) => ({ server: state.server.server, token: getUserSelector(state).token }); -const mapDispatchToProps = (dispatch: Dispatch) => ({ - loginRequest: (params: { resume: string }) => dispatch(loginRequestAction(params)) -}); - -export default connect(mapStateToProps, mapDispatchToProps)(withTheme(SetUsernameView)); +export default connect(mapStateToProps)(withTheme(SetUsernameView)); diff --git a/app/views/StatusView.tsx b/app/views/StatusView.tsx index 23fc619dfdf..8e678ef066b 100644 --- a/app/views/StatusView.tsx +++ b/app/views/StatusView.tsx @@ -211,7 +211,9 @@ const mapStateToProps = (state: any) => ({ Accounts_AllowInvisibleStatusOption: state.settings.Accounts_AllowInvisibleStatusOption ?? true }); +// TODO VERIFY SCREEN FUNCTION AND LOGICS const mapDispatchToProps = (dispatch: Dispatch) => ({ + // @ts-ignore setUser: (user: IUser) => dispatch(setUserAction(user)) }); From 17ebeb7ea0813e9e19a36ca7a79f008883d97d81 Mon Sep 17 00:00:00 2001 From: GleidsonDaniel Date: Tue, 1 Feb 2022 08:39:28 -0300 Subject: [PATCH 2/9] update workers --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9b681e2b6ee..ac5e942a303 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -359,7 +359,7 @@ jobs: - run: name: Test command: | - yarn test + yarn test -w 8 - run: name: Codecov From a529e8b3d6f1867db790a1018543322d131c9e34 Mon Sep 17 00:00:00 2001 From: GleidsonDaniel Date: Tue, 1 Feb 2022 08:50:23 -0300 Subject: [PATCH 3/9] wip --- __tests__/Storyshots.test.js | 11 +++-------- app/views/LoginView.tsx | 14 +++++++------- app/views/RegisterView.tsx | 14 +++++++------- storybook/stories/__snapshots__/Message.storyshot | 2 +- 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/__tests__/Storyshots.test.js b/__tests__/Storyshots.test.js index e0d741e1c1a..1315f9bb5b4 100644 --- a/__tests__/Storyshots.test.js +++ b/__tests__/Storyshots.test.js @@ -22,18 +22,13 @@ global.Date.now = jest.fn(() => new Date('2019-10-10').getTime()); const converter = new Stories2SnapsConverter(); -// Runner initStoryshots({ - asyncJest: true, - test: ({ story, context, done }) => { + test: ({ story, context }) => { const snapshotFilename = converter.getSnapshotFileName(context); const storyElement = story.render(); const { update, toJSON } = render(storyElement); update(storyElement); - setTimeout(() => { - const json = toJSON(); - expect(JSON.stringify(json)).toMatchSpecificSnapshot(snapshotFilename); - done(); - }, 10); + const json = toJSON(); + expect(JSON.stringify(json)).toMatchSpecificSnapshot(snapshotFilename); } }); diff --git a/app/views/LoginView.tsx b/app/views/LoginView.tsx index 4395c5b1ada..a8bcba275a0 100644 --- a/app/views/LoginView.tsx +++ b/app/views/LoginView.tsx @@ -241,16 +241,16 @@ class LoginView extends React.Component { const mapStateToProps = (state: IApplicationState) => ({ server: state.server.server, - Site_Name: state.settings.Site_Name, - Accounts_ShowFormLogin: state.settings.Accounts_ShowFormLogin, - Accounts_RegistrationForm: state.settings.Accounts_RegistrationForm, - Accounts_RegistrationForm_LinkReplacementText: state.settings.Accounts_RegistrationForm_LinkReplacementText, + Site_Name: state.settings.Site_Name as string, + Accounts_ShowFormLogin: state.settings.Accounts_ShowFormLogin as boolean, + Accounts_RegistrationForm: state.settings.Accounts_RegistrationForm as string, + Accounts_RegistrationForm_LinkReplacementText: state.settings.Accounts_RegistrationForm_LinkReplacementText as string, isFetching: state.login.isFetching, failure: state.login.failure, error: state.login.error && state.login.error.data, - Accounts_EmailOrUsernamePlaceholder: state.settings.Accounts_EmailOrUsernamePlaceholder, - Accounts_PasswordPlaceholder: state.settings.Accounts_PasswordPlaceholder, - Accounts_PasswordReset: state.settings.Accounts_PasswordReset, + Accounts_EmailOrUsernamePlaceholder: state.settings.Accounts_EmailOrUsernamePlaceholder as string, + Accounts_PasswordPlaceholder: state.settings.Accounts_PasswordPlaceholder as string, + Accounts_PasswordReset: state.settings.Accounts_PasswordReset as boolean, inviteLinkToken: state.inviteLinks.token }); diff --git a/app/views/RegisterView.tsx b/app/views/RegisterView.tsx index ec86a1852b9..a4f1d025d92 100644 --- a/app/views/RegisterView.tsx +++ b/app/views/RegisterView.tsx @@ -346,13 +346,13 @@ class RegisterView extends React.Component { const mapStateToProps = (state: IApplicationState) => ({ server: state.server.server, - Site_Name: state.settings.Site_Name, - Gitlab_URL: state.settings.API_Gitlab_URL, - CAS_enabled: state.settings.CAS_enabled, - CAS_login_url: state.settings.CAS_login_url, - Accounts_CustomFields: state.settings.Accounts_CustomFields, - Accounts_EmailVerification: state.settings.Accounts_EmailVerification, - Accounts_ManuallyApproveNewUsers: state.settings.Accounts_ManuallyApproveNewUsers, + Site_Name: state.settings.Site_Name as string, + Gitlab_URL: state.settings.API_Gitlab_URL as string, + CAS_enabled: state.settings.CAS_enabled as boolean, + CAS_login_url: state.settings.CAS_login_url as string, + Accounts_CustomFields: state.settings.Accounts_CustomFields as string, + Accounts_EmailVerification: state.settings.Accounts_EmailVerification as boolean, + Accounts_ManuallyApproveNewUsers: state.settings.Accounts_ManuallyApproveNewUsers as boolean, showLoginButton: getShowLoginButton(state) }); diff --git a/storybook/stories/__snapshots__/Message.storyshot b/storybook/stories/__snapshots__/Message.storyshot index b7fdc5e8db3..be6309b0216 100644 --- a/storybook/stories/__snapshots__/Message.storyshot +++ b/storybook/stories/__snapshots__/Message.storyshot @@ -68,7 +68,7 @@ exports[`Storyshots Message URL 1`] = `"{\\"type\\":\\"RCTScrollView\\",\\"props exports[`Storyshots Message With alias 1`] = `"{\\"type\\":\\"RCTScrollView\\",\\"props\\":{\\"style\\":{\\"backgroundColor\\":\\"#ffffff\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"backgroundColor\\":null,\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"paddingVertical\\":4,\\"width\\":\\"100%\\",\\"paddingHorizontal\\":14,\\"flexDirection\\":\\"column\\"},null]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flexDirection\\":\\"row\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"width\\":36,\\"height\\":36,\\"borderRadius\\":4},{\\"marginTop\\":4}],\\"testID\\":\\"avatar\\"},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"overflow\\":\\"hidden\\"},{\\"width\\":36,\\"height\\":36,\\"borderRadius\\":4}]},\\"children\\":[{\\"type\\":\\"FastImageView\\",\\"props\\":{\\"style\\":{\\"position\\":\\"absolute\\",\\"left\\":0,\\"right\\":0,\\"top\\":0,\\"bottom\\":0},\\"source\\":{\\"uri\\":\\"https://open.rocket.chat/avatar/diego.mello?format=png&size=36\\",\\"priority\\":\\"high\\"},\\"resizeMode\\":\\"cover\\"},\\"children\\":null}]}]}]},{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"marginLeft\\":46},{\\"marginLeft\\":10}]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flex\\":1,\\"flexDirection\\":\\"row\\",\\"justifyContent\\":\\"space-between\\",\\"alignItems\\":\\"center\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"flexShrink\\":1,\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"center\\",\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":16,\\"lineHeight\\":22,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"500\\"},{\\"color\\":\\"#0d0e12\\"}],\\"numberOfLines\\":1},\\"children\\":[\\"Diego Mello\\",{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":14,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},{\\"color\\":\\"#9ca2a8\\"}]},\\"children\\":[\\" @\\",\\"diego.mello\\"]}]}]},{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":12,\\"marginLeft\\":8,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},{\\"color\\":\\"#9ca2a8\\"}]},\\"children\\":[\\"10:00 AM\\"]}]},{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},null,{\\"color\\":\\"#2f343d\\"}],\\"numberOfLines\\":0},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"accessibilityLabel\\":\\"Message\\",\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},[{},{\\"marginTop\\":0,\\"marginBottom\\":0,\\"flexWrap\\":\\"wrap\\",\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"flex-start\\",\\"justifyContent\\":\\"flex-start\\"}]],\\"numberOfLines\\":0},\\"children\\":[\\"Message\\"]}]}]}]}]}]}]}]},{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"backgroundColor\\":null,\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"paddingVertical\\":4,\\"width\\":\\"100%\\",\\"paddingHorizontal\\":14,\\"flexDirection\\":\\"column\\"},null]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flexDirection\\":\\"row\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"width\\":36,\\"height\\":36,\\"borderRadius\\":4},{\\"marginTop\\":4}],\\"testID\\":\\"avatar\\"},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"overflow\\":\\"hidden\\"},{\\"width\\":36,\\"height\\":36,\\"borderRadius\\":4}]},\\"children\\":[{\\"type\\":\\"FastImageView\\",\\"props\\":{\\"style\\":{\\"position\\":\\"absolute\\",\\"left\\":0,\\"right\\":0,\\"top\\":0,\\"bottom\\":0},\\"source\\":{\\"uri\\":\\"https://open.rocket.chat/avatar/Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.?format=png&size=36\\",\\"priority\\":\\"high\\"},\\"resizeMode\\":\\"cover\\"},\\"children\\":null}]}]}]},{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"marginLeft\\":46},{\\"marginLeft\\":10}]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flex\\":1,\\"flexDirection\\":\\"row\\",\\"justifyContent\\":\\"space-between\\",\\"alignItems\\":\\"center\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"flexShrink\\":1,\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"center\\",\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":16,\\"lineHeight\\":22,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"500\\"},{\\"color\\":\\"#0d0e12\\"}],\\"numberOfLines\\":1},\\"children\\":[\\"Diego Mello\\",{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":14,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},{\\"color\\":\\"#9ca2a8\\"}]},\\"children\\":[\\" @\\",\\"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\\"]}]}]},{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":12,\\"marginLeft\\":8,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},{\\"color\\":\\"#9ca2a8\\"}]},\\"children\\":[\\"10:00 AM\\"]}]},{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},null,{\\"color\\":\\"#2f343d\\"}],\\"numberOfLines\\":0},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"accessibilityLabel\\":\\"Message\\",\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},[{},{\\"marginTop\\":0,\\"marginBottom\\":0,\\"flexWrap\\":\\"wrap\\",\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"flex-start\\",\\"justifyContent\\":\\"flex-start\\"}]],\\"numberOfLines\\":0},\\"children\\":[\\"Message\\"]}]}]}]}]}]}]}]}]}]}"`; -exports[`Storyshots Message With audio 1`] = `"{\\"type\\":\\"RCTScrollView\\",\\"props\\":{\\"style\\":{\\"backgroundColor\\":\\"#ffffff\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"backgroundColor\\":null,\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"paddingVertical\\":4,\\"width\\":\\"100%\\",\\"paddingHorizontal\\":14,\\"flexDirection\\":\\"column\\"},null]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flexDirection\\":\\"row\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"width\\":36,\\"height\\":36,\\"borderRadius\\":4},{\\"marginTop\\":4}],\\"testID\\":\\"avatar\\"},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"overflow\\":\\"hidden\\"},{\\"width\\":36,\\"height\\":36,\\"borderRadius\\":4}]},\\"children\\":[{\\"type\\":\\"FastImageView\\",\\"props\\":{\\"style\\":{\\"position\\":\\"absolute\\",\\"left\\":0,\\"right\\":0,\\"top\\":0,\\"bottom\\":0},\\"source\\":{\\"uri\\":\\"https://open.rocket.chat/avatar/diego.mello?format=png&size=36\\",\\"priority\\":\\"high\\"},\\"resizeMode\\":\\"cover\\"},\\"children\\":null}]}]}]},{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"marginLeft\\":46},{\\"marginLeft\\":10}]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flex\\":1,\\"flexDirection\\":\\"row\\",\\"justifyContent\\":\\"space-between\\",\\"alignItems\\":\\"center\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"flexShrink\\":1,\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"center\\",\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":16,\\"lineHeight\\":22,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"500\\"},{\\"color\\":\\"#0d0e12\\"}],\\"numberOfLines\\":1},\\"children\\":[\\"diego.mello\\"]}]},{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":12,\\"marginLeft\\":8,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},{\\"color\\":\\"#9ca2a8\\"}]},\\"children\\":[\\"10:00 AM\\"]}]},{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":null},{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"center\\",\\"height\\":56,\\"borderWidth\\":1,\\"borderRadius\\":4,\\"marginBottom\\":6},{\\"backgroundColor\\":\\"#f3f4f5\\",\\"borderColor\\":\\"#e1e5e8\\"}]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"hitSlop\\":{\\"top\\":12,\\"right\\":12,\\"bottom\\":12,\\"left\\":12},\\"focusable\\":true,\\"style\\":{\\"marginHorizontal\\":10,\\"alignItems\\":\\"center\\",\\"backgroundColor\\":\\"transparent\\",\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"allowFontScaling\\":false,\\"style\\":[{\\"fontSize\\":36,\\"color\\":\\"#1d74f5\\"},null,{\\"fontFamily\\":\\"custom\\",\\"fontWeight\\":\\"normal\\",\\"fontStyle\\":\\"normal\\"},{}]},\\"children\\":[\\"\\"]}]},{\\"type\\":\\"RNCSlider\\",\\"props\\":{\\"style\\":[{\\"height\\":40},{\\"flex\\":1}],\\"value\\":0,\\"maximumValue\\":0,\\"minimumValue\\":0,\\"animateTransitions\\":true,\\"animationConfig\\":{\\"duration\\":250,\\"delay\\":0},\\"thumbTintColor\\":false,\\"minimumTrackTintColor\\":\\"#1d74f5\\",\\"maximumTrackTintColor\\":\\"#9ca2a8\\",\\"thumbImage\\":{\\"uri\\":\\"audio_thumb\\",\\"scale\\":2},\\"disabled\\":false,\\"step\\":0,\\"inverted\\":false,\\"onRNCSliderSlidingStart\\":null,\\"onRNCSliderSlidingComplete\\":null,\\"enabled\\":true},\\"children\\":null},{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"marginHorizontal\\":12,\\"fontSize\\":14,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},{\\"color\\":\\"#9ca2a8\\"}]},\\"children\\":[\\"00:00\\"]}]},{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},null,{\\"color\\":\\"#2f343d\\"}]},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"accessibilityLabel\\":\\"This is a description \\",\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},[{},{\\"marginTop\\":0,\\"marginBottom\\":0,\\"flexWrap\\":\\"wrap\\",\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"flex-start\\",\\"justifyContent\\":\\"flex-start\\"}]]},\\"children\\":[\\"This is a description \\"]},{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"overflow\\":\\"hidden\\"},[{\\"width\\":20,\\"height\\":20},{}]]},\\"children\\":[{\\"type\\":\\"FastImageView\\",\\"props\\":{\\"style\\":{\\"position\\":\\"absolute\\",\\"left\\":0,\\"right\\":0,\\"top\\":0,\\"bottom\\":0},\\"source\\":{\\"uri\\":\\"https://open.rocket.chat/emoji-custom/nyan_rocket.png\\",\\"priority\\":\\"high\\"},\\"resizeMode\\":\\"contain\\"},\\"children\\":null}]}]}]}]}]}]}]},{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"backgroundColor\\":null,\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"paddingVertical\\":4,\\"width\\":\\"100%\\",\\"paddingHorizontal\\":14,\\"flexDirection\\":\\"column\\"},null]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flexDirection\\":\\"row\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"marginLeft\\":46},false]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},null,{\\"color\\":\\"#2f343d\\"}],\\"numberOfLines\\":0},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"accessibilityLabel\\":\\"First message\\",\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},[{},{\\"marginTop\\":0,\\"marginBottom\\":0,\\"flexWrap\\":\\"wrap\\",\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"flex-start\\",\\"justifyContent\\":\\"flex-start\\"}]],\\"numberOfLines\\":0},\\"children\\":[\\"First message\\"]}]}]}]}]}]}]}]},{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"backgroundColor\\":null,\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"paddingVertical\\":4,\\"width\\":\\"100%\\",\\"paddingHorizontal\\":14,\\"flexDirection\\":\\"column\\"},null]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flexDirection\\":\\"row\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"marginLeft\\":46},false]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":null},{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"center\\",\\"height\\":56,\\"borderWidth\\":1,\\"borderRadius\\":4,\\"marginBottom\\":6},{\\"backgroundColor\\":\\"#f3f4f5\\",\\"borderColor\\":\\"#e1e5e8\\"}]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"hitSlop\\":{\\"top\\":12,\\"right\\":12,\\"bottom\\":12,\\"left\\":12},\\"focusable\\":true,\\"style\\":{\\"marginHorizontal\\":10,\\"alignItems\\":\\"center\\",\\"backgroundColor\\":\\"transparent\\",\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"allowFontScaling\\":false,\\"style\\":[{\\"fontSize\\":36,\\"color\\":\\"#1d74f5\\"},null,{\\"fontFamily\\":\\"custom\\",\\"fontWeight\\":\\"normal\\",\\"fontStyle\\":\\"normal\\"},{}]},\\"children\\":[\\"\\"]}]},{\\"type\\":\\"RNCSlider\\",\\"props\\":{\\"style\\":[{\\"height\\":40},{\\"flex\\":1}],\\"value\\":0,\\"maximumValue\\":0,\\"minimumValue\\":0,\\"animateTransitions\\":true,\\"animationConfig\\":{\\"duration\\":250,\\"delay\\":0},\\"thumbTintColor\\":false,\\"minimumTrackTintColor\\":\\"#1d74f5\\",\\"maximumTrackTintColor\\":\\"#9ca2a8\\",\\"thumbImage\\":{\\"uri\\":\\"audio_thumb\\",\\"scale\\":2},\\"disabled\\":false,\\"step\\":0,\\"inverted\\":false,\\"onRNCSliderSlidingStart\\":null,\\"onRNCSliderSlidingComplete\\":null,\\"enabled\\":true},\\"children\\":null},{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"marginHorizontal\\":12,\\"fontSize\\":14,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},{\\"color\\":\\"#9ca2a8\\"}]},\\"children\\":[\\"00:00\\"]}]},{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},null,{\\"color\\":\\"#2f343d\\"}]},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"accessibilityLabel\\":\\"This is a description\\",\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},[{},{\\"marginTop\\":0,\\"marginBottom\\":0,\\"flexWrap\\":\\"wrap\\",\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"flex-start\\",\\"justifyContent\\":\\"flex-start\\"}]]},\\"children\\":[\\"This is a description\\"]}]}]}]}]}]}]},{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"backgroundColor\\":null,\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"paddingVertical\\":4,\\"width\\":\\"100%\\",\\"paddingHorizontal\\":14,\\"flexDirection\\":\\"column\\"},null]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flexDirection\\":\\"row\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"marginLeft\\":46},false]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":null},{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"center\\",\\"height\\":56,\\"borderWidth\\":1,\\"borderRadius\\":4,\\"marginBottom\\":6},{\\"backgroundColor\\":\\"#f3f4f5\\",\\"borderColor\\":\\"#e1e5e8\\"}]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"hitSlop\\":{\\"top\\":12,\\"right\\":12,\\"bottom\\":12,\\"left\\":12},\\"focusable\\":true,\\"style\\":{\\"marginHorizontal\\":10,\\"alignItems\\":\\"center\\",\\"backgroundColor\\":\\"transparent\\",\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"allowFontScaling\\":false,\\"style\\":[{\\"fontSize\\":36,\\"color\\":\\"#1d74f5\\"},null,{\\"fontFamily\\":\\"custom\\",\\"fontWeight\\":\\"normal\\",\\"fontStyle\\":\\"normal\\"},{}]},\\"children\\":[\\"\\"]}]},{\\"type\\":\\"RNCSlider\\",\\"props\\":{\\"style\\":[{\\"height\\":40},{\\"flex\\":1}],\\"value\\":0,\\"maximumValue\\":0,\\"minimumValue\\":0,\\"animateTransitions\\":true,\\"animationConfig\\":{\\"duration\\":250,\\"delay\\":0},\\"thumbTintColor\\":false,\\"minimumTrackTintColor\\":\\"#1d74f5\\",\\"maximumTrackTintColor\\":\\"#9ca2a8\\",\\"thumbImage\\":{\\"uri\\":\\"audio_thumb\\",\\"scale\\":2},\\"disabled\\":false,\\"step\\":0,\\"inverted\\":false,\\"onRNCSliderSlidingStart\\":null,\\"onRNCSliderSlidingComplete\\":null,\\"enabled\\":true},\\"children\\":null},{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"marginHorizontal\\":12,\\"fontSize\\":14,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},{\\"color\\":\\"#9ca2a8\\"}]},\\"children\\":[\\"00:00\\"]}]}]}]}]}]}]},{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"backgroundColor\\":null,\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"paddingVertical\\":4,\\"width\\":\\"100%\\",\\"paddingHorizontal\\":14,\\"flexDirection\\":\\"column\\"},null]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flexDirection\\":\\"row\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"marginLeft\\":46},false]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":null},{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"center\\",\\"height\\":56,\\"borderWidth\\":1,\\"borderRadius\\":4,\\"marginBottom\\":6},{\\"backgroundColor\\":\\"#f3f4f5\\",\\"borderColor\\":\\"#e1e5e8\\"}]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"hitSlop\\":{\\"top\\":12,\\"right\\":12,\\"bottom\\":12,\\"left\\":12},\\"focusable\\":true,\\"style\\":{\\"marginHorizontal\\":10,\\"alignItems\\":\\"center\\",\\"backgroundColor\\":\\"transparent\\",\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"allowFontScaling\\":false,\\"style\\":[{\\"fontSize\\":36,\\"color\\":\\"#1d74f5\\"},null,{\\"fontFamily\\":\\"custom\\",\\"fontWeight\\":\\"normal\\",\\"fontStyle\\":\\"normal\\"},{}]},\\"children\\":[\\"\\"]}]},{\\"type\\":\\"RNCSlider\\",\\"props\\":{\\"style\\":[{\\"height\\":40},{\\"flex\\":1}],\\"value\\":0,\\"maximumValue\\":0,\\"minimumValue\\":0,\\"animateTransitions\\":true,\\"animationConfig\\":{\\"duration\\":250,\\"delay\\":0},\\"thumbTintColor\\":false,\\"minimumTrackTintColor\\":\\"#1d74f5\\",\\"maximumTrackTintColor\\":\\"#9ca2a8\\",\\"thumbImage\\":{\\"uri\\":\\"audio_thumb\\",\\"scale\\":2},\\"disabled\\":false,\\"step\\":0,\\"inverted\\":false,\\"onRNCSliderSlidingStart\\":null,\\"onRNCSliderSlidingComplete\\":null,\\"enabled\\":true},\\"children\\":null},{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"marginHorizontal\\":12,\\"fontSize\\":14,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},{\\"color\\":\\"#9ca2a8\\"}]},\\"children\\":[\\"00:00\\"]}]}]}]}]}]}]}]}]}"`; +exports[`Storyshots Message With audio 1`] = `"{\\"type\\":\\"RCTScrollView\\",\\"props\\":{\\"style\\":{\\"backgroundColor\\":\\"#ffffff\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"backgroundColor\\":null,\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"paddingVertical\\":4,\\"width\\":\\"100%\\",\\"paddingHorizontal\\":14,\\"flexDirection\\":\\"column\\"},null]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flexDirection\\":\\"row\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"width\\":36,\\"height\\":36,\\"borderRadius\\":4},{\\"marginTop\\":4}],\\"testID\\":\\"avatar\\"},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"overflow\\":\\"hidden\\"},{\\"width\\":36,\\"height\\":36,\\"borderRadius\\":4}]},\\"children\\":[{\\"type\\":\\"FastImageView\\",\\"props\\":{\\"style\\":{\\"position\\":\\"absolute\\",\\"left\\":0,\\"right\\":0,\\"top\\":0,\\"bottom\\":0},\\"source\\":{\\"uri\\":\\"https://open.rocket.chat/avatar/diego.mello?format=png&size=36\\",\\"priority\\":\\"high\\"},\\"resizeMode\\":\\"cover\\"},\\"children\\":null}]}]}]},{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"marginLeft\\":46},{\\"marginLeft\\":10}]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flex\\":1,\\"flexDirection\\":\\"row\\",\\"justifyContent\\":\\"space-between\\",\\"alignItems\\":\\"center\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"flexShrink\\":1,\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"center\\",\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":16,\\"lineHeight\\":22,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"500\\"},{\\"color\\":\\"#0d0e12\\"}],\\"numberOfLines\\":1},\\"children\\":[\\"diego.mello\\"]}]},{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":12,\\"marginLeft\\":8,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},{\\"color\\":\\"#9ca2a8\\"}]},\\"children\\":[\\"10:00 AM\\"]}]},{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":null},{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"center\\",\\"height\\":56,\\"borderWidth\\":1,\\"borderRadius\\":4,\\"marginBottom\\":6},{\\"backgroundColor\\":\\"#f3f4f5\\",\\"borderColor\\":\\"#e1e5e8\\"}]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"hitSlop\\":{\\"top\\":12,\\"right\\":12,\\"bottom\\":12,\\"left\\":12},\\"focusable\\":true,\\"style\\":{\\"marginHorizontal\\":10,\\"alignItems\\":\\"center\\",\\"backgroundColor\\":\\"transparent\\",\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"ActivityIndicator\\",\\"props\\":{\\"animating\\":true,\\"color\\":\\"#9ca2a8\\",\\"hidesWhenStopped\\":true,\\"size\\":\\"small\\",\\"style\\":[{\\"marginHorizontal\\":10,\\"alignItems\\":\\"center\\",\\"backgroundColor\\":\\"transparent\\"},{\\"marginHorizontal\\":8}]},\\"children\\":null}]},{\\"type\\":\\"RNCSlider\\",\\"props\\":{\\"style\\":[{\\"height\\":40},{\\"flex\\":1}],\\"value\\":0,\\"maximumValue\\":0,\\"minimumValue\\":0,\\"animateTransitions\\":true,\\"animationConfig\\":{\\"duration\\":250,\\"delay\\":0},\\"thumbTintColor\\":false,\\"minimumTrackTintColor\\":\\"#1d74f5\\",\\"maximumTrackTintColor\\":\\"#9ca2a8\\",\\"thumbImage\\":{\\"uri\\":\\"audio_thumb\\",\\"scale\\":2},\\"disabled\\":false,\\"step\\":0,\\"inverted\\":false,\\"onRNCSliderSlidingStart\\":null,\\"onRNCSliderSlidingComplete\\":null,\\"enabled\\":true},\\"children\\":null},{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"marginHorizontal\\":12,\\"fontSize\\":14,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},{\\"color\\":\\"#9ca2a8\\"}]},\\"children\\":[\\"00:00\\"]}]},{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},null,{\\"color\\":\\"#2f343d\\"}]},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"accessibilityLabel\\":\\"This is a description \\",\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},[{},{\\"marginTop\\":0,\\"marginBottom\\":0,\\"flexWrap\\":\\"wrap\\",\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"flex-start\\",\\"justifyContent\\":\\"flex-start\\"}]]},\\"children\\":[\\"This is a description \\"]},{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"overflow\\":\\"hidden\\"},[{\\"width\\":20,\\"height\\":20},{}]]},\\"children\\":[{\\"type\\":\\"FastImageView\\",\\"props\\":{\\"style\\":{\\"position\\":\\"absolute\\",\\"left\\":0,\\"right\\":0,\\"top\\":0,\\"bottom\\":0},\\"source\\":{\\"uri\\":\\"https://open.rocket.chat/emoji-custom/nyan_rocket.png\\",\\"priority\\":\\"high\\"},\\"resizeMode\\":\\"contain\\"},\\"children\\":null}]}]}]}]}]}]}]},{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"backgroundColor\\":null,\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"paddingVertical\\":4,\\"width\\":\\"100%\\",\\"paddingHorizontal\\":14,\\"flexDirection\\":\\"column\\"},null]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flexDirection\\":\\"row\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"marginLeft\\":46},false]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},null,{\\"color\\":\\"#2f343d\\"}],\\"numberOfLines\\":0},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"accessibilityLabel\\":\\"First message\\",\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},[{},{\\"marginTop\\":0,\\"marginBottom\\":0,\\"flexWrap\\":\\"wrap\\",\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"flex-start\\",\\"justifyContent\\":\\"flex-start\\"}]],\\"numberOfLines\\":0},\\"children\\":[\\"First message\\"]}]}]}]}]}]}]}]},{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"backgroundColor\\":null,\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"paddingVertical\\":4,\\"width\\":\\"100%\\",\\"paddingHorizontal\\":14,\\"flexDirection\\":\\"column\\"},null]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flexDirection\\":\\"row\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"marginLeft\\":46},false]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":null},{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"center\\",\\"height\\":56,\\"borderWidth\\":1,\\"borderRadius\\":4,\\"marginBottom\\":6},{\\"backgroundColor\\":\\"#f3f4f5\\",\\"borderColor\\":\\"#e1e5e8\\"}]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"hitSlop\\":{\\"top\\":12,\\"right\\":12,\\"bottom\\":12,\\"left\\":12},\\"focusable\\":true,\\"style\\":{\\"marginHorizontal\\":10,\\"alignItems\\":\\"center\\",\\"backgroundColor\\":\\"transparent\\",\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"ActivityIndicator\\",\\"props\\":{\\"animating\\":true,\\"color\\":\\"#9ca2a8\\",\\"hidesWhenStopped\\":true,\\"size\\":\\"small\\",\\"style\\":[{\\"marginHorizontal\\":10,\\"alignItems\\":\\"center\\",\\"backgroundColor\\":\\"transparent\\"},{\\"marginHorizontal\\":8}]},\\"children\\":null}]},{\\"type\\":\\"RNCSlider\\",\\"props\\":{\\"style\\":[{\\"height\\":40},{\\"flex\\":1}],\\"value\\":0,\\"maximumValue\\":0,\\"minimumValue\\":0,\\"animateTransitions\\":true,\\"animationConfig\\":{\\"duration\\":250,\\"delay\\":0},\\"thumbTintColor\\":false,\\"minimumTrackTintColor\\":\\"#1d74f5\\",\\"maximumTrackTintColor\\":\\"#9ca2a8\\",\\"thumbImage\\":{\\"uri\\":\\"audio_thumb\\",\\"scale\\":2},\\"disabled\\":false,\\"step\\":0,\\"inverted\\":false,\\"onRNCSliderSlidingStart\\":null,\\"onRNCSliderSlidingComplete\\":null,\\"enabled\\":true},\\"children\\":null},{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"marginHorizontal\\":12,\\"fontSize\\":14,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},{\\"color\\":\\"#9ca2a8\\"}]},\\"children\\":[\\"00:00\\"]}]},{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},null,{\\"color\\":\\"#2f343d\\"}]},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"accessibilityLabel\\":\\"This is a description\\",\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},[{},{\\"marginTop\\":0,\\"marginBottom\\":0,\\"flexWrap\\":\\"wrap\\",\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"flex-start\\",\\"justifyContent\\":\\"flex-start\\"}]]},\\"children\\":[\\"This is a description\\"]}]}]}]}]}]}]},{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"backgroundColor\\":null,\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"paddingVertical\\":4,\\"width\\":\\"100%\\",\\"paddingHorizontal\\":14,\\"flexDirection\\":\\"column\\"},null]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flexDirection\\":\\"row\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"marginLeft\\":46},false]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":null},{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"center\\",\\"height\\":56,\\"borderWidth\\":1,\\"borderRadius\\":4,\\"marginBottom\\":6},{\\"backgroundColor\\":\\"#f3f4f5\\",\\"borderColor\\":\\"#e1e5e8\\"}]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"hitSlop\\":{\\"top\\":12,\\"right\\":12,\\"bottom\\":12,\\"left\\":12},\\"focusable\\":true,\\"style\\":{\\"marginHorizontal\\":10,\\"alignItems\\":\\"center\\",\\"backgroundColor\\":\\"transparent\\",\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"ActivityIndicator\\",\\"props\\":{\\"animating\\":true,\\"color\\":\\"#9ca2a8\\",\\"hidesWhenStopped\\":true,\\"size\\":\\"small\\",\\"style\\":[{\\"marginHorizontal\\":10,\\"alignItems\\":\\"center\\",\\"backgroundColor\\":\\"transparent\\"},{\\"marginHorizontal\\":8}]},\\"children\\":null}]},{\\"type\\":\\"RNCSlider\\",\\"props\\":{\\"style\\":[{\\"height\\":40},{\\"flex\\":1}],\\"value\\":0,\\"maximumValue\\":0,\\"minimumValue\\":0,\\"animateTransitions\\":true,\\"animationConfig\\":{\\"duration\\":250,\\"delay\\":0},\\"thumbTintColor\\":false,\\"minimumTrackTintColor\\":\\"#1d74f5\\",\\"maximumTrackTintColor\\":\\"#9ca2a8\\",\\"thumbImage\\":{\\"uri\\":\\"audio_thumb\\",\\"scale\\":2},\\"disabled\\":false,\\"step\\":0,\\"inverted\\":false,\\"onRNCSliderSlidingStart\\":null,\\"onRNCSliderSlidingComplete\\":null,\\"enabled\\":true},\\"children\\":null},{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"marginHorizontal\\":12,\\"fontSize\\":14,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},{\\"color\\":\\"#9ca2a8\\"}]},\\"children\\":[\\"00:00\\"]}]}]}]}]}]}]},{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"backgroundColor\\":null,\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"paddingVertical\\":4,\\"width\\":\\"100%\\",\\"paddingHorizontal\\":14,\\"flexDirection\\":\\"column\\"},null]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flexDirection\\":\\"row\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"marginLeft\\":46},false]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":null},{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"center\\",\\"height\\":56,\\"borderWidth\\":1,\\"borderRadius\\":4,\\"marginBottom\\":6},{\\"backgroundColor\\":\\"#f3f4f5\\",\\"borderColor\\":\\"#e1e5e8\\"}]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"hitSlop\\":{\\"top\\":12,\\"right\\":12,\\"bottom\\":12,\\"left\\":12},\\"focusable\\":true,\\"style\\":{\\"marginHorizontal\\":10,\\"alignItems\\":\\"center\\",\\"backgroundColor\\":\\"transparent\\",\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"ActivityIndicator\\",\\"props\\":{\\"animating\\":true,\\"color\\":\\"#9ca2a8\\",\\"hidesWhenStopped\\":true,\\"size\\":\\"small\\",\\"style\\":[{\\"marginHorizontal\\":10,\\"alignItems\\":\\"center\\",\\"backgroundColor\\":\\"transparent\\"},{\\"marginHorizontal\\":8}]},\\"children\\":null}]},{\\"type\\":\\"RNCSlider\\",\\"props\\":{\\"style\\":[{\\"height\\":40},{\\"flex\\":1}],\\"value\\":0,\\"maximumValue\\":0,\\"minimumValue\\":0,\\"animateTransitions\\":true,\\"animationConfig\\":{\\"duration\\":250,\\"delay\\":0},\\"thumbTintColor\\":false,\\"minimumTrackTintColor\\":\\"#1d74f5\\",\\"maximumTrackTintColor\\":\\"#9ca2a8\\",\\"thumbImage\\":{\\"uri\\":\\"audio_thumb\\",\\"scale\\":2},\\"disabled\\":false,\\"step\\":0,\\"inverted\\":false,\\"onRNCSliderSlidingStart\\":null,\\"onRNCSliderSlidingComplete\\":null,\\"enabled\\":true},\\"children\\":null},{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"marginHorizontal\\":12,\\"fontSize\\":14,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},{\\"color\\":\\"#9ca2a8\\"}]},\\"children\\":[\\"00:00\\"]}]}]}]}]}]}]}]}]}"`; exports[`Storyshots Message With file 1`] = `"{\\"type\\":\\"RCTScrollView\\",\\"props\\":{\\"style\\":{\\"backgroundColor\\":\\"#ffffff\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"backgroundColor\\":null,\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"paddingVertical\\":4,\\"width\\":\\"100%\\",\\"paddingHorizontal\\":14,\\"flexDirection\\":\\"column\\"},null]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flexDirection\\":\\"row\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"width\\":36,\\"height\\":36,\\"borderRadius\\":4},{\\"marginTop\\":4}],\\"testID\\":\\"avatar\\"},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"overflow\\":\\"hidden\\"},{\\"width\\":36,\\"height\\":36,\\"borderRadius\\":4}]},\\"children\\":[{\\"type\\":\\"FastImageView\\",\\"props\\":{\\"style\\":{\\"position\\":\\"absolute\\",\\"left\\":0,\\"right\\":0,\\"top\\":0,\\"bottom\\":0},\\"source\\":{\\"uri\\":\\"https://open.rocket.chat/avatar/diego.mello?format=png&size=36\\",\\"priority\\":\\"high\\"},\\"resizeMode\\":\\"cover\\"},\\"children\\":null}]}]}]},{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"marginLeft\\":46},{\\"marginLeft\\":10}]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flex\\":1,\\"flexDirection\\":\\"row\\",\\"justifyContent\\":\\"space-between\\",\\"alignItems\\":\\"center\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"flexShrink\\":1,\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"center\\",\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":16,\\"lineHeight\\":22,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"500\\"},{\\"color\\":\\"#0d0e12\\"}],\\"numberOfLines\\":1},\\"children\\":[\\"diego.mello\\"]}]},{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":12,\\"marginLeft\\":8,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},{\\"color\\":\\"#9ca2a8\\"}]},\\"children\\":[\\"10:00 AM\\"]}]},{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":null},{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"flex\\":1,\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"center\\",\\"marginTop\\":6,\\"alignSelf\\":\\"flex-start\\",\\"borderWidth\\":1,\\"borderRadius\\":4,\\"marginBottom\\":4,\\"backgroundColor\\":\\"#f3f4f5\\",\\"borderColor\\":\\"#e1e5e8\\",\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flex\\":1,\\"borderRadius\\":4,\\"flexDirection\\":\\"column\\",\\"padding\\":15}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flex\\":1,\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"center\\"}},\\"children\\":null},{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},null,{\\"color\\":\\"#2f343d\\"}]},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"accessibilityLabel\\":\\"File.pdf\\",\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},[{},{\\"marginTop\\":0,\\"marginBottom\\":0,\\"flexWrap\\":\\"wrap\\",\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"flex-start\\",\\"justifyContent\\":\\"flex-start\\"}]]},\\"children\\":[\\"File.pdf\\"]}]}]}]},{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},null,{\\"color\\":\\"#2f343d\\"}]},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"accessibilityLabel\\":\\"This is a description \\",\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},[{},{\\"marginTop\\":0,\\"marginBottom\\":0,\\"flexWrap\\":\\"wrap\\",\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"flex-start\\",\\"justifyContent\\":\\"flex-start\\"}]]},\\"children\\":[\\"This is a description \\"]},{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"overflow\\":\\"hidden\\"},[{\\"width\\":20,\\"height\\":20},{}]]},\\"children\\":[{\\"type\\":\\"FastImageView\\",\\"props\\":{\\"style\\":{\\"position\\":\\"absolute\\",\\"left\\":0,\\"right\\":0,\\"top\\":0,\\"bottom\\":0},\\"source\\":{\\"uri\\":\\"https://open.rocket.chat/emoji-custom/nyan_rocket.png\\",\\"priority\\":\\"high\\"},\\"resizeMode\\":\\"contain\\"},\\"children\\":null}]}]}]}]}]}]}]},{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"backgroundColor\\":null,\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"paddingVertical\\":4,\\"width\\":\\"100%\\",\\"paddingHorizontal\\":14,\\"flexDirection\\":\\"column\\"},null]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flexDirection\\":\\"row\\"}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"flex\\":1,\\"marginLeft\\":46},false]},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{},\\"children\\":null},{\\"type\\":\\"View\\",\\"props\\":{\\"accessible\\":true,\\"focusable\\":true,\\"style\\":{\\"flex\\":1,\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"center\\",\\"marginTop\\":6,\\"alignSelf\\":\\"flex-start\\",\\"borderWidth\\":1,\\"borderRadius\\":4,\\"marginBottom\\":4,\\"backgroundColor\\":\\"#f3f4f5\\",\\"borderColor\\":\\"#e1e5e8\\",\\"opacity\\":1}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flex\\":1,\\"borderRadius\\":4,\\"flexDirection\\":\\"column\\",\\"padding\\":15}},\\"children\\":[{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":{\\"flex\\":1,\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"center\\"}},\\"children\\":null},{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},null,{\\"color\\":\\"#2f343d\\"}]},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"accessibilityLabel\\":\\"File.pdf\\",\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},[{},{\\"marginTop\\":0,\\"marginBottom\\":0,\\"flexWrap\\":\\"wrap\\",\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"flex-start\\",\\"justifyContent\\":\\"flex-start\\"}]]},\\"children\\":[\\"File.pdf\\"]}]}]}]},{\\"type\\":\\"Text\\",\\"props\\":{\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},null,{\\"color\\":\\"#2f343d\\"}]},\\"children\\":[{\\"type\\":\\"Text\\",\\"props\\":{\\"accessibilityLabel\\":\\"This is a description \\",\\"style\\":[{\\"fontSize\\":16,\\"textAlign\\":\\"left\\",\\"backgroundColor\\":\\"transparent\\",\\"fontFamily\\":\\"System\\",\\"fontWeight\\":\\"400\\"},[{},{\\"marginTop\\":0,\\"marginBottom\\":0,\\"flexWrap\\":\\"wrap\\",\\"flexDirection\\":\\"row\\",\\"alignItems\\":\\"flex-start\\",\\"justifyContent\\":\\"flex-start\\"}]]},\\"children\\":[\\"This is a description \\"]},{\\"type\\":\\"View\\",\\"props\\":{\\"style\\":[{\\"overflow\\":\\"hidden\\"},[{\\"width\\":20,\\"height\\":20},{}]]},\\"children\\":[{\\"type\\":\\"FastImageView\\",\\"props\\":{\\"style\\":{\\"position\\":\\"absolute\\",\\"left\\":0,\\"right\\":0,\\"top\\":0,\\"bottom\\":0},\\"source\\":{\\"uri\\":\\"https://open.rocket.chat/emoji-custom/nyan_rocket.png\\",\\"priority\\":\\"high\\"},\\"resizeMode\\":\\"contain\\"},\\"children\\":null}]}]}]}]}]}]}]}]}]}"`; From ee9a57f821e5b79a508087f45acd530c6a886b46 Mon Sep 17 00:00:00 2001 From: GleidsonDaniel Date: Wed, 2 Feb 2022 18:25:43 -0300 Subject: [PATCH 4/9] fix type --- app/reducers/login.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/reducers/login.ts b/app/reducers/login.ts index 25e53e2bcf1..ee7e9771785 100644 --- a/app/reducers/login.ts +++ b/app/reducers/login.ts @@ -7,7 +7,7 @@ export interface IUserLogin { token: string; username: string; name: string; - language: null; + language: string; status: TUserStatus; statusText: string; roles: string[]; From b1605a0dd9b073be0824f3bbc877f6e7f09147da Mon Sep 17 00:00:00 2001 From: GleidsonDaniel Date: Thu, 10 Feb 2022 16:57:00 -0300 Subject: [PATCH 5/9] remove partial --- app/actions/login.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/actions/login.ts b/app/actions/login.ts index 1c893fe8dcb..f21844ab585 100644 --- a/app/actions/login.ts +++ b/app/actions/login.ts @@ -16,7 +16,7 @@ interface ILoginRequest extends Action { } interface ILoginSuccess extends Action { - user: Partial; + user: IUserLogin; } interface ILoginFailure extends Action { @@ -65,7 +65,7 @@ export function loginRequest( }; } -export function loginSuccess(user: Partial): ILoginSuccess { +export function loginSuccess(user: IUserLogin): ILoginSuccess { return { type: types.LOGIN.SUCCESS, user From 0249d1d2e4316a02474161b1f6f07cb38975db6a Mon Sep 17 00:00:00 2001 From: GleidsonDaniel Date: Thu, 10 Feb 2022 16:58:27 -0300 Subject: [PATCH 6/9] add more status --- app/reducers/activeUsers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/reducers/activeUsers.ts b/app/reducers/activeUsers.ts index 34771773130..e88f010488f 100644 --- a/app/reducers/activeUsers.ts +++ b/app/reducers/activeUsers.ts @@ -1,7 +1,7 @@ import { TApplicationActions } from '../definitions'; import { SET_ACTIVE_USERS } from '../actions/actionsTypes'; -export type TUserStatus = 'online' | 'offline'; +export type TUserStatus = 'online' | 'offline' | 'busy' | 'away'; export interface IActiveUser { status: TUserStatus; statusText: string; From 839f4063340aab010c891d1e96d3cea3f6525f19 Mon Sep 17 00:00:00 2001 From: GleidsonDaniel Date: Thu, 10 Feb 2022 16:59:42 -0300 Subject: [PATCH 7/9] migrate the rest of the stuff to typescript --- app/views/StatusView.tsx | 47 ++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/app/views/StatusView.tsx b/app/views/StatusView.tsx index 8e678ef066b..40cd5cd212e 100644 --- a/app/views/StatusView.tsx +++ b/app/views/StatusView.tsx @@ -1,24 +1,24 @@ import React from 'react'; -import { StackNavigationProp } from '@react-navigation/stack'; import { FlatList, StyleSheet } from 'react-native'; -import { Dispatch } from 'redux'; import { connect } from 'react-redux'; -import I18n from '../i18n'; +import { setUser } from '../actions/login'; +import * as HeaderButton from '../containers/HeaderButton'; import * as List from '../containers/List'; +import Loading from '../containers/Loading'; +import SafeAreaView from '../containers/SafeAreaView'; import Status from '../containers/Status/Status'; import TextInput from '../containers/TextInput'; +import { LISTENER } from '../containers/Toast'; +import { IBaseScreen, IApplicationState } from '../definitions'; +import I18n from '../i18n'; +import RocketChat from '../lib/rocketchat'; +import { TUserStatus } from '../reducers/activeUsers'; +import { getUserSelector } from '../selectors/login'; +import { withTheme } from '../theme'; import EventEmitter from '../utils/events'; import { showErrorAlert } from '../utils/info'; -import Loading from '../containers/Loading'; -import RocketChat from '../lib/rocketchat'; import log, { events, logEvent } from '../utils/log'; -import { LISTENER } from '../containers/Toast'; -import { withTheme } from '../theme'; -import { getUserSelector } from '../selectors/login'; -import * as HeaderButton from '../containers/HeaderButton'; -import { setUser as setUserAction } from '../actions/login'; -import SafeAreaView from '../containers/SafeAreaView'; const STATUS = [ { @@ -65,12 +65,9 @@ interface IStatusViewState { loading: boolean; } -interface IStatusViewProps { - navigation: StackNavigationProp; +interface IStatusViewProps extends IBaseScreen { user: IUser; - theme: string; isMasterDetail: boolean; - setUser: (user: IUser) => void; Accounts_AllowInvisibleStatusOption: boolean; } @@ -111,7 +108,7 @@ class StatusView extends React.Component { }; setCustomStatus = async (statusText: string) => { - const { user, setUser } = this.props; + const { user, dispatch } = this.props; this.setState({ loading: true }); @@ -119,7 +116,7 @@ class StatusView extends React.Component { const result = await RocketChat.setUserStatus(user.status, statusText); if (result.success) { logEvent(events.STATUS_CUSTOM); - setUser({ statusText }); + dispatch(setUser({ statusText })); EventEmitter.emit(LISTENER, { message: I18n.t('Status_saved_successfully') }); } else { logEvent(events.STATUS_CUSTOM_F); @@ -156,7 +153,7 @@ class StatusView extends React.Component { renderItem = ({ item }: { item: { id: string; name: string } }) => { const { statusText } = this.state; - const { user, setUser } = this.props; + const { user, dispatch } = this.props; const { id, name } = item; return ( { try { const result = await RocketChat.setUserStatus(item.id, statusText); if (result.success) { - setUser({ status: item.id }); + dispatch(setUser({ status: item.id as TUserStatus })); } } catch (e: any) { showErrorAlert(I18n.t(e.data.errorType)); @@ -205,16 +202,10 @@ class StatusView extends React.Component { } } -const mapStateToProps = (state: any) => ({ +const mapStateToProps = (state: IApplicationState) => ({ user: getUserSelector(state), isMasterDetail: state.app.isMasterDetail, - Accounts_AllowInvisibleStatusOption: state.settings.Accounts_AllowInvisibleStatusOption ?? true -}); - -// TODO VERIFY SCREEN FUNCTION AND LOGICS -const mapDispatchToProps = (dispatch: Dispatch) => ({ - // @ts-ignore - setUser: (user: IUser) => dispatch(setUserAction(user)) + Accounts_AllowInvisibleStatusOption: (state.settings.Accounts_AllowInvisibleStatusOption as boolean) ?? true }); -export default connect(mapStateToProps, mapDispatchToProps)(withTheme(StatusView)); +export default connect(mapStateToProps)(withTheme(StatusView)); From 3588cafff5383a5050ac9d3ad610a76d592cb2ba Mon Sep 17 00:00:00 2001 From: GleidsonDaniel Date: Wed, 16 Feb 2022 12:04:07 -0300 Subject: [PATCH 8/9] fix tests and types --- app/reducers/activeUsers.test.ts | 3 ++- app/reducers/activeUsers.ts | 7 +++---- app/reducers/login.test.ts | 5 ++++- app/reducers/login.ts | 10 +++++----- app/views/StatusView.tsx | 6 +++--- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/app/reducers/activeUsers.test.ts b/app/reducers/activeUsers.test.ts index b78db6db490..42a10d40218 100644 --- a/app/reducers/activeUsers.test.ts +++ b/app/reducers/activeUsers.test.ts @@ -1,4 +1,5 @@ import { clearActiveUsers, setActiveUsers } from '../actions/activeUsers'; +import { UserStatus } from '../definitions/UserStatus'; import { IActiveUsers, initialState } from './activeUsers'; import { mockedStore } from './mockedStore'; @@ -8,7 +9,7 @@ describe('test reducer', () => { expect(state).toEqual(initialState); }); it('should return modified store after action', () => { - const activeUsers: IActiveUsers = { any: { status: 'online', statusText: 'any' } }; + const activeUsers: IActiveUsers = { any: { status: UserStatus.ONLINE, statusText: 'any' } }; mockedStore.dispatch(setActiveUsers(activeUsers)); const state = mockedStore.getState().activeUsers; expect(state).toEqual({ ...activeUsers }); diff --git a/app/reducers/activeUsers.ts b/app/reducers/activeUsers.ts index 9c08f0affcd..34a55ce6de3 100644 --- a/app/reducers/activeUsers.ts +++ b/app/reducers/activeUsers.ts @@ -1,10 +1,9 @@ -import { TApplicationActions } from '../definitions'; import { ACTIVE_USERS } from '../actions/actionsTypes'; - -type TUserStatus = 'online' | 'offline' | 'away' | 'busy'; +import { TApplicationActions } from '../definitions'; +import { UserStatus } from '../definitions/UserStatus'; export interface IActiveUser { - status: TUserStatus; + status: UserStatus; statusText: string; } diff --git a/app/reducers/login.test.ts b/app/reducers/login.test.ts index 2ca1887c7a8..abab2ebaf24 100644 --- a/app/reducers/login.test.ts +++ b/app/reducers/login.test.ts @@ -7,6 +7,7 @@ import { setLoginServices, setUser } from '../actions/login'; +import { UserStatus } from '../definitions/UserStatus'; import { initialState } from './login'; import { mockedStore } from './mockedStore'; @@ -46,7 +47,9 @@ describe('test selectedUsers reducer', () => { roles: ['user'], isFromWebView: false, showMessageInMainThread: false, - enableMessageParserEarlyAdoption: false + enableMessageParserEarlyAdoption: false, + status: UserStatus.ONLINE, + statusText: 'online' }; mockedStore.dispatch(loginSuccess(user)); const state = mockedStore.getState().login.user; diff --git a/app/reducers/login.ts b/app/reducers/login.ts index ee7e9771785..d954d2c4ac9 100644 --- a/app/reducers/login.ts +++ b/app/reducers/login.ts @@ -1,23 +1,23 @@ +import { UserStatus } from '../definitions/UserStatus'; import * as types from '../actions/actionsTypes'; import { TActionsLogin } from '../actions/login'; -import { TUserStatus } from './activeUsers'; export interface IUserLogin { id: string; token: string; username: string; name: string; - language: string; - status: TUserStatus; + language?: string; + status: UserStatus; statusText: string; roles: string[]; - avatarETag: string; + avatarETag?: string; isFromWebView: boolean; showMessageInMainThread: boolean; enableMessageParserEarlyAdoption: boolean; emails: Record[]; customFields: Record; - settings: Record; + settings?: Record; } export interface ILogin { diff --git a/app/views/StatusView.tsx b/app/views/StatusView.tsx index 40cd5cd212e..a8822df0052 100644 --- a/app/views/StatusView.tsx +++ b/app/views/StatusView.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { FlatList, StyleSheet } from 'react-native'; import { connect } from 'react-redux'; +import { UserStatus } from '../definitions/UserStatus'; import { setUser } from '../actions/login'; import * as HeaderButton from '../containers/HeaderButton'; import * as List from '../containers/List'; @@ -10,10 +11,9 @@ import SafeAreaView from '../containers/SafeAreaView'; import Status from '../containers/Status/Status'; import TextInput from '../containers/TextInput'; import { LISTENER } from '../containers/Toast'; -import { IBaseScreen, IApplicationState } from '../definitions'; +import { IApplicationState, IBaseScreen } from '../definitions'; import I18n from '../i18n'; import RocketChat from '../lib/rocketchat'; -import { TUserStatus } from '../reducers/activeUsers'; import { getUserSelector } from '../selectors/login'; import { withTheme } from '../theme'; import EventEmitter from '../utils/events'; @@ -165,7 +165,7 @@ class StatusView extends React.Component { try { const result = await RocketChat.setUserStatus(item.id, statusText); if (result.success) { - dispatch(setUser({ status: item.id as TUserStatus })); + dispatch(setUser({ status: item.id as UserStatus })); } } catch (e: any) { showErrorAlert(I18n.t(e.data.errorType)); From d9316854728171bc984d790f56d88492e3551fc7 Mon Sep 17 00:00:00 2001 From: GleidsonDaniel Date: Wed, 16 Feb 2022 15:30:22 -0300 Subject: [PATCH 9/9] fix types and tests --- app/actions/login.ts | 12 ++++++------ app/definitions/IUser.ts | 5 ++++- app/reducers/login.ts | 18 ++++++++++-------- app/selectors/login.ts | 7 ++++--- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/app/actions/login.ts b/app/actions/login.ts index f21844ab585..dead3143362 100644 --- a/app/actions/login.ts +++ b/app/actions/login.ts @@ -1,6 +1,6 @@ import { Action } from 'redux'; -import { IUserLogin } from '../reducers/login'; +import { IUser } from '../definitions'; import * as types from './actionsTypes'; interface ICredentials { @@ -16,11 +16,11 @@ interface ILoginRequest extends Action { } interface ILoginSuccess extends Action { - user: IUserLogin; + user: Partial; } interface ILoginFailure extends Action { - err: Partial; + err: Partial; } interface ILogout extends Action { @@ -28,7 +28,7 @@ interface ILogout extends Action { } interface ISetUser extends Action { - user: Partial; + user: Partial; } interface ISetServices extends Action { @@ -65,7 +65,7 @@ export function loginRequest( }; } -export function loginSuccess(user: IUserLogin): ILoginSuccess { +export function loginSuccess(user: Partial): ILoginSuccess { return { type: types.LOGIN.SUCCESS, user @@ -86,7 +86,7 @@ export function logout(forcedByServer = false): ILogout { }; } -export function setUser(user: Partial): ISetUser { +export function setUser(user: Partial): ISetUser { return { type: types.USER.SET, user diff --git a/app/definitions/IUser.ts b/app/definitions/IUser.ts index 1b5d244c818..1884e8d9cf7 100644 --- a/app/definitions/IUser.ts +++ b/app/definitions/IUser.ts @@ -2,6 +2,7 @@ import Model from '@nozbe/watermelondb/Model'; import { UserStatus } from './UserStatus'; import { IRocketChatRecord } from './IRocketChatRecord'; +import { ILoggedUser } from './ILoggedUser'; export interface ILoginToken { hashedToken: string; @@ -93,8 +94,10 @@ export interface IUserSettings { }; } -export interface IUser extends IRocketChatRecord { +export interface IUser extends IRocketChatRecord, Omit { _id: string; + id: string; + token: string; createdAt: Date; roles: string[]; type: string; diff --git a/app/reducers/login.ts b/app/reducers/login.ts index d954d2c4ac9..2969d0c2815 100644 --- a/app/reducers/login.ts +++ b/app/reducers/login.ts @@ -1,6 +1,7 @@ import { UserStatus } from '../definitions/UserStatus'; import * as types from '../actions/actionsTypes'; import { TActionsLogin } from '../actions/login'; +import { IUser } from '../definitions'; export interface IUserLogin { id: string; @@ -21,7 +22,7 @@ export interface IUserLogin { } export interface ILogin { - user: Partial | Record; + user: Partial; isLocalAuthenticated: boolean; isAuthenticated: boolean; isFetching: boolean; @@ -91,13 +92,14 @@ export default function login(state = initialState, action: TActionsLogin): ILog ...state, user: { ...state.user, - settings: { - ...state.user.settings, - preferences: { - ...state.user.settings.preferences, - ...action.preference - } - } + settings: state.user?.settings + ? { + ...state.user?.settings, + preferences: state.user?.settings?.preferences + ? { ...state.user.settings.preferences, ...action.preference } + : { ...action.preference } + } + : { profile: {}, preferences: {} } } }; case types.LOGIN.SET_LOCAL_AUTHENTICATED: diff --git a/app/selectors/login.ts b/app/selectors/login.ts index d9524b6e484..2b634d6abb8 100644 --- a/app/selectors/login.ts +++ b/app/selectors/login.ts @@ -1,7 +1,7 @@ import { createSelector } from 'reselect'; import isEmpty from 'lodash/isEmpty'; -import { IApplicationState } from '../definitions'; +import { IApplicationState, IUser } from '../definitions'; interface IServices { facebook: { clientId: string }; @@ -13,7 +13,7 @@ interface IServices { wordpress: { clientId: string; serverURL: string }; } -const getUser = (state: IApplicationState) => { +const getUser = (state: IApplicationState): Partial => { if (!isEmpty(state.share?.user)) { return state.share.user; } @@ -23,7 +23,8 @@ const getLoginServices = (state: IApplicationState) => (state.login.services as const getShowFormLoginSetting = (state: IApplicationState) => (state.settings.Accounts_ShowFormLogin as boolean) || false; const getIframeEnabledSetting = (state: IApplicationState) => (state.settings.Accounts_iframe_enabled as boolean) || false; -export const getUserSelector = createSelector([getUser], user => user); +// 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 getShowLoginButton = createSelector( [getLoginServices, getShowFormLoginSetting, getIframeEnabledSetting],