Merge pull request #1024 from esteemapp/bugfix/linking

Fixed linking issue
This commit is contained in:
uğur erdal 2019-08-08 12:27:22 +03:00 committed by GitHub
commit 5b75148a08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,7 @@ import { injectIntl } from 'react-intl';
import { NavigationActions } from 'react-navigation'; import { NavigationActions } from 'react-navigation';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import EStyleSheet from 'react-native-extended-stylesheet'; import EStyleSheet from 'react-native-extended-stylesheet';
import forEach from 'lodash/forEach';
// Constants // Constants
import AUTH_TYPE from '../../../constants/authType'; import AUTH_TYPE from '../../../constants/authType';
@ -170,23 +171,36 @@ class ApplicationContainer extends Component {
let content; let content;
let profile; let profile;
const { currentAccount, dispatch } = this.props; const { currentAccount, dispatch } = this.props;
const { isIos } = this.state;
if ( const mapObj = {
url.indexOf('esteem') > -1 || esteem: '',
url.indexOf('steemit') > -1 || 'steemit.com/': '',
url.indexOf('busy') > -1 || 'busy.org/': '',
url.indexOf('steempeak') > -1 'steempeak.com/': '',
) { };
url = url.substring(url.indexOf('@'), url.length);
const routeParams = url.indexOf('/') > -1 ? url.split('/') : [url];
[, permlink] = routeParams; let formattedUrl = url
author = .split('//')
routeParams && routeParams.length > 0 && routeParams[0].indexOf('@') > -1 .pop()
? routeParams[0].replace('@', '') .replace(/steemit.com\/|busy.org\/|steempeak.com\//gi, matched => {
: routeParams[0]; return mapObj[matched];
});
// TODO: WORKAROUND
if (isIos && url.indexOf('esteem://') > -1) {
formattedUrl = `@${formattedUrl}`;
} }
const routeParams = formattedUrl.indexOf('/') > -1 ? formattedUrl.split('/') : [formattedUrl];
forEach(routeParams, (value, index) => {
if (value.indexOf('@') > -1) {
author = value.replace('@', '');
permlink = routeParams[index + 1];
}
});
if (author && permlink) { if (author && permlink) {
await getPost(author, permlink, currentAccount.name) await getPost(author, permlink, currentAccount.name)
.then(result => { .then(result => {