mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-19 03:11:38 +03:00
deeplinking improved
This commit is contained in:
parent
4958ea5727
commit
7e8f56d8ff
@ -71,7 +71,7 @@ class UpvoteContainer extends PureComponent {
|
||||
const payoutDate = getTimeFromNow(get(content, 'payout_at'));
|
||||
const beneficiaries = [];
|
||||
const beneficiary = get(content, 'beneficiaries');
|
||||
if (beneficiaries) {
|
||||
if (beneficiary) {
|
||||
beneficiary.forEach((key) => {
|
||||
beneficiaries.push(
|
||||
`\n ${get(key, 'account')}: ${(parseFloat(get(key, 'weight')) / 100).toFixed(2)}%`,
|
||||
|
@ -256,10 +256,11 @@ class ApplicationContainer extends Component {
|
||||
let params;
|
||||
let content;
|
||||
let profile;
|
||||
let keey;
|
||||
const { currentAccount } = this.props;
|
||||
|
||||
const postUrl = postUrlParser(url);
|
||||
const { author, permlink } = postUrl || {};
|
||||
const { author, permlink, feedType, tag } = postUrl || {};
|
||||
|
||||
try {
|
||||
if (author) {
|
||||
@ -269,6 +270,7 @@ class ApplicationContainer extends Component {
|
||||
params = {
|
||||
content,
|
||||
};
|
||||
keey = `${author}/${permlink}`;
|
||||
} else {
|
||||
profile = await getUser(author);
|
||||
routeName = ROUTES.SCREENS.PROFILE;
|
||||
@ -276,17 +278,34 @@ class ApplicationContainer extends Component {
|
||||
username: get(profile, 'name'),
|
||||
reputation: get(profile, 'reputation'),
|
||||
};
|
||||
keey = get(profile, 'name');
|
||||
}
|
||||
}
|
||||
if (feedType) {
|
||||
routeName = ROUTES.SCREENS.SEARCH_RESULT;
|
||||
keey = 'search';
|
||||
}
|
||||
if (feedType && tag) {
|
||||
if (/hive-[1-3]\d{4,6}$/.test(tag)) {
|
||||
routeName = ROUTES.SCREENS.COMMUNITY;
|
||||
} else {
|
||||
routeName = ROUTES.SCREENS.TAG_RESULT;
|
||||
}
|
||||
params = {
|
||||
tag,
|
||||
filter: feedType,
|
||||
};
|
||||
keey = `${feedType}/${tag}`;
|
||||
}
|
||||
} catch (error) {
|
||||
this._handleAlert('deep_link.no_existing_user');
|
||||
}
|
||||
|
||||
if (routeName && (profile || content)) {
|
||||
if (routeName && keey) {
|
||||
navigate({
|
||||
routeName,
|
||||
params,
|
||||
key: permlink || author,
|
||||
key: keey,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -72,23 +72,6 @@ export default (url) => {
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
[
|
||||
'https://estm.to',
|
||||
'https://ecency.com',
|
||||
'https://esteem.app',
|
||||
'https://hive.blog',
|
||||
'https://peakd.com',
|
||||
'https://leofinance.io',
|
||||
].some((x) => url.startsWith(x))
|
||||
) {
|
||||
return parseCatAuthorPermlink(url);
|
||||
}
|
||||
|
||||
if (['https://busy.org', 'https://steemhunt.com'].some((x) => url.startsWith(x))) {
|
||||
return parseAuthorPermlink(url);
|
||||
}
|
||||
|
||||
// For non urls like @good-karma/esteem-london-presentation-e3105ba6637ed
|
||||
let match = url.match(/^[/]?(@[\w.\d-]+)\/(.*)/);
|
||||
if (match && match.length === 3) {
|
||||
@ -117,5 +100,38 @@ export default (url) => {
|
||||
};
|
||||
}
|
||||
|
||||
let profile = url.match(/^https?:\/\/(.*)\/(@[\w.\d-]+)$/);
|
||||
if (profile) {
|
||||
if (profile && profile.length === 3) {
|
||||
return {
|
||||
author: profile[2].replace('@', ''),
|
||||
permlink: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
[
|
||||
'https://estm.to',
|
||||
'https://ecency.com',
|
||||
'https://esteem.app',
|
||||
'https://hive.blog',
|
||||
'https://peakd.com',
|
||||
'https://leofinance.io',
|
||||
].some((x) => url.startsWith(x))
|
||||
) {
|
||||
return parseCatAuthorPermlink(url);
|
||||
}
|
||||
|
||||
if (
|
||||
[
|
||||
'https://ecency.com',
|
||||
'https://hive.blog',
|
||||
'https://peakd.com',
|
||||
'https://leofinance.io',
|
||||
].some((x) => url.startsWith(x))
|
||||
) {
|
||||
return parseAuthorPermlink(url);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user