From 690a753ecaebe53b873d3224126ef2137146236a Mon Sep 17 00:00:00 2001 From: u-e Date: Wed, 19 Dec 2018 14:35:11 +0300 Subject: [PATCH 1/4] loading enhanced --- .../posts/container/postsContainer.js | 4 ++-- src/screens/profile/screen/profileScreen.js | 20 ++++++------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/components/posts/container/postsContainer.js b/src/components/posts/container/postsContainer.js index 190f58618..f22d08f53 100644 --- a/src/components/posts/container/postsContainer.js +++ b/src/components/posts/container/postsContainer.js @@ -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 ( diff --git a/src/screens/profile/screen/profileScreen.js b/src/screens/profile/screen/profileScreen.js index 7bd0255d9..dbe16afb3 100644 --- a/src/screens/profile/screen/profileScreen.js +++ b/src/screens/profile/screen/profileScreen.js @@ -121,20 +121,12 @@ class ProfileScreen extends Component { })} style={styles.postTabBar} > - {user && ( - - )} + Date: Wed, 19 Dec 2018 18:30:58 +0300 Subject: [PATCH 2/4] fixed profile post havent posted text --- .../container/postButtonContainer.js | 2 - .../postElements/body/view/postBodyView.js | 7 +- src/components/posts/view/postsView.js | 69 +++++++++++-------- src/providers/steem/dsteem.js | 34 +++++---- .../profile/container/profileContainer.js | 1 + src/utils/markdownToHtml.js | 18 ++++- src/utils/postParser.js | 6 +- 7 files changed, 88 insertions(+), 49 deletions(-) diff --git a/src/components/postButton/container/postButtonContainer.js b/src/components/postButton/container/postButtonContainer.js index 863ea48dc..a7e7b5497 100644 --- a/src/components/postButton/container/postButtonContainer.js +++ b/src/components/postButton/container/postButtonContainer.js @@ -25,8 +25,6 @@ class PostButtonContainer extends Component { action, }, }); - - // navigation.navigate(route); }; _handleButtonCollapse = (status, platformIsAndroid) => { diff --git a/src/components/postElements/body/view/postBodyView.js b/src/components/postElements/body/view/postBodyView.js index e1b302099..8c16fbd9c 100644 --- a/src/components/postElements/body/view/postBodyView.js +++ b/src/components/postElements/body/view/postBodyView.js @@ -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() { diff --git a/src/components/posts/view/postsView.js b/src/components/posts/view/postsView.js index 6b4062185..002ccab73 100644 --- a/src/components/posts/view/postsView.js +++ b/src/components/posts/view/postsView.js @@ -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 ? ( + ) : ( - {/* TODO: fix here */} - {/* { - (posts.length <= 0 && ( - - )) - } */} diff --git a/src/providers/steem/dsteem.js b/src/providers/steem/dsteem.js index 0b193fa65..3ba00063c 100644 --- a/src/providers/steem/dsteem.js +++ b/src/providers/steem/dsteem.js @@ -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); + }); }); } }; diff --git a/src/screens/profile/container/profileContainer.js b/src/screens/profile/container/profileContainer.js index 04b0fad2b..c5b7f0883 100644 --- a/src/screens/profile/container/profileContainer.js +++ b/src/screens/profile/container/profileContainer.js @@ -224,6 +224,7 @@ class ProfileContainer extends Component { count, username, }, + key: `${username}${count}`, }); }; diff --git a/src/utils/markdownToHtml.js b/src/utils/markdownToHtml.js index 720292987..3ce582a5f 100644 --- a/src/utils/markdownToHtml.js +++ b/src/utils/markdownToHtml.js @@ -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 = /(
)/g; - +const imgRegex = /(https?:\/\/.*\.(?:tiff?|jpe?g|gif|png|svg|ico))(.*)/gim; +const pullRightLeftRegex = /(
(.*?)(<[/]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 `><`; }); +const changePullRightLeft = input => input.replace(pullRightLeftRegex, (item) => { + const imageLink = item.match(linkRegex)[0]; + + return `

`; +}); + const steemitUrlHandle = input => input.replace(postRegex, (link) => { const postMatch = link.match(postRegex); const tag = postMatch[2]; diff --git a/src/utils/postParser.js b/src/utils/postParser.js index 5ed58128b..3dcd70ae7 100644 --- a/src/utils/postParser.js +++ b/src/utils/postParser.js @@ -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); From ffc04c74f312203e2b9bb0d30fd0b9291a2f2c2c Mon Sep 17 00:00:00 2001 From: u-e Date: Wed, 19 Dec 2018 18:38:32 +0300 Subject: [PATCH 3/4] post screen fester than all times --- src/components/postCard/container/postCardContainer.js | 9 ++++----- src/components/postCard/view/postCardView.js | 2 +- src/screens/post/container/postContainer.js | 6 ++++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/components/postCard/container/postCardContainer.js b/src/components/postCard/container/postCardContainer.js index b3e69f96a..b3db06b53 100644 --- a/src/components/postCard/container/postCardContainer.js +++ b/src/components/postCard/container/postCardContainer.js @@ -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, }); } }; diff --git a/src/components/postCard/view/postCardView.js b/src/components/postCard/view/postCardView.js index 49b3d1165..1df06584d 100644 --- a/src/components/postCard/view/postCardView.js +++ b/src/components/postCard/view/postCardView.js @@ -44,7 +44,7 @@ class PostCard extends Component { _handleOnContentPress = () => { const { handleOnContentPress, content } = this.props; - handleOnContentPress(content.author, content.permlink); + handleOnContentPress(content); }; _handleOnVotersPress = () => { diff --git a/src/screens/post/container/postContainer.js b/src/screens/post/container/postContainer.js index c6cfcd04d..a5cb6fd78 100644 --- a/src/screens/post/container/postContainer.js +++ b/src/screens/post/container/postContainer.js @@ -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) { From 4c483bee61cf4ab3971ea7cdd9f94688a97a37ed Mon Sep 17 00:00:00 2001 From: u-e Date: Wed, 19 Dec 2018 18:42:22 +0300 Subject: [PATCH 4/4] launch screen temporarily removed --- src/screens/launch/screen/launchScreen.js | 33 ++++++++++++----------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/screens/launch/screen/launchScreen.js b/src/screens/launch/screen/launchScreen.js index daabeeeae..5af8531b9 100644 --- a/src/screens/launch/screen/launchScreen.js +++ b/src/screens/launch/screen/launchScreen.js @@ -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 ( - - - {/* eSteem - mobile */} - - ); + return ; + + // Temporarily removed + // return ( + // + // + // {/* eSteem + // mobile */} + // + // ); } }