mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 21:01:31 +03:00
Fix for #527
This commit is contained in:
parent
ce24b21f5c
commit
2ee7ba5836
@ -32,7 +32,7 @@ class PostBody extends PureComponent {
|
|||||||
// Component Functions
|
// Component Functions
|
||||||
|
|
||||||
_handleOnLinkPress = (evt, href, hrefatr) => {
|
_handleOnLinkPress = (evt, href, hrefatr) => {
|
||||||
const { handleOnUserPress, handleOnPostPress, intl } = this.props;
|
const { handleOnUserPress, handleOnPostPress } = this.props;
|
||||||
|
|
||||||
if (hrefatr.class === 'markdown-author-link') {
|
if (hrefatr.class === 'markdown-author-link') {
|
||||||
if (!handleOnUserPress) {
|
if (!handleOnUserPress) {
|
||||||
@ -47,9 +47,38 @@ class PostBody extends PureComponent {
|
|||||||
handleOnPostPress(href);
|
handleOnPostPress(href);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Linking.canOpenURL(href).then((supported) => {
|
this._handleBrowserLink(href);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
_handleBrowserLink = async (url) => {
|
||||||
|
if (!url) return;
|
||||||
|
|
||||||
|
let author;
|
||||||
|
let permlink;
|
||||||
|
const { intl } = this.props;
|
||||||
|
|
||||||
|
if (
|
||||||
|
url.indexOf('esteem') > -1
|
||||||
|
|| url.indexOf('steemit') > -1
|
||||||
|
|| url.indexOf('busy') > -1
|
||||||
|
|| url.indexOf('steempeak') > -1
|
||||||
|
) {
|
||||||
|
url = url.substring(url.indexOf('@'), url.length);
|
||||||
|
const routeParams = url.indexOf('/') > -1 ? url.split('/') : [url];
|
||||||
|
|
||||||
|
[, permlink] = routeParams;
|
||||||
|
author = routeParams[0].indexOf('@') > -1 ? routeParams[0].replace('@', '') : routeParams[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (author && permlink) {
|
||||||
|
this._handleOnPostPress(permlink, author);
|
||||||
|
} else if (author) {
|
||||||
|
this._handleOnUserPress(author);
|
||||||
|
} else {
|
||||||
|
Linking.canOpenURL(url).then((supported) => {
|
||||||
if (supported) {
|
if (supported) {
|
||||||
Linking.openURL(href);
|
Linking.openURL(url);
|
||||||
} else {
|
} else {
|
||||||
Alert.alert(intl.formatMessage({ id: 'alert.failed_to_open' }));
|
Alert.alert(intl.formatMessage({ id: 'alert.failed_to_open' }));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user