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: Add tokens android crash #1127

Merged
merged 2 commits into from
Oct 2, 2019
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
21 changes: 18 additions & 3 deletions app/components/UI/AddCustomToken/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { PureComponent } from 'react';
import { Text, TextInput, View, StyleSheet } from 'react-native';
import { Text, TextInput, View, StyleSheet, InteractionManager } from 'react-native';
import { colors, fontStyles } from '../../../styles/common';
import Engine from '../../../core/Engine';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -54,8 +54,23 @@ export default class AddCustomToken extends PureComponent {
if (!(await this.validateCustomToken())) return;
const { AssetsController } = Engine.context;
const { address, symbol, decimals } = this.state;
AssetsController.addToken(address, symbol, decimals);
this.props.navigation.goBack();
await AssetsController.addToken(address, symbol, decimals);
// Clear state before closing
this.setState(
{
address: '',
symbol: '',
decimals: '',
warningAddress: '',
warningSymbol: '',
warningDecimals: ''
},
() => {
InteractionManager.runAfterInteractions(() => {
this.props.navigation.goBack();
});
}
);
};

cancelAddToken = () => {
Expand Down
20 changes: 16 additions & 4 deletions app/components/UI/SearchTokenAutocomplete/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { PureComponent } from 'react';
import { View, StyleSheet } from 'react-native';
import { View, StyleSheet, InteractionManager } from 'react-native';
import { colors } from '../../../styles/common';
import PropTypes from 'prop-types';
import { strings } from '../../../../locales/i18n';
Expand Down Expand Up @@ -44,11 +44,23 @@ export default class SearchTokenAutocomplete extends PureComponent {
this.setState({ selectedAsset: asset });
};

addToken = () => {
addToken = async () => {
const { AssetsController } = Engine.context;
const { address, symbol, decimals } = this.state.selectedAsset;
AssetsController.addToken(address, symbol, decimals);
this.props.navigation.goBack();
await AssetsController.addToken(address, symbol, decimals);
// Clear state before closing
this.setState(
{
searchResults: [],
searchQuery: '',
selectedAsset: {}
},
() => {
InteractionManager.runAfterInteractions(() => {
this.props.navigation.goBack();
});
}
);
};

render = () => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"react-native-push-notification": "git+ssh://[email protected]/brunobar79/react-native-push-notification.git#androidx",
"react-native-qrcode-svg": "5.1.2",
"react-native-randombytes": "3.5.2",
"react-native-remote-svg": "git+ssh://[email protected]/brunobar79/react-native-remote-svg.git#cc0ba8b1a0bd8fc73e10b3078751e362ddcb3aee",
"react-native-remote-svg": "git+ssh://[email protected]/brunobar79/react-native-remote-svg.git#6f071a1cefe25e9a9d56570a74523741bae65a8b",
"react-native-screens": "1.0.0-alpha.23",
"react-native-scrollable-tab-view": "git+ssh://[email protected]/estebanmino/react-native-scrollable-tab-view.git#f954274c6260a07c956e2185c611aed24b2f1526",
"react-native-search-api": "1.2.0",
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9039,9 +9039,9 @@ [email protected]:
buffer "^4.9.1"
sjcl "^1.0.3"

"react-native-remote-svg@git+ssh://[email protected]/brunobar79/react-native-remote-svg.git#cc0ba8b1a0bd8fc73e10b3078751e362ddcb3aee":
"react-native-remote-svg@git+ssh://[email protected]/brunobar79/react-native-remote-svg.git#6f071a1cefe25e9a9d56570a74523741bae65a8b":
version "2.0.6"
resolved "git+ssh://[email protected]/brunobar79/react-native-remote-svg.git#cc0ba8b1a0bd8fc73e10b3078751e362ddcb3aee"
resolved "git+ssh://[email protected]/brunobar79/react-native-remote-svg.git#6f071a1cefe25e9a9d56570a74523741bae65a8b"

react-native-safe-area-view@^0.14.1:
version "0.14.7"
Expand Down