From 2f6a16545811cd3f67c4e48c61c46f9a031ac330 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Thu, 27 Feb 2020 16:20:20 -0300 Subject: [PATCH 1/8] [IMPROVEMENT] Add message & loading to AuthLoadingView --- app/actions/index.js | 5 +++-- app/sagas/init.js | 4 ++-- app/views/AuthLoadingView.js | 39 ++++++++++++++++++++++++++++----- app/views/LanguageView/index.js | 4 ++-- app/views/SettingsView/index.js | 4 ++-- 5 files changed, 43 insertions(+), 13 deletions(-) diff --git a/app/actions/index.js b/app/actions/index.js index 494cb1c934..5ea2988121 100644 --- a/app/actions/index.js +++ b/app/actions/index.js @@ -1,10 +1,11 @@ import * as types from '../constants/types'; import { APP } from './actionsTypes'; -export function appStart(root) { +export function appStart(root, text) { return { type: APP.START, - root + root, + text }; } diff --git a/app/sagas/init.js b/app/sagas/init.js index 1db148ab8d..4f35e3d0a7 100644 --- a/app/sagas/init.js +++ b/app/sagas/init.js @@ -110,7 +110,7 @@ const restore = function* restore() { } }; -const start = function* start({ root }) { +const start = function* start({ root, text }) { if (root === 'inside') { yield Navigation.navigate('InsideStack'); } else if (root === 'setUsername') { @@ -118,7 +118,7 @@ const start = function* start({ root }) { } else if (root === 'outside') { yield Navigation.navigate('OutsideStack'); } else if (root === 'loading') { - yield Navigation.navigate('AuthLoading'); + yield Navigation.navigate('AuthLoading', { text }); } RNBootSplash.hide(); }; diff --git a/app/views/AuthLoadingView.js b/app/views/AuthLoadingView.js index 6c6fb58dbb..174d4ae50f 100644 --- a/app/views/AuthLoadingView.js +++ b/app/views/AuthLoadingView.js @@ -1,10 +1,39 @@ import React from 'react'; +import { + View, Text, StyleSheet, ActivityIndicator +} from 'react-native'; import StatusBar from '../containers/StatusBar'; import { withTheme } from '../theme'; +import { themes } from '../constants/colors'; -export default React.memo(withTheme(({ theme }) => ( - <> - - -))); +import sharedStyles from './Styles'; + +const styles = StyleSheet.create({ + container: { + flex: 1, + justifyContent: 'center', + alignItems: 'center' + }, + text: { + fontSize: 24, + paddingTop: 10, + ...sharedStyles.textRegular, + ...sharedStyles.textAlignCenter + } +}); + +export default React.memo(withTheme(({ theme, navigation }) => { + const text = navigation.getParam('text'); + return ( + + + {text && ( + <> + + {text} + + )} + + ); +})); diff --git a/app/views/LanguageView/index.js b/app/views/LanguageView/index.js index 36a9039993..093f48cd4c 100644 --- a/app/views/LanguageView/index.js +++ b/app/views/LanguageView/index.js @@ -133,7 +133,7 @@ class LanguageView extends React.Component { } }); - await appStart('loading'); + await appStart('loading', I18n.t('Change_language_loading')); await appStart('inside'); } catch (e) { showErrorAlert(I18n.t('There_was_an_error_while_action', { action: I18n.t('saving_preferences') })); @@ -205,7 +205,7 @@ const mapStateToProps = state => ({ const mapDispatchToProps = dispatch => ({ setUser: params => dispatch(setUserAction(params)), - appStart: params => dispatch(appStartAction(params)) + appStart: (...params) => dispatch(appStartAction(...params)) }); export default connect(mapStateToProps, mapDispatchToProps)(withTheme(LanguageView)); diff --git a/app/views/SettingsView/index.js b/app/views/SettingsView/index.js index adafca1d73..426c91d2c0 100644 --- a/app/views/SettingsView/index.js +++ b/app/views/SettingsView/index.js @@ -108,7 +108,7 @@ class SettingsView extends React.Component { const { server: { server }, loginRequest, token, appStart } = this.props; - await appStart('loading'); + await appStart('loading', I18n.t('Clear_cache_loading')); await RocketChat.clearCache({ server }); await loginRequest({ resume: token }, true); } @@ -350,7 +350,7 @@ const mapDispatchToProps = dispatch => ({ logout: () => dispatch(logoutAction()), loginRequest: (...params) => dispatch(loginRequestAction(...params)), toggleCrashReport: params => dispatch(toggleCrashReportAction(params)), - appStart: params => dispatch(appStartAction(params)) + appStart: (...params) => dispatch(appStartAction(...params)) }); export default connect(mapStateToProps, mapDispatchToProps)(withTheme(withSplit(SettingsView))); From c3f157331014abc3648e8797c5232fedc14585c3 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Fri, 28 Feb 2020 10:04:28 -0300 Subject: [PATCH 2/8] [I18n] Add translations --- app/i18n/locales/en.js | 2 ++ app/i18n/locales/pt-BR.js | 2 ++ app/views/AuthLoadingView.js | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/i18n/locales/en.js b/app/i18n/locales/en.js index 7f40b56b1a..a38c1f187f 100644 --- a/app/i18n/locales/en.js +++ b/app/i18n/locales/en.js @@ -130,6 +130,7 @@ export default { Click_to_join: 'Click to Join!', Close: 'Close', Close_emoji_selector: 'Close emoji selector', + Change_language_loading: 'Changing language. Please wait.', Choose: 'Choose', Choose_from_library: 'Choose from library', Choose_file: 'Choose file', @@ -150,6 +151,7 @@ export default { Permalink: 'Permalink', Certificate_password: 'Certificate Password', Clear_cache: 'Clear local server cache', + Clear_cache_loading: 'Clearing cache. Please wait.', Whats_the_password_for_your_certificate: 'What\'s the password for your certificate?', Create_account: 'Create an account', Create_Channel: 'Create Channel', diff --git a/app/i18n/locales/pt-BR.js b/app/i18n/locales/pt-BR.js index 61711e32f6..acd3ce640c 100644 --- a/app/i18n/locales/pt-BR.js +++ b/app/i18n/locales/pt-BR.js @@ -128,7 +128,9 @@ export default { Channel_Name: 'Nome do Canal', Channels: 'Canais', Chats: 'Conversas', + Change_language_loading: 'Alterando idioma. Por favor, aguarde.', Call_already_ended: 'A chamada já terminou!', + Clear_cache_loading: 'Limpando cache. Por favor, aguarde.', Click_to_join: 'Clique para participar!', Close: 'Fechar', Close_emoji_selector: 'Fechar seletor de emojis', diff --git a/app/views/AuthLoadingView.js b/app/views/AuthLoadingView.js index 174d4ae50f..fcb2f265b0 100644 --- a/app/views/AuthLoadingView.js +++ b/app/views/AuthLoadingView.js @@ -16,7 +16,7 @@ const styles = StyleSheet.create({ alignItems: 'center' }, text: { - fontSize: 24, + fontSize: 16, paddingTop: 10, ...sharedStyles.textRegular, ...sharedStyles.textAlignCenter From 0eaad31debd36c79dfb962398f988208110c2413 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Fri, 28 Feb 2020 11:41:15 -0300 Subject: [PATCH 3/8] [FIX] Remove loading of LanguageView --- app/i18n/locales/en.js | 5 +++-- app/i18n/locales/pt-BR.js | 5 +++-- app/views/AuthLoadingView.js | 3 ++- app/views/LanguageView/index.js | 20 +++++--------------- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/app/i18n/locales/en.js b/app/i18n/locales/en.js index a38c1f187f..b3e1c5121f 100644 --- a/app/i18n/locales/en.js +++ b/app/i18n/locales/en.js @@ -130,7 +130,7 @@ export default { Click_to_join: 'Click to Join!', Close: 'Close', Close_emoji_selector: 'Close emoji selector', - Change_language_loading: 'Changing language. Please wait.', + Change_language_loading: 'Changing language.', Choose: 'Choose', Choose_from_library: 'Choose from library', Choose_file: 'Choose file', @@ -151,7 +151,7 @@ export default { Permalink: 'Permalink', Certificate_password: 'Certificate Password', Clear_cache: 'Clear local server cache', - Clear_cache_loading: 'Clearing cache. Please wait.', + Clear_cache_loading: 'Clearing cache.', Whats_the_password_for_your_certificate: 'What\'s the password for your certificate?', Create_account: 'Create an account', Create_Channel: 'Create Channel', @@ -303,6 +303,7 @@ export default { pinned: 'pinned', Pinned: 'Pinned', Please_enter_your_password: 'Please enter your password', + Please_wait: 'Please wait.', Preferences: 'Preferences', Preferences_saved: 'Preferences saved!', Privacy_Policy: ' Privacy Policy', diff --git a/app/i18n/locales/pt-BR.js b/app/i18n/locales/pt-BR.js index acd3ce640c..3dc086e745 100644 --- a/app/i18n/locales/pt-BR.js +++ b/app/i18n/locales/pt-BR.js @@ -128,9 +128,9 @@ export default { Channel_Name: 'Nome do Canal', Channels: 'Canais', Chats: 'Conversas', - Change_language_loading: 'Alterando idioma. Por favor, aguarde.', + Change_language_loading: 'Alterando idioma.', Call_already_ended: 'A chamada já terminou!', - Clear_cache_loading: 'Limpando cache. Por favor, aguarde.', + Clear_cache_loading: 'Limpando cache.', Click_to_join: 'Clique para participar!', Close: 'Fechar', Close_emoji_selector: 'Fechar seletor de emojis', @@ -278,6 +278,7 @@ export default { Pinned_Messages: 'Mensagens Fixadas', pinned: 'fixada', Pinned: 'Mensagens Fixadas', + Please_wait: 'Por favor, aguarde.', Please_enter_your_password: 'Por favor, digite sua senha', Preferences: 'Preferências', Preferences_saved: 'Preferências salvas!', diff --git a/app/views/AuthLoadingView.js b/app/views/AuthLoadingView.js index fcb2f265b0..cbc3587e41 100644 --- a/app/views/AuthLoadingView.js +++ b/app/views/AuthLoadingView.js @@ -3,6 +3,7 @@ import { View, Text, StyleSheet, ActivityIndicator } from 'react-native'; +import I18n from '../i18n'; import StatusBar from '../containers/StatusBar'; import { withTheme } from '../theme'; import { themes } from '../constants/colors'; @@ -31,7 +32,7 @@ export default React.memo(withTheme(({ theme, navigation }) => { {text && ( <> - {text} + {`${ text }\n${ I18n.t('Please_wait') }`} )} diff --git a/app/views/LanguageView/index.js b/app/views/LanguageView/index.js index 093f48cd4c..4f2c210cee 100644 --- a/app/views/LanguageView/index.js +++ b/app/views/LanguageView/index.js @@ -6,7 +6,6 @@ import { SafeAreaView } from 'react-navigation'; import RocketChat from '../../lib/rocketchat'; import I18n from '../../i18n'; -import Loading from '../../containers/Loading'; import { showErrorAlert } from '../../utils/info'; import log from '../../utils/log'; import { setUser as setUserAction } from '../../actions/login'; @@ -72,13 +71,12 @@ class LanguageView extends React.Component { constructor(props) { super(props); this.state = { - language: props.user ? props.user.language : 'en', - saving: false + language: props.user ? props.user.language : 'en' }; } shouldComponentUpdate(nextProps, nextState) { - const { language, saving } = this.state; + const { language } = this.state; const { user, theme } = this.props; if (nextProps.theme !== theme) { return true; @@ -86,9 +84,6 @@ class LanguageView extends React.Component { if (nextState.language !== language) { return true; } - if (nextState.saving !== saving) { - return true; - } if (nextProps.user.language !== user.language) { return true; } @@ -105,10 +100,10 @@ class LanguageView extends React.Component { return; } - this.setState({ saving: true }); - const { user, setUser, appStart } = this.props; + await appStart('loading', I18n.t('Change_language_loading')); + const params = {}; // language @@ -132,15 +127,12 @@ class LanguageView extends React.Component { // do nothing } }); - - await appStart('loading', I18n.t('Change_language_loading')); - await appStart('inside'); } catch (e) { showErrorAlert(I18n.t('There_was_an_error_while_action', { action: I18n.t('saving_preferences') })); log(e); } - this.setState({ saving: false }); + await appStart('inside'); } renderSeparator = () => { @@ -171,7 +163,6 @@ class LanguageView extends React.Component { } render() { - const { saving } = this.state; const { theme } = this.props; return ( - ); } From c497cb1b945f98c289f7400ab2b1d6ea670dc3ba Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Fri, 28 Feb 2020 13:00:01 -0300 Subject: [PATCH 4/8] [IMPROVEMENT] Shows loading for at least 200ms --- app/views/LanguageView/index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/views/LanguageView/index.js b/app/views/LanguageView/index.js index 4f2c210cee..17e4ecb1a7 100644 --- a/app/views/LanguageView/index.js +++ b/app/views/LanguageView/index.js @@ -100,10 +100,19 @@ class LanguageView extends React.Component { return; } - const { user, setUser, appStart } = this.props; + const { appStart } = this.props; await appStart('loading', I18n.t('Change_language_loading')); + // shows loading for at least 200ms + await Promise.all([this.changeLanguage(language), new Promise(resolve => setTimeout(resolve, 200))]); + + await appStart('inside'); + } + + changeLanguage = async(language) => { + const { user, setUser } = this.props; + const params = {}; // language @@ -131,8 +140,6 @@ class LanguageView extends React.Component { showErrorAlert(I18n.t('There_was_an_error_while_action', { action: I18n.t('saving_preferences') })); log(e); } - - await appStart('inside'); } renderSeparator = () => { From 9af50bd436aefcaac648fc89f80005edbc0bf76b Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Fri, 28 Feb 2020 15:28:25 -0300 Subject: [PATCH 5/8] [IMPROVEMENT] Add message when logout --- app/sagas/login.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/sagas/login.js b/app/sagas/login.js index 52b413a15b..9d903be057 100644 --- a/app/sagas/login.js +++ b/app/sagas/login.js @@ -147,7 +147,7 @@ const handleLoginSuccess = function* handleLoginSuccess({ user }) { }; const handleLogout = function* handleLogout({ forcedByServer }) { - yield put(appStart('loading')); + yield put(appStart('loading', I18n.t('Logout'))); const server = yield select(getServer); if (server) { try { From 55ac773350dbcccfc7cb8ab158a5d9b6eb430440 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Fri, 28 Feb 2020 15:33:27 -0300 Subject: [PATCH 6/8] [IMPROVEMENT] Messages --- app/i18n/locales/en.js | 5 +++-- app/i18n/locales/pt-BR.js | 5 +++-- app/sagas/login.js | 2 +- app/views/AuthLoadingView.js | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/i18n/locales/en.js b/app/i18n/locales/en.js index b3e1c5121f..61d38642b1 100644 --- a/app/i18n/locales/en.js +++ b/app/i18n/locales/en.js @@ -130,7 +130,7 @@ export default { Click_to_join: 'Click to Join!', Close: 'Close', Close_emoji_selector: 'Close emoji selector', - Change_language_loading: 'Changing language.', + Change_language_loading: 'Changing language', Choose: 'Choose', Choose_from_library: 'Choose from library', Choose_file: 'Choose file', @@ -151,7 +151,7 @@ export default { Permalink: 'Permalink', Certificate_password: 'Certificate Password', Clear_cache: 'Clear local server cache', - Clear_cache_loading: 'Clearing cache.', + Clear_cache_loading: 'Clearing cache', Whats_the_password_for_your_certificate: 'What\'s the password for your certificate?', Create_account: 'Create an account', Create_Channel: 'Create Channel', @@ -237,6 +237,7 @@ export default { Login: 'Login', Login_error: 'Your credentials were rejected! Please try again.', Login_with: 'Login with', + Logging_out: 'Logging out', Logout: 'Logout', Max_number_of_uses: 'Max number of uses', members: 'members', diff --git a/app/i18n/locales/pt-BR.js b/app/i18n/locales/pt-BR.js index 3dc086e745..fa30a79fbb 100644 --- a/app/i18n/locales/pt-BR.js +++ b/app/i18n/locales/pt-BR.js @@ -128,9 +128,9 @@ export default { Channel_Name: 'Nome do Canal', Channels: 'Canais', Chats: 'Conversas', - Change_language_loading: 'Alterando idioma.', + Change_language_loading: 'Alterando idioma', Call_already_ended: 'A chamada já terminou!', - Clear_cache_loading: 'Limpando cache.', + Clear_cache_loading: 'Limpando cache', Click_to_join: 'Clique para participar!', Close: 'Fechar', Close_emoji_selector: 'Fechar seletor de emojis', @@ -224,6 +224,7 @@ export default { Login_error: 'Suas credenciais foram rejeitadas. Tente novamente por favor!', Login_with: 'Login with', Logout: 'Sair', + Logging_out: 'Saindo.', Max_number_of_uses: 'Número máximo de usos', Members: 'Membros', Mentioned_Messages: 'Mensagens mencionadas', diff --git a/app/sagas/login.js b/app/sagas/login.js index 9d903be057..5fd61f0d66 100644 --- a/app/sagas/login.js +++ b/app/sagas/login.js @@ -147,7 +147,7 @@ const handleLoginSuccess = function* handleLoginSuccess({ user }) { }; const handleLogout = function* handleLogout({ forcedByServer }) { - yield put(appStart('loading', I18n.t('Logout'))); + yield put(appStart('loading', I18n.t('Logging_out'))); const server = yield select(getServer); if (server) { try { diff --git a/app/views/AuthLoadingView.js b/app/views/AuthLoadingView.js index cbc3587e41..92a467720a 100644 --- a/app/views/AuthLoadingView.js +++ b/app/views/AuthLoadingView.js @@ -32,7 +32,7 @@ export default React.memo(withTheme(({ theme, navigation }) => { {text && ( <> - {`${ text }\n${ I18n.t('Please_wait') }`} + {`${ text }.\n${ I18n.t('Please_wait') }`} )} From 225fde15062c0f1cdb9c95d9feace5d1eade9aa9 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Fri, 28 Feb 2020 17:00:27 -0300 Subject: [PATCH 7/8] 200s -> 300ms on change language --- app/views/LanguageView/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/LanguageView/index.js b/app/views/LanguageView/index.js index 41a1c5bc9b..716ba335eb 100644 --- a/app/views/LanguageView/index.js +++ b/app/views/LanguageView/index.js @@ -107,8 +107,8 @@ class LanguageView extends React.Component { await appStart('loading', I18n.t('Change_language_loading')); - // shows loading for at least 200ms - await Promise.all([this.changeLanguage(language), new Promise(resolve => setTimeout(resolve, 200))]); + // shows loading for at least 300ms + await Promise.all([this.changeLanguage(language), new Promise(resolve => setTimeout(resolve, 300))]); await appStart('inside'); } From 3b2b0fdffa53deef1d2ea47d2632d938015fa030 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Fri, 28 Feb 2020 17:09:18 -0300 Subject: [PATCH 8/8] Apply suggestions from code review --- app/i18n/locales/en.js | 6 +++--- app/i18n/locales/pt-BR.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/i18n/locales/en.js b/app/i18n/locales/en.js index cfed62b810..f6a643d1bd 100644 --- a/app/i18n/locales/en.js +++ b/app/i18n/locales/en.js @@ -130,7 +130,7 @@ export default { Click_to_join: 'Click to Join!', Close: 'Close', Close_emoji_selector: 'Close emoji selector', - Change_language_loading: 'Changing language', + Change_language_loading: 'Changing language.', Choose: 'Choose', Choose_from_library: 'Choose from library', Choose_file: 'Choose file', @@ -151,7 +151,7 @@ export default { Permalink: 'Permalink', Certificate_password: 'Certificate Password', Clear_cache: 'Clear local server cache', - Clear_cache_loading: 'Clearing cache', + Clear_cache_loading: 'Clearing cache.', Whats_the_password_for_your_certificate: 'What\'s the password for your certificate?', Create_account: 'Create an account', Create_Channel: 'Create Channel', @@ -237,7 +237,7 @@ export default { Login: 'Login', Login_error: 'Your credentials were rejected! Please try again.', Login_with: 'Login with', - Logging_out: 'Logging out', + Logging_out: 'Logging out.', Logout: 'Logout', Max_number_of_uses: 'Max number of uses', members: 'members', diff --git a/app/i18n/locales/pt-BR.js b/app/i18n/locales/pt-BR.js index d4da613b0d..75fae94645 100644 --- a/app/i18n/locales/pt-BR.js +++ b/app/i18n/locales/pt-BR.js @@ -128,9 +128,9 @@ export default { Channel_Name: 'Nome do Canal', Channels: 'Canais', Chats: 'Conversas', - Change_language_loading: 'Alterando idioma', + Change_language_loading: 'Alterando idioma.', Call_already_ended: 'A chamada já terminou!', - Clear_cache_loading: 'Limpando cache', + Clear_cache_loading: 'Limpando cache.', Click_to_join: 'Clique para participar!', Close: 'Fechar', Close_emoji_selector: 'Fechar seletor de emojis',