mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 04:41:43 +03:00
enhanced routes to post screen
This commit is contained in:
parent
ea8977067a
commit
625c72456e
@ -1,28 +1,34 @@
|
||||
import React from 'react';
|
||||
import { View, Text, TouchableOpacity } from 'react-native';
|
||||
import { withNavigation } from 'react-navigation';
|
||||
import get from 'lodash/get';
|
||||
import { default as ROUTES } from '../../../constants/routeNames';
|
||||
|
||||
|
||||
import styles from './parentPostStyles';
|
||||
|
||||
const ParentPost = ({ post, navigation }) => (
|
||||
<View style={styles.container}>
|
||||
<TouchableOpacity
|
||||
onPress={() => (navigation && navigation.navigate
|
||||
? navigation.navigate({
|
||||
routeName: ROUTES.SCREENS.POST,
|
||||
params: {
|
||||
content: post,
|
||||
},
|
||||
key: post.permlink,
|
||||
})
|
||||
: null)
|
||||
const ParentPost = (props) => {
|
||||
const { navigation, post } = props;
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<TouchableOpacity
|
||||
onPress={() => (get(navigation, 'navigate')
|
||||
? navigation.navigate({
|
||||
routeName: ROUTES.SCREENS.POST,
|
||||
params: {
|
||||
content: post,
|
||||
},
|
||||
key: post.permlink,
|
||||
})
|
||||
: null)
|
||||
}
|
||||
>
|
||||
<Text style={styles.title}>{post.title}</Text>
|
||||
<Text style={styles.description}>{post.summary}</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
>
|
||||
<Text style={styles.title}>{get(post, 'title')}</Text>
|
||||
<Text style={styles.description}>{get(post, 'summary')}</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
export default withNavigation(ParentPost);
|
||||
|
@ -7,7 +7,7 @@ import HTML from 'react-native-html-renderer';
|
||||
import { getParentsTagsRecursively } from 'react-native-html-renderer/src/HTMLUtils';
|
||||
|
||||
// Utils
|
||||
import { validateUsername } from '../../../../utils/user';
|
||||
import { validateUsername } from '../../../../utils/user';
|
||||
|
||||
// Styles
|
||||
import styles from './postBodyStyles';
|
||||
@ -94,14 +94,16 @@ class PostBody extends PureComponent {
|
||||
_handleOnPostPress = (permlink, author) => {
|
||||
const { navigation } = this.props;
|
||||
|
||||
navigation.navigate({
|
||||
routeName: ROUTES.SCREENS.POST,
|
||||
params: {
|
||||
author,
|
||||
permlink,
|
||||
},
|
||||
key: permlink,
|
||||
});
|
||||
if (permlink) {
|
||||
navigation.navigate({
|
||||
routeName: ROUTES.SCREENS.POST,
|
||||
params: {
|
||||
author,
|
||||
permlink,
|
||||
},
|
||||
key: permlink,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_handleOnUserPress = (username) => {
|
||||
|
@ -117,13 +117,15 @@ class DraftsContainer extends Component {
|
||||
_handleOnBookarkPress = (permlink, author) => {
|
||||
const { navigation } = this.props;
|
||||
|
||||
navigation.navigate({
|
||||
routeName: ROUTES.SCREENS.POST,
|
||||
params: {
|
||||
permlink,
|
||||
author,
|
||||
},
|
||||
});
|
||||
if (permlink && author) {
|
||||
navigation.navigate({
|
||||
routeName: ROUTES.SCREENS.POST,
|
||||
params: {
|
||||
permlink,
|
||||
author,
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_sortData = data => data.sort((a, b) => {
|
||||
|
@ -359,7 +359,7 @@ class EditorContainer extends Component {
|
||||
navigation.navigate({
|
||||
routeName: ROUTES.SCREENS.POST,
|
||||
params: {
|
||||
author: currentAccount.name,
|
||||
author: get(currentAccount, 'name'),
|
||||
permlink,
|
||||
isNewPost: true,
|
||||
},
|
||||
|
@ -1,5 +1,6 @@
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import get from 'lodash/get';
|
||||
|
||||
// Actions and Services
|
||||
import { getActivities, markActivityAsRead } from '../../../providers/esteem/esteem';
|
||||
@ -61,6 +62,9 @@ class NotificationContainer extends Component {
|
||||
|
||||
_navigateToNotificationRoute = (data) => {
|
||||
const { navigation, username, dispatch } = this.props;
|
||||
const type = get(data, 'type');
|
||||
const permlink = get(data, 'permlink');
|
||||
const author = get(data, 'author');
|
||||
let routeName;
|
||||
let params;
|
||||
let key;
|
||||
@ -68,30 +72,32 @@ class NotificationContainer extends Component {
|
||||
dispatch(updateUnreadActivityCount(result.unread));
|
||||
});
|
||||
|
||||
if (data.permlink) {
|
||||
if (permlink) {
|
||||
routeName = ROUTES.SCREENS.POST;
|
||||
key = data.permlink;
|
||||
key = permlink;
|
||||
params = {
|
||||
author: data.author,
|
||||
permlink: data.permlink,
|
||||
isHasParentPost: data.parent_author && data.parent_permlink,
|
||||
author,
|
||||
permlink,
|
||||
isHasParentPost: get(data, 'parent_permlink'),
|
||||
};
|
||||
} else if (data.type === 'follow') {
|
||||
} else if (type === 'follow') {
|
||||
routeName = ROUTES.SCREENS.PROFILE;
|
||||
key = data.follower;
|
||||
key = get(data, 'follower');
|
||||
params = {
|
||||
username: data.follower,
|
||||
username: get(data, 'follower'),
|
||||
};
|
||||
} else if (data.type === 'transfer') {
|
||||
} else if (type === 'transfer') {
|
||||
routeName = ROUTES.TABBAR.PROFILE;
|
||||
params = { activePage: 2 };
|
||||
}
|
||||
|
||||
navigation.navigate({
|
||||
routeName,
|
||||
params,
|
||||
key,
|
||||
});
|
||||
if (routeName) {
|
||||
navigation.navigate({
|
||||
routeName,
|
||||
params,
|
||||
key,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_readAllNotification = () => {
|
||||
|
@ -5,6 +5,7 @@ import {
|
||||
import { connect } from 'react-redux';
|
||||
import Push from 'appcenter-push';
|
||||
import { injectIntl } from 'react-intl';
|
||||
import get from 'lodash/get';
|
||||
|
||||
// Actions & Services
|
||||
import { openPinCodeModal } from '../../../redux/actions/applicationActions';
|
||||
@ -72,13 +73,15 @@ const RootContainer = () => (WrappedComponent) => {
|
||||
const routeParams = url.indexOf('/') > -1 ? url.split('/') : [url];
|
||||
|
||||
[, permlink] = routeParams;
|
||||
author = routeParams[0].indexOf('@') > -1 ? routeParams[0].replace('@', '') : routeParams[0];
|
||||
author = routeParams && routeParams.length > 0
|
||||
&& routeParams[0].indexOf('@') > -1
|
||||
? routeParams[0].replace('@', '') : routeParams[0];
|
||||
}
|
||||
|
||||
if (author && permlink) {
|
||||
await getPost(author, permlink, currentAccountUsername)
|
||||
.then((result) => {
|
||||
if (result && result.title) {
|
||||
if (get(result, 'title')) {
|
||||
content = result;
|
||||
} else {
|
||||
this._handleAlert(
|
||||
@ -111,10 +114,10 @@ const RootContainer = () => (WrappedComponent) => {
|
||||
}
|
||||
|
||||
routeName = ROUTES.SCREENS.PROFILE;
|
||||
params = { username: profile.name, reputation: profile.reputation };
|
||||
params = { username: get(profile, 'name'), reputation: get(profile, 'reputation') };
|
||||
}
|
||||
|
||||
if (profile || content) {
|
||||
if (routeName && (profile || content)) {
|
||||
this.navigationTimeout = setTimeout(() => {
|
||||
clearTimeout(this.navigationTimeout);
|
||||
navigation.navigate({
|
||||
@ -168,18 +171,27 @@ const RootContainer = () => (WrappedComponent) => {
|
||||
|
||||
Push.setListener({
|
||||
onPushNotificationReceived(pushNotification) {
|
||||
const push = pushNotification.customProperties;
|
||||
const push = get(pushNotification, 'customProperties');
|
||||
const permlink1 = get(push, 'permlink1');
|
||||
const permlink2 = get(push, 'permlink2');
|
||||
const permlink3 = get(push, 'permlink3');
|
||||
const parentPermlink1 = get(push, 'parent_permlink1');
|
||||
const parentPermlink2 = get(push, 'parent_permlink2');
|
||||
const parentPermlink3 = get(push, 'parent_permlink3');
|
||||
|
||||
if (parentPermlink1 || permlink1) {
|
||||
const fullParentPermlink = `${parentPermlink1}${parentPermlink2}${parentPermlink3}`;
|
||||
const fullPermlink = `${permlink1}${permlink2}${permlink3}`;
|
||||
|
||||
if (push.parent_permlink1 || push.permlink1) {
|
||||
params = {
|
||||
author: push.parent_permlink1 ? push.parent_author : push.target,
|
||||
permlink: push.parent_permlink1
|
||||
? `${push.parent_permlink1}${push.parent_permlink2}${push.parent_permlink3}`
|
||||
: `${push.permlink1}${push.permlink2}${push.permlink3}`,
|
||||
author: parentPermlink1 ? get(push, 'parent_author') : get(push, 'target'),
|
||||
permlink: parentPermlink1
|
||||
? fullParentPermlink
|
||||
: fullPermlink,
|
||||
};
|
||||
key = push.parent_permlink1
|
||||
? `${push.parent_permlink1}${push.parent_permlink2}${push.parent_permlink3}`
|
||||
: `${push.permlink1}${push.permlink2}${push.permlink3}`;
|
||||
key = parentPermlink1
|
||||
? fullParentPermlink
|
||||
: fullPermlink;
|
||||
routeName = ROUTES.SCREENS.POST;
|
||||
} else {
|
||||
params = {
|
||||
@ -189,7 +201,8 @@ const RootContainer = () => (WrappedComponent) => {
|
||||
routeName = ROUTES.SCREENS.PROFILE;
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
this.pushNavigationTimeout = setTimeout(() => {
|
||||
clearTimeout(this.pushNavigationTimeout);
|
||||
navigation.navigate({ routeName, params, key });
|
||||
}, 4000);
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user