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