mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-11-24 17:09:13 +03:00
commit
10cdbe9357
@ -25,8 +25,6 @@ class PostButtonContainer extends Component {
|
||||
action,
|
||||
},
|
||||
});
|
||||
|
||||
// navigation.navigate(route);
|
||||
};
|
||||
|
||||
_handleButtonCollapse = (status, platformIsAndroid) => {
|
||||
|
@ -37,17 +37,16 @@ class PostCardContainer extends Component {
|
||||
}
|
||||
};
|
||||
|
||||
_handleOnContentPress = (author, permlink) => {
|
||||
_handleOnContentPress = (content) => {
|
||||
const { navigation } = this.props;
|
||||
|
||||
if (author && permlink) {
|
||||
if (content) {
|
||||
navigation.navigate({
|
||||
routeName: ROUTES.SCREENS.POST,
|
||||
params: {
|
||||
author,
|
||||
permlink,
|
||||
content,
|
||||
},
|
||||
key: permlink,
|
||||
key: content.permlink,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -44,7 +44,7 @@ class PostCard extends Component {
|
||||
_handleOnContentPress = () => {
|
||||
const { handleOnContentPress, content } = this.props;
|
||||
|
||||
handleOnContentPress(content.author, content.permlink);
|
||||
handleOnContentPress(content);
|
||||
};
|
||||
|
||||
_handleOnVotersPress = () => {
|
||||
|
@ -70,7 +70,8 @@ class PostBody extends Component {
|
||||
_alterNode = (node, isComment) => {
|
||||
if (isComment) {
|
||||
if (node.name === 'img') {
|
||||
node.attribs.style = `max-width: ${WIDTH - 50}px; height: 100px; width: ${WIDTH - 50}`;
|
||||
node.attribs.style = `max-width: ${WIDTH - 50}px; height: 100px; width: ${WIDTH
|
||||
- 50}px; text-align: center;`;
|
||||
}
|
||||
// else if (node.name === 'iframe') {
|
||||
// node.attribs.style = `max-width: ${WIDTH}px; left: -30px`;
|
||||
@ -79,6 +80,10 @@ class PostBody extends Component {
|
||||
} else if (node.name === 'a') {
|
||||
node.attribs.style = 'text-decoration: underline';
|
||||
}
|
||||
|
||||
if (node.name === 'img') {
|
||||
node.attribs.style = 'text-align: center;';
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
|
@ -32,9 +32,9 @@ class PostsContainer extends Component {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { currentAccount, isLoginDone } = this.props;
|
||||
const { currentAccount, isLoginDone, tag } = this.props;
|
||||
|
||||
if (!isLoginDone) {
|
||||
if (!isLoginDone && !tag) {
|
||||
return (
|
||||
<Fragment>
|
||||
<PostCardPlaceHolder />
|
||||
|
@ -25,9 +25,10 @@ class PostsView extends Component {
|
||||
startPermlink: '',
|
||||
refreshing: false,
|
||||
isLoading: false,
|
||||
isPostsLoading: false,
|
||||
isPostsLoading: true,
|
||||
isHideImage: false,
|
||||
selectedFilterIndex: 0,
|
||||
isNoPost: false,
|
||||
};
|
||||
}
|
||||
|
||||
@ -43,18 +44,22 @@ class PostsView extends Component {
|
||||
&& nextProps.currentAccountUsername
|
||||
) {
|
||||
// Set all initial data (New user new rules)
|
||||
this.setState({
|
||||
posts: [],
|
||||
startAuthor: '',
|
||||
startPermlink: '',
|
||||
refreshing: false,
|
||||
isLoading: false,
|
||||
isPostsLoading: false,
|
||||
isHideImage: false,
|
||||
selectedFilterIndex: 0,
|
||||
}, () => {
|
||||
this._loadPosts();
|
||||
});
|
||||
this.setState(
|
||||
{
|
||||
posts: [],
|
||||
startAuthor: '',
|
||||
startPermlink: '',
|
||||
refreshing: false,
|
||||
isLoading: false,
|
||||
isPostsLoading: false,
|
||||
isHideImage: false,
|
||||
selectedFilterIndex: 0,
|
||||
isNoPost: false,
|
||||
},
|
||||
() => {
|
||||
this._loadPosts();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,7 +88,7 @@ class PostsView extends Component {
|
||||
|
||||
getPostsSummary(filter || getFor, options, currentAccountUsername)
|
||||
.then((result) => {
|
||||
if (result) {
|
||||
if (result.length > 0) {
|
||||
let _posts = result;
|
||||
|
||||
if (_posts.length > 0) {
|
||||
@ -99,10 +104,13 @@ class PostsView extends Component {
|
||||
isPostsLoading: false,
|
||||
});
|
||||
}
|
||||
} else if (result.length === 0) {
|
||||
this.setState({ isNoPost: true });
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
this.setState({
|
||||
refreshing: false,
|
||||
isPostsLoading: false,
|
||||
});
|
||||
});
|
||||
@ -158,10 +166,15 @@ class PostsView extends Component {
|
||||
|
||||
render() {
|
||||
const {
|
||||
refreshing, posts, isPostsLoading, isHideImage, selectedFilterIndex,
|
||||
refreshing,
|
||||
posts,
|
||||
isPostsLoading,
|
||||
isHideImage,
|
||||
selectedFilterIndex,
|
||||
isNoPost,
|
||||
} = this.state;
|
||||
const {
|
||||
filterOptions, intl, isLoggedIn, getFor, isLoginDone,
|
||||
filterOptions, intl, isLoggedIn, getFor, isLoginDone, tag,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
@ -208,22 +221,18 @@ class PostsView extends Component {
|
||||
ListFooterComponent={this._renderFooter}
|
||||
onScrollBeginDrag={() => this._handleOnScrollStart()}
|
||||
/>
|
||||
) : isNoPost ? (
|
||||
<NoPost
|
||||
name={tag}
|
||||
text={intl.formatMessage({
|
||||
id: 'profile.havent_posted',
|
||||
})}
|
||||
defaultText={intl.formatMessage({
|
||||
id: 'profile.login_to_see',
|
||||
})}
|
||||
/>
|
||||
) : (
|
||||
<Fragment>
|
||||
{/* TODO: fix here */}
|
||||
{/* {
|
||||
(posts.length <= 0 && (
|
||||
<NoPost
|
||||
name={user.name}
|
||||
text={intl.formatMessage({
|
||||
id: 'profile.havent_posted',
|
||||
})}
|
||||
defaultText={intl.formatMessage({
|
||||
id: 'profile.login_to_see',
|
||||
})}
|
||||
/>
|
||||
))
|
||||
} */}
|
||||
<PostCardPlaceHolder />
|
||||
<PostCardPlaceHolder />
|
||||
</Fragment>
|
||||
|
@ -6,9 +6,7 @@ import { getUnreadActivityCount } from '../esteem/esteem';
|
||||
// Utils
|
||||
import { decryptKey } from '../../utils/crypto';
|
||||
import { getDigitPinCode } from './auth';
|
||||
import {
|
||||
parsePosts, parsePost, parseComments,
|
||||
} from '../../utils/postParser';
|
||||
import { parsePosts, parsePost, parseComments } from '../../utils/postParser';
|
||||
import { getName, getAvatar } from '../../utils/user';
|
||||
|
||||
// Constant
|
||||
@ -257,7 +255,9 @@ export const getActiveVotes = (author, permlink) => client.database.call('get_ac
|
||||
export const getPostsSummary = async (by, query, currentUserName) => {
|
||||
try {
|
||||
let posts = await client.database.getDiscussions(by, query);
|
||||
posts = await parsePosts(posts, currentUserName);
|
||||
if (posts) {
|
||||
posts = await parsePosts(posts, currentUserName);
|
||||
}
|
||||
return posts;
|
||||
} catch (error) {
|
||||
return error;
|
||||
@ -368,11 +368,14 @@ export const vote = async (currentAccount, author, permlink, weight) => {
|
||||
};
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
client.broadcast.vote(args, privateKey).then((result) => {
|
||||
resolve(result);
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
client.broadcast
|
||||
.vote(args, privateKey)
|
||||
.then((result) => {
|
||||
resolve(result);
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -385,11 +388,14 @@ export const vote = async (currentAccount, author, permlink, weight) => {
|
||||
const voter = currentAccount.name;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
api.vote(voter, author, permlink, weight).then((result) => {
|
||||
resolve(result);
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
api
|
||||
.vote(voter, author, permlink, weight)
|
||||
.then((result) => {
|
||||
resolve(result);
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { Component } from 'react';
|
||||
import React, { Component, Fragment } from 'react';
|
||||
import { View, Text } from 'react-native';
|
||||
|
||||
// Constants
|
||||
@ -25,20 +25,23 @@ class LaunchScreen extends Component {
|
||||
// Component Functions
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
marginBottom: 130,
|
||||
}}
|
||||
>
|
||||
<Logo style={{ width: 130, height: 130 }} />
|
||||
{/* <Text style={{ fontSize: 24 }}>eSteem</Text>
|
||||
<Text style={{ fontSize: 24 }}>mobile</Text> */}
|
||||
</View>
|
||||
);
|
||||
return <Fragment />;
|
||||
|
||||
// Temporarily removed
|
||||
// return (
|
||||
// <View
|
||||
// style={{
|
||||
// flex: 1,
|
||||
// justifyContent: 'center',
|
||||
// alignItems: 'center',
|
||||
// marginBottom: 130,
|
||||
// }}
|
||||
// >
|
||||
// <Logo style={{ width: 130, height: 130 }} />
|
||||
// {/* <Text style={{ fontSize: 24 }}>eSteem</Text>
|
||||
// <Text style={{ fontSize: 24 }}>mobile</Text> */}
|
||||
// </View>
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,9 +25,11 @@ class PostContainer extends Component {
|
||||
// Component Life Cycle Functions
|
||||
componentDidMount() {
|
||||
const { navigation } = this.props;
|
||||
const { author, permlink } = navigation.state && navigation.state.params;
|
||||
const { content } = navigation.state && navigation.state.params;
|
||||
|
||||
this._loadPost(author, permlink);
|
||||
if (content) {
|
||||
this.setState({ post: content });
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
|
@ -224,6 +224,7 @@ class ProfileContainer extends Component {
|
||||
count,
|
||||
username,
|
||||
},
|
||||
key: `${username}${count}`,
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -121,20 +121,12 @@ class ProfileScreen extends Component {
|
||||
})}
|
||||
style={styles.postTabBar}
|
||||
>
|
||||
{user && (
|
||||
<Posts
|
||||
filterOptions={[
|
||||
'NEW POSTS',
|
||||
'VOTES',
|
||||
'REPLIES',
|
||||
'MENTIONS',
|
||||
'FOLLOWS',
|
||||
'REBLOGS',
|
||||
]}
|
||||
getFor="blog"
|
||||
tag={username}
|
||||
/>
|
||||
)}
|
||||
<Posts
|
||||
filterOptions={['NEW POSTS', 'VOTES', 'REPLIES', 'MENTIONS', 'FOLLOWS', 'REBLOGS']}
|
||||
getFor="blog"
|
||||
tag={username}
|
||||
key={username}
|
||||
/>
|
||||
</View>
|
||||
<View
|
||||
tabLabel={intl.formatMessage({
|
||||
|
@ -13,7 +13,9 @@ const dTubeRegex = /(https?:\/\/d.tube.#!\/v\/)(\w+)\/(\w+)/g;
|
||||
const authorNameRegex = /(^|[^a-zA-Z0-9_!#$%&*@@\/]|(^|[^a-zA-Z0-9_+~.-\/]))[@@]([a-z][-\.a-z\d]+[a-z\d])/gi;
|
||||
const tagsRegex = /(^|\s|>)(#[-a-z\d]+)/gi;
|
||||
const centerRegex = /(<center>)/g;
|
||||
|
||||
const imgRegex = /(https?:\/\/.*\.(?:tiff?|jpe?g|gif|png|svg|ico))(.*)/gim;
|
||||
const pullRightLeftRegex = /(<div class="[^"]*?pull-[^"]*?">(.*?)(<[/]div>))/g;
|
||||
const linkRegex = /[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/gi;
|
||||
export const markDown2Html = (input) => {
|
||||
if (!input) {
|
||||
return '';
|
||||
@ -37,6 +39,14 @@ export const markDown2Html = (input) => {
|
||||
// output = createDtubeIframe(output);
|
||||
// }
|
||||
|
||||
if (pullRightLeftRegex.test(output)) {
|
||||
output = changePullRightLeft(output);
|
||||
}
|
||||
|
||||
if (imgRegex.test(output)) {
|
||||
output = createImage(output);
|
||||
}
|
||||
|
||||
if (vimeoRegex.test(output)) {
|
||||
output = createVimeoIframe(output);
|
||||
}
|
||||
@ -97,6 +107,12 @@ const createCenterImage = input => input.replace(imgCenterRegex, (link) => {
|
||||
return `><img data-href="${_link}" src="${_link}"><`;
|
||||
});
|
||||
|
||||
const changePullRightLeft = input => input.replace(pullRightLeftRegex, (item) => {
|
||||
const imageLink = item.match(linkRegex)[0];
|
||||
|
||||
return `<center style="text-align:center;"><img src="${imageLink}"/></center><br>`;
|
||||
});
|
||||
|
||||
const steemitUrlHandle = input => input.replace(postRegex, (link) => {
|
||||
const postMatch = link.match(postRegex);
|
||||
const tag = postMatch[2];
|
||||
|
@ -4,9 +4,13 @@ import { getPostSummary } from './formatter';
|
||||
import { getReputation } from './reputation';
|
||||
import { getTimeFromNow } from './time';
|
||||
|
||||
export const parsePosts = (posts, currentUserName) => posts.map(post => parsePost(post, currentUserName));
|
||||
export const parsePosts = (posts, currentUserName) => (!posts ? null : posts.map(post => parsePost(post, currentUserName)));
|
||||
|
||||
export const parsePost = (post, currentUserName) => {
|
||||
if (!post) {
|
||||
return null;
|
||||
}
|
||||
|
||||
post.json_metadata = JSON.parse(post.json_metadata);
|
||||
post.json_metadata.image ? (post.image = post.json_metadata.image[0]) : '';
|
||||
post.pending_payout_value = parseFloat(post.pending_payout_value).toFixed(2);
|
||||
|
Loading…
Reference in New Issue
Block a user