Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix offline error message on E.cash login page #3067

Merged
merged 2 commits into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,7 @@ export default {
noPhoneNumber: 'Please enter a phone number including the country code e.g +447814266907',
maxParticipantsReached: 'You\'ve reached the maximum number of participants for a group chat.',
},
session: {
offlineMessage: 'Looks like you\'re not connected to internet. Can you check your connection and try again?',
},
};
4 changes: 4 additions & 0 deletions src/libs/actions/Session.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import CONFIG from '../../CONFIG';
import PushNotification from '../Notification/PushNotification';
import Timing from './Timing';
import CONST from '../../CONST';
import {translate} from '../translate';

let credentials = {};
Onyx.connect({
Expand Down Expand Up @@ -132,6 +133,9 @@ function fetchAccountDetails(login) {
}
Onyx.merge(ONYXKEYS.ACCOUNT, {error: response.message});
})
.catch(() => {
Onyx.merge(ONYXKEYS.ACCOUNT, {error: translate('', 'session.offlineMessage')});
})
.finally(() => {
Onyx.merge(ONYXKEYS.ACCOUNT, {loading: false});
});
Expand Down
8 changes: 4 additions & 4 deletions src/libs/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import translations from '../languages/translations';
/**
* Return translated string for given locale and phrase
*
* @param {String} locale eg 'en', 'es-ES'
* @param {String} [locale] eg 'en', 'es-ES'
* @param {String|Array} phrase
* @param {Object} variables
* @returns {string}
* @param {Object} [variables]
* @returns {String}
*/
function translate(locale, phrase, variables = {}) {
function translate(locale = 'en', phrase, variables = {}) {
const localeLanguage = locale.substring(0, 2);
const fullLocale = lodashGet(translations, locale, {});
const language = lodashGet(translations, localeLanguage, {});
Expand Down