mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-20 20:01:56 +03:00
Fixed deeplink issue
This commit is contained in:
parent
d0dd5a532a
commit
036c4d2698
@ -10,7 +10,6 @@ import { setUpvotePercent as upvoteAction } from '../../../redux/actions/applica
|
||||
// Utils
|
||||
import parseToken from '../../../utils/parseToken';
|
||||
import { isEmptyContentDate, getTimeFromNow } from '../../../utils/time';
|
||||
import parseDate from '../../../utils/parseDate';
|
||||
|
||||
// Component
|
||||
import UpvoteView from '../view/upvoteView';
|
||||
|
@ -15,7 +15,6 @@ import { getPost, getUser } from '../../../providers/steem/dsteem';
|
||||
import { Modal } from '../../../components';
|
||||
import { PinCode } from '../../pinCode';
|
||||
import PostButtonForAndroid from '../../../components/postButton/view/postButtonsForAndroid';
|
||||
import { ToastNotificaiton } from '../../../components/toastNotification';
|
||||
|
||||
// Constants
|
||||
import ROUTES from '../../../constants/routeNames';
|
||||
@ -34,7 +33,6 @@ const RootContainer = () => (WrappedComponent) => {
|
||||
componentDidMount() {
|
||||
AppState.addEventListener('change', this._handleAppStateChange);
|
||||
this._createPushListener();
|
||||
console.log('test ===11222211==== :');
|
||||
|
||||
if (Platform.OS === 'android') {
|
||||
Linking.getInitialURL().then((url) => {
|
||||
@ -51,12 +49,10 @@ const RootContainer = () => (WrappedComponent) => {
|
||||
}
|
||||
|
||||
_handleOpenURL = (event) => {
|
||||
console.log('event :', event);
|
||||
this._handleDeepLink(event.url);
|
||||
}
|
||||
|
||||
_handleDeepLink = async (url) => {
|
||||
console.log('url :', url);
|
||||
if (!url) return;
|
||||
|
||||
let author;
|
||||
@ -65,28 +61,20 @@ const RootContainer = () => (WrappedComponent) => {
|
||||
let params;
|
||||
let content;
|
||||
let profile;
|
||||
const postRegex = /^https?:\/\/(.*)\/(.*)\/(@[\w.\d-]+)\/(.*)/i;
|
||||
const { navigation, currentAccountUsername, intl } = this.props;
|
||||
|
||||
console.log('url.indexOf() :', url.indexOf('steemit'));
|
||||
if (url.indexOf('esteem') > -1) {
|
||||
console.log('test ===3 === :');
|
||||
const route = url.replace(/.*?:\/\//g, '');
|
||||
const routeParams = route.indexOf('/') > -1 ? route.split('/') : [route];
|
||||
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];
|
||||
|
||||
if (routeParams && routeParams.length > 1) {
|
||||
permlink = routeParams[2];
|
||||
author = routeParams[1].indexOf('@') > -1 ? routeParams[1].replace('@', '') : routeParams[1];
|
||||
} else if ((routeParams && routeParams.length === 1) || route.indexOf('@') > -1) {
|
||||
author = route.length >= 3 && route;
|
||||
}
|
||||
} else if (url.indexOf('steemit') > -1) {
|
||||
console.log('test ===2 === :');
|
||||
const urlMatch = url.match(postRegex);
|
||||
const sss = urlMatch;
|
||||
[, permlink] = routeParams;
|
||||
author = routeParams[0].indexOf('@') > -1 ? routeParams[0].replace('@', '') : routeParams[0];
|
||||
}
|
||||
console.log('author :', author);
|
||||
console.log('permlink :', permlink);
|
||||
|
||||
if (author && permlink) {
|
||||
await getPost(author, permlink, currentAccountUsername)
|
||||
@ -128,11 +116,13 @@ const RootContainer = () => (WrappedComponent) => {
|
||||
}
|
||||
|
||||
if (profile || content) {
|
||||
navigation.navigate({
|
||||
routeName,
|
||||
params,
|
||||
key: permlink || author,
|
||||
});
|
||||
setTimeout(() => {
|
||||
navigation.navigate({
|
||||
routeName,
|
||||
params,
|
||||
key: permlink || author,
|
||||
});
|
||||
}, 2000);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user