merged with master

This commit is contained in:
u-e 2018-12-06 14:59:38 +03:00
commit e448d582b1
36 changed files with 334 additions and 384 deletions

2
.gitignore vendored
View File

@ -60,3 +60,5 @@ config.js
keystore/ keystore/
.env .env
package-lock.json package-lock.json
my-release-key.keystore
gradle.properties

View File

@ -19,6 +19,7 @@ import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage; import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage; import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader; import com.facebook.soloader.SoLoader;
import com.facebook.react.BuildConfig;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;

View File

@ -1,15 +0,0 @@
package com.esteem;
import com.facebook.react.ReactActivity;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "eSteem";
}
}

View File

@ -1,45 +0,0 @@
package com.esteem;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage()
);
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}

3
appcenter-post-build.sh Normal file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
printf "Post-Build.sh\n"

View File

@ -1,8 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Creates an .env from ENV variables for use with react-native-config # Creates an .env from ENV variables for use with react-native-config
ENV_WHITELIST=${ENV_WHITELIST:-"."} printf "Old .env file:\n"
cat .env
printf "Started script:\n"
ENV_WHITELIST=${ENV_WHITELIST:-"/ACTIVITY|WEBSOCKET|BACKEND|API|TOKEN|URL/"}
printf "Creating an .env file with the following whitelist:\n" printf "Creating an .env file with the following whitelist:\n"
printf "%s\n\n" $ENV_WHITELIST printf "%s\n\n" $ENV_WHITELIST
set | egrep -e $ENV_WHITELIST | egrep -v "^_" | egrep -v "WHITELIST" > .env set | egrep -e $ENV_WHITELIST | egrep -v "^_" | egrep -v "WHITELIST" | egrep -v "USER-DEFINED" > .env
printf "\n.env created with contents:\n" printf "\n.env created with contents:\n"
cat .env cat .env
printf "\nEND OF .env\n"

View File

@ -36,7 +36,6 @@ class CommentsView extends Component {
avatarSize, avatarSize,
marginLeft, marginLeft,
handleOnUserPress, handleOnUserPress,
currentUser,
commentNumber, commentNumber,
handleOnReplyPress, handleOnReplyPress,
isProfilePreview, isProfilePreview,

View File

@ -29,9 +29,7 @@ class CommentsDisplayView extends Component {
}; };
render() { render() {
const { const { author, permlink, commentCount } = this.props;
currentUser, author, permlink, commentCount,
} = this.props;
return ( return (
<Fragment> <Fragment>
@ -44,7 +42,7 @@ class CommentsDisplayView extends Component {
onDropdownSelect={this._handleOnDropdownSelect} onDropdownSelect={this._handleOnDropdownSelect}
/> />
<View style={{ padding: 16 }}> <View style={{ padding: 16 }}>
<Comments currentUser={currentUser} author={author} permlink={permlink} /> <Comments author={author} permlink={permlink} />
</View> </View>
</Fragment> </Fragment>
)} )}

View File

@ -9,10 +9,13 @@ import { connect } from 'react-redux';
// Constants // Constants
// Utilities // Utilities
import { getReputation } from '../../../utils/user';
// Component // Component
import { HeaderView } from '..'; import { HeaderView } from '..';
const DEFAULT_IMAGE = require('../../../assets/avatar_default.png');
/* /*
* Props Name Description Value * Props Name Description Value
*@props --> props name here description here Value Type Here *@props --> props name here description here Value Type Here
@ -42,14 +45,37 @@ class HeaderContainer extends Component {
}; };
render() { render() {
const { isLoggedIn, currentUser, user } = this.props; const {
isLoggedIn, currentAccount, selectedUser, isReverse, isLoginDone,
} = this.props;
let avatar;
let displayName;
let userName;
let reputation;
if (isReverse && selectedUser) {
avatar = selectedUser.avatar ? { uri: selectedUser.avatar } : DEFAULT_IMAGE;
displayName = selectedUser.display_name;
userName = selectedUser.name;
reputation = getReputation(selectedUser.reputation);
} else if (!isReverse) {
avatar = currentAccount.avatar ? { uri: currentAccount.avatar } : DEFAULT_IMAGE;
displayName = currentAccount.display_name;
userName = currentAccount.name;
reputation = getReputation(currentAccount.reputation);
}
return ( return (
<HeaderView <HeaderView
handleOnPressBackButton={this._handleOnPressBackButton} handleOnPressBackButton={this._handleOnPressBackButton}
handleOpenDrawer={this._handleOpenDrawer} handleOpenDrawer={this._handleOpenDrawer}
isLoggedIn={isLoggedIn} isLoggedIn={isLoggedIn}
currentAccount={user || currentUser} isReverse={isReverse}
{...this.props} isLoginDone={isLoginDone}
avatar={avatar}
displayName={displayName}
userName={userName}
reputation={reputation}
/> />
); );
} }
@ -57,7 +83,9 @@ class HeaderContainer extends Component {
const mapStateToProps = state => ({ const mapStateToProps = state => ({
isLoggedIn: state.application.isLoggedIn, isLoggedIn: state.application.isLoggedIn,
currentUser: state.account.currentAccount, isLoginDone: state.application.isLoginDone,
currentAccount: state.account.currentAccount,
}); });
export default connect(mapStateToProps)(withNavigation(HeaderContainer)); export default connect(mapStateToProps)(withNavigation(HeaderContainer));

View File

@ -1,14 +1,10 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { import {
View, StatusBar, Text, SafeAreaView, TouchableOpacity, View, StatusBar, Text, SafeAreaView, TouchableOpacity, Image,
} from 'react-native'; } from 'react-native';
import FastImage from 'react-native-fast-image';
import LinearGradient from 'react-native-linear-gradient'; import LinearGradient from 'react-native-linear-gradient';
import { injectIntl } from 'react-intl'; import { injectIntl } from 'react-intl';
// Utils
import { getReputation } from '../../../utils/user';
// Components // Components
import { SearchModal } from '../../searchModal'; import { SearchModal } from '../../searchModal';
import { IconButton } from '../../iconButton'; import { IconButton } from '../../iconButton';
@ -42,18 +38,20 @@ class HeaderView extends Component {
render() { render() {
const { const {
handleOpenDrawer, avatar,
displayName,
handleOnPressBackButton, handleOnPressBackButton,
handleOpenDrawer,
hideStatusBar, hideStatusBar,
isReverse,
currentAccount,
intl, intl,
isLoggedIn,
isLoginDone,
isReverse,
reputation,
userName,
} = this.props; } = this.props;
const { isSearchModalOpen } = this.state; const { isSearchModalOpen } = this.state;
const _reputation = getReputation(currentAccount.reputation);
const _avatar = currentAccount.profile_image
? { uri: currentAccount.profile_image }
: DEFAULT_IMAGE;
return ( return (
<SafeAreaView style={[styles.container, isReverse && styles.containerReverse]}> <SafeAreaView style={[styles.container, isReverse && styles.containerReverse]}>
{/* <StatusBar style={ { height: 20}} hidden={hideStatusBar} translucent /> */} {/* <StatusBar style={ { height: 20}} hidden={hideStatusBar} translucent /> */}
@ -77,27 +75,27 @@ class HeaderView extends Component {
isReverse ? styles.avatarButtonWrapperReverse : styles.avatarDefault, isReverse ? styles.avatarButtonWrapperReverse : styles.avatarDefault,
]} ]}
> >
<FastImage style={styles.avatar} source={_avatar} defaultSource={DEFAULT_IMAGE} /> <Image style={styles.avatar} source={avatar} defaultSource={DEFAULT_IMAGE} />
</LinearGradient> </LinearGradient>
</TouchableOpacity> </TouchableOpacity>
{currentAccount && currentAccount.name ? ( {displayName || userName ? (
<View style={styles.titleWrapper}> <View style={styles.titleWrapper}>
{currentAccount.display_name && ( {displayName && <Text style={styles.title}>{displayName}</Text>}
<Text style={styles.title}>{currentAccount.display_name}</Text>
)}
<Text style={styles.subTitle}> <Text style={styles.subTitle}>
@ @
{currentAccount.name} {userName}
{`(${_reputation})`} {`(${reputation})`}
</Text> </Text>
</View> </View>
) : ( ) : (
<View style={styles.titleWrapper}> <View style={styles.titleWrapper}>
<Text style={styles.noAuthTitle}> {isLoginDone && !isLoggedIn && (
{intl.formatMessage({ <Text style={styles.noAuthTitle}>
id: 'header.title', {intl.formatMessage({
})} id: 'header.title',
</Text> })}
</Text>
)}
</View> </View>
)} )}
{isReverse && ( {isReverse && (

View File

@ -152,13 +152,14 @@ export default class MarkdownEditorView extends Component {
iconType="FontAwesome" iconType="FontAwesome"
name="image" name="image"
/> />
<DropdownButton {/* TODO: After alpha */}
{/* <DropdownButton
style={styles.dropdownStyle} style={styles.dropdownStyle}
options={['option1', 'option2', 'option3', 'option4']} options={['option1', 'option2', 'option3', 'option4']}
iconName="md-more" iconName="md-more"
iconStyle={styles.dropdownIconStyle} iconStyle={styles.dropdownIconStyle}
isHasChildIcon isHasChildIcon
/> /> */}
</View> </View>
</StickyBar> </StickyBar>
); );

View File

@ -4,7 +4,6 @@ import {
} from 'react-native'; } from 'react-native';
// import FastImage from 'react-native-fast-image'; // import FastImage from 'react-native-fast-image';
import { PostHeaderDescription } from '../../postElements'; import { PostHeaderDescription } from '../../postElements';
import { DropdownButton } from '../../dropdownButton';
import { PostDropdown } from '../../postDropdown'; import { PostDropdown } from '../../postDropdown';
import { Icon } from '../../icon'; import { Icon } from '../../icon';
import { LineBreak } from '../../basicUIElements'; import { LineBreak } from '../../basicUIElements';
@ -32,10 +31,10 @@ class PostCard extends Component {
// Component Functions // Component Functions
_handleOnUserPress = () => { _handleOnUserPress = () => {
const { handleOnUserPress, content, user } = this.props; const { handleOnUserPress, content } = this.props;
if (handleOnUserPress && content && content.author !== user.name) { if (handleOnUserPress && content) {
handleOnUserPress(content.author, content.author); handleOnUserPress(content.author);
} }
}; };
@ -57,7 +56,7 @@ class PostCard extends Component {
render() { render() {
const { const {
content, isLoggedIn, user, isHideImage, content, isHideImage,
} = this.props; } = this.props;
// const likersText = `@${content.top_likers[0]}, @${content.top_likers[1]}, @${ // const likersText = `@${content.top_likers[0]}, @${content.top_likers[1]}, @${
// content.top_likers[2] // content.top_likers[2]
@ -121,31 +120,6 @@ class PostCard extends Component {
</TouchableOpacity> </TouchableOpacity>
</View> </View>
<LineBreak height={8} /> <LineBreak height={8} />
{/* {content && content.top_likers ? (
<TouchableOpacity
style={styles.likersWrapper}
onPress={() => this._handleOnVotersPress()}
>
<View style={styles.topLikers}>
{content.top_likers.map((liker, i) => (
<FastImage
source={{
uri: `https://steemitimages.com/u/${liker}/avatar/small`,
}}
style={[styles.liker, i !== 0 && { marginLeft: -3 }]}
/>
))}
<Text style={styles.footer}>
{likersText}
{otherLikers}
</Text>
</View>
</TouchableOpacity>
) : (
<View>
<Text style={styles.footer}>{likesCount}</Text>
</View>
)} */}
</View> </View>
); );
} }

View File

@ -53,13 +53,13 @@ class PostDisplayContainer extends Component {
}; };
render() { render() {
const { post, currentUser } = this.props; const { post, currentAccount } = this.props;
return ( return (
<PostDisplayView <PostDisplayView
handleOnVotersPress={this._handleOnVotersPress} handleOnVotersPress={this._handleOnVotersPress}
handleOnReplyPress={this._handleOnReplyPress} handleOnReplyPress={this._handleOnReplyPress}
currentUser={currentUser} currentAccount={currentAccount}
post={post} post={post}
/> />
); );

View File

@ -53,7 +53,7 @@ class PostDisplayView extends Component {
_getTabBar = (isFixedFooter = false) => { _getTabBar = (isFixedFooter = false) => {
const { const {
post, post,
currentUser, currentAccount,
handleOnReplyPress, handleOnReplyPress,
handleOnEditPress, handleOnEditPress,
handleOnVotersPress, handleOnVotersPress,
@ -80,7 +80,7 @@ class PostDisplayView extends Component {
iconType="FontAwesome" iconType="FontAwesome"
/> />
<View style={styles.stickyRightWrapper}> <View style={styles.stickyRightWrapper}>
{post && currentUser && currentUser.name === post.author && ( {post && currentAccount && currentAccount.name === post.author && (
<IconButton <IconButton
iconStyle={styles.barIconRight} iconStyle={styles.barIconRight}
style={styles.barIconButton} style={styles.barIconButton}
@ -103,7 +103,7 @@ class PostDisplayView extends Component {
}; };
render() { render() {
const { post, currentUser } = this.props; const { post } = this.props;
const { postHeight, scrollHeight, isLoadedComments } = this.state; const { postHeight, scrollHeight, isLoadedComments } = this.state;
const isPostEnd = scrollHeight > postHeight; const isPostEnd = scrollHeight > postHeight;
@ -145,7 +145,6 @@ class PostDisplayView extends Component {
</View> </View>
{post && (isGetComment || isLoadedComments) && ( {post && (isGetComment || isLoadedComments) && (
<CommentsDisplay <CommentsDisplay
currentUser={currentUser}
author={post.author} author={post.author}
permlink={post.permlink} permlink={post.permlink}
commentCount={post.children} commentCount={post.children}

View File

@ -1,13 +1,15 @@
import React, { Component } from 'react'; import React, { Component, Fragment } from 'react';
import { connect } from 'react-redux';
// Component // Component
import { PostsView } from '..'; import { PostsView } from '..';
import { PostCardPlaceHolder } from '../../basicUIElements';
/* /*
* Props Name Description Value * Props Name Description Value
*@props --> props name here description here Value Type Here *@props --> props name here description here Value Type Here
* *
*/ */
class PostsContainer extends Component { class PostsContainer extends Component {
constructor(props) { constructor(props) {
@ -20,8 +22,29 @@ class PostsContainer extends Component {
// Component Functions // Component Functions
render() { render() {
return <PostsView {...this.props} />; const { currentAccount, isLoginDone } = this.props;
if (!isLoginDone) {
return (
<Fragment>
<PostCardPlaceHolder />
<PostCardPlaceHolder />
</Fragment>
);
}
return (
<PostsView
currentAccountUsername={currentAccount && currentAccount.username}
{...this.props}
/>
);
} }
} }
export default PostsContainer; const mapStateToProps = state => ({
currentAccount: state.account.currentAccount,
isLoginDone: state.application.isLoginDone,
});
export default connect(mapStateToProps)(PostsContainer);

View File

@ -18,7 +18,6 @@ class PostsView extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
user: props.user || null,
posts: [], posts: [],
startAuthor: '', startAuthor: '',
startPermlink: '', startPermlink: '',
@ -30,53 +29,42 @@ class PostsView extends Component {
} }
componentDidMount() { componentDidMount() {
const { user, isLoggedIn, isLoginMust } = this.state; this._loadPosts();
const isCanLoad = isLoginMust ? isLoggedIn : true;
isCanLoad && this._loadPosts(user);
} }
componentWillReceiveProps(nextProps) { _loadPosts = (filter = null) => {
const { user } = this.props; const { getFor, tag, currentAccountUsername } = this.props;
if (user !== nextProps.user) {
this.setState({ user: nextProps.user });
this._loadPosts(nextProps.user, nextProps.tag);
}
}
_loadPosts = (user, _tag = null, _getFor = null) => {
const { getFor, tag } = this.props;
const { isHideImage } = this.state;
let options; let options;
_getFor ? (options = { limit: 3 }) : (options = { tag: _tag || tag, limit: 3 });
if (user) { if (!filter) {
getPostsSummary(_getFor || getFor, options, user && user.name, isHideImage) options = { tag, limit: 3 };
.then((result) => { } else {
if (result) { options = { limit: 3 };
this.setState({
posts: result,
startAuthor: result[result.length - 1] && result[result.length - 1].author,
startPermlink: result[result.length - 1] && result[result.length - 1].permlink,
refreshing: false,
isPostsLoading: false,
});
}
})
.catch((err) => {
alert(err);
});
} }
getPostsSummary(filter || getFor, options, currentAccountUsername)
.then((result) => {
if (result) {
this.setState({
posts: result,
startAuthor: result[result.length - 1] && result[result.length - 1].author,
startPermlink: result[result.length - 1] && result[result.length - 1].permlink,
refreshing: false,
isPostsLoading: false,
});
}
})
.catch((err) => {
alert(err);
});
}; };
_loadMore = () => { _loadMore = () => {
// TODO: merge above function with this func (after alpha). // TODO: merge above function with this func (after alpha).
const { const {
posts, startAuthor, startPermlink, user, isHideImage, posts, startAuthor, startPermlink,
} = this.state; } = this.state;
const { getFor, tag } = this.props; const { getFor, tag, currentAccountUsername } = this.props;
this.setState({ isLoading: true }); this.setState({ isLoading: true });
@ -88,8 +76,7 @@ class PostsView extends Component {
start_author: startAuthor, start_author: startAuthor,
start_permlink: startPermlink, start_permlink: startPermlink,
}, },
(user && user.name) || 'esteemapp', currentAccountUsername,
isHideImage,
).then((result) => { ).then((result) => {
const _posts = result; const _posts = result;
_posts.shift(); _posts.shift();
@ -102,14 +89,12 @@ class PostsView extends Component {
}; };
_handleOnRefreshPosts = () => { _handleOnRefreshPosts = () => {
const { user } = this.state;
this.setState( this.setState(
{ {
refreshing: true, refreshing: true,
}, },
() => { () => {
this._loadPosts(user); this._loadPosts();
}, },
); );
}; };
@ -128,9 +113,8 @@ class PostsView extends Component {
}; };
_handleOnDropdownSelect = (index) => { _handleOnDropdownSelect = (index) => {
const { user } = this.state;
this.setState({ isPostsLoading: true }); this.setState({ isPostsLoading: true });
this._loadPosts(user, null, filters[index]); this._loadPosts(filters[index]);
}; };
_onRightIconPress = () => { _onRightIconPress = () => {
@ -141,11 +125,9 @@ class PostsView extends Component {
render() { render() {
const { const {
refreshing, posts, user, isPostsLoading, isHideImage, refreshing, posts, isPostsLoading, isHideImage,
} = this.state; } = this.state;
const { const { componentId, filterOptions, intl } = this.props;
componentId, filterOptions, isLoggedIn, intl,
} = this.props;
return ( return (
<Fragment> <Fragment>
@ -160,18 +142,12 @@ class PostsView extends Component {
onRightIconPress={this._onRightIconPress} onRightIconPress={this._onRightIconPress}
/> />
)} )}
{user && posts && posts.length > 0 && !isPostsLoading ? ( {posts && posts.length > 0 && !isPostsLoading ? (
<FlatList <FlatList
data={posts} data={posts}
showsVerticalScrollIndicator={false} showsVerticalScrollIndicator={false}
renderItem={({ item }) => ( renderItem={({ item }) => (
<PostCard <PostCard componentId={componentId} content={item} isHideImage={isHideImage} />
componentId={componentId}
content={item}
user={user}
isLoggedIn={isLoggedIn}
isHideImage={isHideImage}
/>
)} )}
keyExtractor={(post, index) => index.toString()} keyExtractor={(post, index) => index.toString()}
onEndReached={this._loadMore} onEndReached={this._loadMore}

View File

@ -4,7 +4,6 @@ import {
} from 'react-native'; } from 'react-native';
import { injectIntl } from 'react-intl'; import { injectIntl } from 'react-intl';
import LinearGradient from 'react-native-linear-gradient'; import LinearGradient from 'react-native-linear-gradient';
import FastImage from 'react-native-fast-image';
// Components // Components
import { Icon, IconButton } from '../..'; import { Icon, IconButton } from '../..';
@ -69,12 +68,8 @@ class SideMenuView extends Component {
navigateToRoute, currentAccount, isLoggedIn, switchAccount, intl, navigateToRoute, currentAccount, isLoggedIn, switchAccount, intl,
} = this.props; } = this.props;
const { menuItems, isAddAccountIconActive } = this.state; const { menuItems, isAddAccountIconActive } = this.state;
const _avatar = currentAccount.profile_image const _avatar = currentAccount.avatar ? { uri: currentAccount.avatar } : DEFAULT_IMAGE;
? { uri: currentAccount.profile_image }
: DEFAULT_IMAGE;
console.log(_avatar);
console.log(menuItems);
return ( return (
<View style={styles.container}> <View style={styles.container}>
<LinearGradient <LinearGradient

View File

@ -1,14 +1,6 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
// Services and Actions
// Middleware
// Constants
// Utilities
// Component // Component
import { UpvoteView } from '..'; import { UpvoteView } from '..';
@ -29,7 +21,32 @@ class UpvoteContainer extends Component {
// Component Functions // Component Functions
render() { render() {
return <UpvoteView {...this.props} />; const {
content, currentAccount, isLoggedIn, isShowPayoutValue,
} = this.props;
let author;
let isVoted;
let pendingPayoutValue;
let permlink;
if (content) {
author = content.author;
isVoted = content.is_voted;
pendingPayoutValue = content.pending_payout_value;
permlink = content.permlink;
}
return (
<UpvoteView
author={author}
currentAccount={currentAccount}
isLoggedIn={isLoggedIn}
isShowPayoutValue={isShowPayoutValue}
isVoted={isVoted}
pendingPayoutValue={pendingPayoutValue}
permlink={permlink}
/>
);
} }
} }

View File

@ -1,6 +1,6 @@
import React, { Component, Fragment } from 'react'; import React, { Component, Fragment } from 'react';
import { import {
View, TouchableOpacity, ActivityIndicator, Text, View, TouchableOpacity, ActivityIndicator, Text, Alert,
} from 'react-native'; } from 'react-native';
import { Popover, PopoverController } from 'react-native-modal-popover'; import { Popover, PopoverController } from 'react-native-modal-popover';
import Slider from 'react-native-slider'; import Slider from 'react-native-slider';
@ -28,16 +28,23 @@ class UpvoteView extends Component {
this.state = { this.state = {
sliderValue: 0.0, sliderValue: 0.0,
isVoting: false, isVoting: false,
isVoted: props.content ? props.content.is_voted : false, isVoted: props.isVoted,
amount: '0.00', amount: '0.00000',
isModalVisible: false,
}; };
} }
// Component Life Cycles // Component Life Cycles
// Component Functions componentWillReceiveProps(nextProps) {
const { isVoted } = this.props;
const { isVoted: localIsVoted } = this.state;
if (isVoted !== nextProps.isVoted && localIsVoted !== nextProps.isVoted) {
this.setState({ isVoted: nextProps.isVoted });
}
}
// Component Functions
_calculateEstimatedAmount = async () => { _calculateEstimatedAmount = async () => {
const { currentAccount } = this.props; const { currentAccount } = this.props;
// Calculate total vesting shares // Calculate total vesting shares
@ -62,7 +69,7 @@ class UpvoteView extends Component {
}; };
_upvoteContent = async () => { _upvoteContent = async () => {
const { currentAccount, content } = this.props; const { currentAccount, author, permlink } = this.props;
const { sliderValue } = this.state; const { sliderValue } = this.state;
this.setState({ this.setState({
@ -70,25 +77,26 @@ class UpvoteView extends Component {
}); });
const digitPinCode = await getDigitPinCode(); const digitPinCode = await getDigitPinCode();
const postingKey = decryptKey(currentAccount.realm_object.postingKey, digitPinCode); const postingKey = decryptKey(currentAccount.local.postingKey, digitPinCode);
const _weight = sliderValue ? (sliderValue * 100).toFixed(0) * 100 : 0;
upvote( upvote(
{ {
voter: currentAccount && currentAccount.username, voter: currentAccount && currentAccount.username,
author: content && content.author, author,
permlink: content && content.permlink, permlink,
weight: sliderValue ? (sliderValue * 100).toFixed(0) * 100 : 0, weight: _weight,
}, },
postingKey, postingKey,
) )
.then((res) => { .then(() => {
this.setState({ this.setState({
isVoted: !!sliderValue, isVoted: !!sliderValue,
isVoting: false, isVoting: false,
}); });
}) })
.catch((err) => { .catch((err) => {
alert(err); Alert.alert('Failed!', err);
this.setState({ this.setState({
isVoted: false, isVoted: false,
isVoting: false, isVoting: false,
@ -97,10 +105,17 @@ class UpvoteView extends Component {
}; };
render() { render() {
const { isLoggedIn, isShowPayoutValue, content } = this.props; const { isLoggedIn, isShowPayoutValue, pendingPayoutValue } = this.props;
const { const {
isVoting, isModalVisible, amount, sliderValue, isVoted, isVoting, amount, sliderValue, isVoted,
} = this.state; } = this.state;
let iconName = 'ios-arrow-dropup';
let iconType;
if (isVoted) {
iconName = 'upcircle';
iconType = 'AntDesign';
}
const _percent = `${(sliderValue * 100).toFixed(0)}%`; const _percent = `${(sliderValue * 100).toFixed(0)}%`;
const _amount = `$${amount}`; const _amount = `$${amount}`;
@ -124,14 +139,14 @@ class UpvoteView extends Component {
<Icon <Icon
style={[styles.upvoteIcon]} style={[styles.upvoteIcon]}
active={!isLoggedIn} active={!isLoggedIn}
iconType={isVoted && isLoggedIn && 'AntDesign'} iconType={iconType}
name={isVoted && isLoggedIn ? 'upcircle' : 'ios-arrow-dropup'} name={iconName}
/> />
{isShowPayoutValue && ( {isShowPayoutValue && (
<Text style={styles.payoutValue}> <Text style={styles.payoutValue}>
$ $
{' '} {' '}
{content && content.pending_payout_value} {pendingPayoutValue}
</Text> </Text>
)} )}
</Fragment> </Fragment>
@ -163,8 +178,8 @@ class UpvoteView extends Component {
size={20} size={20}
style={[styles.upvoteIcon, { color: '#007ee5' }]} style={[styles.upvoteIcon, { color: '#007ee5' }]}
active={!isLoggedIn} active={!isLoggedIn}
iconType="AntDesign" iconType={iconType}
name={isVoted ? 'upcircle' : 'upcircleo'} name={iconName}
/> />
)} )}
</TouchableOpacity> </TouchableOpacity>

View File

@ -53,7 +53,7 @@ export const Login = (username, password) => {
const jsonMetadata = JSON.parse(account.json_metadata); const jsonMetadata = JSON.parse(account.json_metadata);
if (Object.keys(jsonMetadata).length !== 0) { if (Object.keys(jsonMetadata).length !== 0) {
avatar = jsonMetadata.profile.profile_image; avatar = jsonMetadata.profile.avatar;
} }
if (loginFlag) { if (loginFlag) {
const userData = { const userData = {
@ -93,7 +93,7 @@ export const loginWithSC2 = async (accessToken) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const jsonMetadata = JSON.parse(account.json_metadata); const jsonMetadata = JSON.parse(account.json_metadata);
if (Object.keys(jsonMetadata).length !== 0) { if (Object.keys(jsonMetadata).length !== 0) {
avatar = jsonMetadata.profile.profile_image; avatar = jsonMetadata.profile.avatar;
} }
const userData = { const userData = {

View File

@ -88,7 +88,7 @@ export const getUser = async (user) => {
); );
account[0].about = account[0].json_metadata && JSON.parse(account[0].json_metadata); account[0].about = account[0].json_metadata && JSON.parse(account[0].json_metadata);
account[0].profile_image = getAvatar(account[0].about); account[0].avatar = getAvatar(account[0].about);
account[0].display_name = getName(account[0].about); account[0].display_name = getName(account[0].about);
return account[0]; return account[0];
@ -238,11 +238,11 @@ export const getPosts = async (by, query, user) => {
} }
}; };
export const getPostsSummary = async (by, query, currentUser) => { export const getPostsSummary = async (by, query, currentUserName) => {
try { try {
let posts = await client.database.getDiscussions(by, query); let posts = await client.database.getDiscussions(by, query);
posts = await parsePostsSummary(posts, currentUser); posts = await parsePostsSummary(posts, currentUserName);
return posts; return posts;
} catch (error) { } catch (error) {
return error; return error;
@ -263,13 +263,13 @@ export const getUserComments = async (query) => {
* @method getUser get user data * @method getUser get user data
* @param user post author * @param user post author
* @param permlink post permlink * @param permlink post permlink
* @param currentUserName active accounts username
*/ */
export const getPost = async (user, permlink, currentUser) => { export const getPost = async (author, permlink, currentUserName) => {
try { try {
let posts = await client.database.call('get_content', [user, permlink]); const post = await client.database.call('get_content', [author, permlink]);
posts = await parsePost(posts, user, currentUser); return await parsePost(post, currentUserName);
return posts;
} catch (error) { } catch (error) {
return error; return error;
} }
@ -640,7 +640,7 @@ export const postComment = (
opArray.push(e); opArray.push(e);
} }
const key = decryptKey(account.realm_object.postingKey, digitPinCode); const key = decryptKey(account.local.postingKey, digitPinCode);
const privateKey = PrivateKey.fromString(key); const privateKey = PrivateKey.fromString(key);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -657,7 +657,7 @@ export const postComment = (
export const reblog = async (account, author, permlink) => { export const reblog = async (account, author, permlink) => {
const pin = await getDigitPinCode(); const pin = await getDigitPinCode();
const key = decryptKey(account.realm_object.postingKey, pin); const key = decryptKey(account.local.postingKey, pin);
const privateKey = PrivateKey.fromString(key); const privateKey = PrivateKey.fromString(key);
const follower = account.name; const follower = account.name;

View File

@ -9,6 +9,7 @@ import {
SET_LANGUAGE, SET_LANGUAGE,
IS_NOTIFICATION_OPEN, IS_NOTIFICATION_OPEN,
IS_DARK_THEME, IS_DARK_THEME,
IS_LOGIN_DONE,
} from '../constants/constants'; } from '../constants/constants';
export const login = () => ({ export const login = () => ({
@ -19,6 +20,10 @@ export const logout = () => ({
type: LOGOUT, type: LOGOUT,
}); });
export const isLoginDone = () => ({
type: IS_LOGIN_DONE,
});
export const openPinCodeModal = () => ({ export const openPinCodeModal = () => ({
type: OPEN_PIN_CODE_MODAL, type: OPEN_PIN_CODE_MODAL,
}); });

View File

@ -7,6 +7,7 @@ export const LOGIN = 'LOGIN';
export const LOGOUT = 'LOGOUT'; export const LOGOUT = 'LOGOUT';
export const LOGOUT_SUCCESS = 'LOGOUT_SUCCESS'; export const LOGOUT_SUCCESS = 'LOGOUT_SUCCESS';
export const LOGOUT_FAIL = 'LOGOUT_FAIL'; export const LOGOUT_FAIL = 'LOGOUT_FAIL';
export const IS_LOGIN_DONE = 'IS_LOGIN_DONE';
export const ADD_OTHER_ACCOUNT = 'ADD_OTHER_ACCOUNT'; export const ADD_OTHER_ACCOUNT = 'ADD_OTHER_ACCOUNT';
export const UPDATE_CURRENT_ACCOUNT = 'UPDATE_CURRENT_ACCOUNT'; export const UPDATE_CURRENT_ACCOUNT = 'UPDATE_CURRENT_ACCOUNT';

View File

@ -9,6 +9,7 @@ import {
SET_LANGUAGE, SET_LANGUAGE,
IS_NOTIFICATION_OPEN, IS_NOTIFICATION_OPEN,
IS_DARK_THEME, IS_DARK_THEME,
IS_LOGIN_DONE,
} from '../constants/constants'; } from '../constants/constants';
const initialState = { const initialState = {
@ -21,6 +22,7 @@ const initialState = {
currency: 'usd', currency: 'usd',
api: 'api.steemit.com', api: 'api.steemit.com',
isDarkTheme: false, isDarkTheme: false,
isLoginDone: false,
}; };
export default function (state = initialState, action) { export default function (state = initialState, action) {
@ -30,6 +32,11 @@ export default function (state = initialState, action) {
...state, ...state,
isLoggedIn: true, isLoggedIn: true,
}; };
case IS_LOGIN_DONE:
return {
...state,
isLoginDone: true,
};
case LOGOUT: case LOGOUT:
return { return {
...state, ...state,

View File

@ -29,13 +29,14 @@ import {
} from '../../../redux/actions/accountAction'; } from '../../../redux/actions/accountAction';
import { import {
activeApplication, activeApplication,
isDarkTheme,
isLoginDone,
isNotificationOpen,
login, login,
openPinCodeModal, openPinCodeModal,
setLanguage,
isNotificationOpen,
setCurrency,
setApi, setApi,
isDarkTheme, setCurrency,
setLanguage,
} from '../../../redux/actions/applicationActions'; } from '../../../redux/actions/applicationActions';
// Container // Container
@ -51,54 +52,62 @@ class ApplicationContainer extends Component {
}; };
} }
componentDidMount = () => { componentDidMount = async () => {
this._getUserData(); await this._getUserData();
this._getSettings(); this._getSettings();
}; };
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
const { isDarkTheme, selectedLanguage } = this.props; const { isDarkTheme: _isDarkTheme, selectedLanguage } = this.props;
if (isDarkTheme !== nextProps.isDarkTheme || selectedLanguage !== nextProps.selectedLanguage) { if (_isDarkTheme !== nextProps.isDarkTheme || selectedLanguage !== nextProps.selectedLanguage) {
this.setState({ isRenderRequire: false }, () => this.setState({ isRenderRequire: true })); this.setState({ isRenderRequire: false }, () => this.setState({ isRenderRequire: true }));
} }
} }
_getUserData = () => { _getUserData = async () => {
const { dispatch } = this.props; const { dispatch } = this.props;
let realmData;
getAuthStatus().then((res) => { await getAuthStatus().then((res) => {
if (res.isLoggedIn) { if (res.isLoggedIn) {
getUserData().then((response) => { getUserData().then((response) => {
if (response.length > 0) { if (response.length > 0) {
realmData = response;
response.forEach((accountData) => { response.forEach((accountData) => {
dispatch( dispatch(
addOtherAccount({ username: accountData.username, avatar: accountData.avatar }), addOtherAccount({ username: accountData.username, avatar: accountData.avatar }),
); );
}); });
getUser(response[response.length - 1].username)
.then((accountData) => {
const realmObject = response[response.length - 1];
accountData.realm_object = realmObject;
dispatch(login());
dispatch(updateCurrentAccount(accountData));
dispatch(activeApplication());
if (__DEV__ === false) {
dispatch(openPinCodeModal());
}
this._connectNotificationServer(accountData.name);
this._setPushToken(accountData.name);
})
.catch((err) => {
alert(err);
});
} }
}); });
} else {
dispatch(activeApplication());
} }
}); });
if (realmData) {
await getUser(realmData[realmData.length - 1].username)
.then((accountData) => {
dispatch(login());
const realmObject = realmData[realmData.length - 1];
accountData.local = realmObject;
dispatch(updateCurrentAccount(accountData));
// If in dev mode pin code does not show
if (__DEV__ === false) {
dispatch(openPinCodeModal());
}
this._connectNotificationServer(accountData.name);
this._setPushToken(accountData.name);
})
.catch((err) => {
alert(err);
});
}
dispatch(activeApplication());
dispatch(isLoginDone());
}; };
_getSettings = () => { _getSettings = () => {

View File

@ -138,7 +138,7 @@ class EditorContainer extends Component {
// For new image api // For new image api
// const { currentAccount } = this.props; // const { currentAccount } = this.props;
// const digitPinCode = await getDigitPinCode(); // const digitPinCode = await getDigitPinCode();
// const privateKey = decryptKey(currentAccount.realm_object.postingKey, digitPinCode); // const privateKey = decryptKey(currentAccount.local.postingKey, digitPinCode);
// const sign = generateSignature(media, privateKey); // const sign = generateSignature(media, privateKey);
// const data = new Buffer(media.data, 'base64'); // const data = new Buffer(media.data, 'base64');
}; };
@ -208,7 +208,7 @@ class EditorContainer extends Component {
const permlink = generatePermlink(fields.title); const permlink = generatePermlink(fields.title);
const digitPinCode = await getDigitPinCode(); const digitPinCode = await getDigitPinCode();
const postingKey = decryptKey(currentAccount.realm_object.postingKey, digitPinCode); const postingKey = decryptKey(currentAccount.local.postingKey, digitPinCode);
const post = { const post = {
...fields, ...fields,

View File

@ -1,22 +1,14 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
// Services and Actions
// Middleware
// Constants
// Utilities
// Component // Component
import { HomeScreen } from '..'; import { HomeScreen } from '..';
/* /*
* Props Name Description Value * Props Name Description Value
*@props --> props name here description here Value Type Here *@props --> props name here description here Value Type Here
* *
*/ */
class HomeContainer extends Component { class HomeContainer extends Component {
constructor(props) { constructor(props) {
@ -29,12 +21,22 @@ class HomeContainer extends Component {
// Component Functions // Component Functions
render() { render() {
return <HomeScreen {...this.props} />; const { isLoggedIn, isLoginDone, currentAccount } = this.props;
return (
<HomeScreen
isLoggedIn={isLoggedIn}
isLoginDone={isLoginDone}
currentAccount={currentAccount}
/>
);
} }
} }
const mapStateToProps = state => ({ const mapStateToProps = state => ({
isLoggedIn: state.application.isLoggedIn, isLoggedIn: state.application.isLoggedIn,
isLoginDone: state.application.isLoginDone,
currentAccount: state.account.currentAccount, currentAccount: state.account.currentAccount,
}); });

View File

@ -1,5 +1,5 @@
import React, { PureComponent, Fragment } from 'react'; import React, { PureComponent, Fragment } from 'react';
import { View, Alert } from 'react-native'; import { View } from 'react-native';
import ScrollableTabView from '@esteemapp/react-native-scrollable-tab-view'; import ScrollableTabView from '@esteemapp/react-native-scrollable-tab-view';
import { injectIntl } from 'react-intl'; import { injectIntl } from 'react-intl';
@ -20,7 +20,7 @@ class HomeScreen extends PureComponent {
render() { render() {
const { const {
componentId, isLoggedIn, currentAccount, intl, currentAccount, intl, isLoggedIn, isLoginDone,
} = this.props; } = this.props;
const _filterOptions = [ const _filterOptions = [
'FEED', 'FEED',
@ -33,12 +33,17 @@ class HomeScreen extends PureComponent {
'COMMENTS', 'COMMENTS',
'PAYOUT', 'PAYOUT',
]; ];
let tag;
if (isLoginDone && !isLoggedIn) {
tag = 'esteemapp';
}
return ( return (
<Fragment> <Fragment>
<Header /> <Header />
<View style={styles.container} key="overlay"> <View style={styles.container}>
<ScrollableTabView <ScrollableTabView
style={styles.tabView} style={styles.tabView}
renderTabBar={() => ( renderTabBar={() => (
@ -59,10 +64,7 @@ class HomeScreen extends PureComponent {
<Posts <Posts
filterOptions={_filterOptions} filterOptions={_filterOptions}
getFor="feed" getFor="feed"
tag={isLoggedIn ? currentAccount.name : 'esteemapp'} tag={tag || currentAccount.username}
user={currentAccount}
isLoggedIn={isLoggedIn}
componentId={componentId}
/> />
</View> </View>
<View <View
@ -71,13 +73,7 @@ class HomeScreen extends PureComponent {
})} })}
style={styles.tabbarItem} style={styles.tabbarItem}
> >
<Posts <Posts filterOptions={_filterOptions} getFor="trending" />
filterOptions={_filterOptions}
getFor="trending"
user={currentAccount}
isLoggedIn={isLoggedIn}
componentId={componentId}
/>
</View> </View>
</ScrollableTabView> </ScrollableTabView>
</View> </View>

View File

@ -132,7 +132,7 @@ class PinCodeContainer extends Component {
setPinCode={this._setPinCode} setPinCode={this._setPinCode}
showForgotButton={isExistUser} showForgotButton={isExistUser}
username={currentAccount ? currentAccount.name : 'unknow'} username={currentAccount ? currentAccount.name : 'unknow'}
avatar={currentAccount.profile_image} avatar={currentAccount.avatar}
intl={intl} intl={intl}
/> />
); );

View File

@ -27,6 +27,7 @@ export default EStyleSheet.create({
informationView: { informationView: {
flex: 1, flex: 1,
alignItems: 'center', alignItems: 'center',
color: '$primaryBlack',
}, },
animatedView: { animatedView: {
flex: 1, flex: 1,

View File

@ -1,15 +1,9 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
// import { connect } from 'react-redux'; import { connect } from 'react-redux';
// Services and Actions // Services and Actions
import { getUserData, getAuthStatus } from '../../../realm/realm'; import { getPost } from '../../../providers/steem/dsteem';
import { getPost, getUser } from '../../../providers/steem/dsteem';
// Middleware
// Constants
// Utilities
// Component // Component
import { PostScreen } from '..'; import { PostScreen } from '..';
@ -25,25 +19,23 @@ class PostContainer extends Component {
this.state = { this.state = {
post: null, post: null,
error: null, error: null,
currentUser: null,
}; };
} }
// Component Life Cycle Functions // Component Life Cycle Functions
componentDidMount() { async componentDidMount() {
const { navigation } = this.props; const { navigation } = this.props;
const { author, permlink } = navigation.state && navigation.state.params; const { author, permlink } = navigation.state && navigation.state.params;
this._loadPost(author, permlink); await this._loadPost(author, permlink);
this._getUser();
} }
// Component Functions // Component Functions
_loadPost = (author, permlink) => { _loadPost = async (author, permlink) => {
const { currentUser } = this.state; const { currentAccount } = this.props;
// TODO: get from redux for cureentUser
getPost(author, permlink, currentUser && currentUser.name) await getPost(author, permlink, currentAccount && currentAccount.name)
.then((result) => { .then((result) => {
if (result) { if (result) {
this.setState({ post: result }); this.setState({ post: result });
@ -54,33 +46,16 @@ class PostContainer extends Component {
}); });
}; };
async _getUser() {
let _currentUser;
let userData;
let isLoggedIn;
await getAuthStatus().then((res) => {
isLoggedIn = res.isLoggedIn;
});
if (isLoggedIn) {
await getUserData().then((res) => {
_currentUser = Array.from(res);
});
userData = _currentUser && (await getUser(_currentUser[0].username));
await this.setState({
currentUser: userData,
});
}
}
render() { render() {
const { post, error, currentUser } = this.state; const { currentAccount } = this.props;
const { post, error } = this.state;
return <PostScreen currentUser={currentUser} post={post} error={error} />; return <PostScreen currentAccount={currentAccount} post={post} error={error} />;
} }
} }
export default PostContainer; const mapStateToProps = state => ({
currentAccount: state.account.currentAccount,
});
export default connect(mapStateToProps)(PostContainer);

View File

@ -23,7 +23,7 @@ class PostScreen extends Component {
// Component Functions // Component Functions
render() { render() {
const { post, currentUser } = this.props; const { post, currentAccount } = this.props;
return ( return (
<Fragment> <Fragment>
@ -33,7 +33,7 @@ class PostScreen extends Component {
content={post} content={post}
dropdownComponent={<PostDropdown content={post} />} dropdownComponent={<PostDropdown content={post} />}
/> />
<PostDisplay post={post} currentUser={currentUser} /> <PostDisplay post={post} currentAccount={currentAccount} />
</Fragment> </Fragment>
); );
} }

View File

@ -30,16 +30,15 @@ class ProfileContainer extends Component {
comments: [], comments: [],
follows: {}, follows: {},
isFollowing: false, isFollowing: false,
isLoading: false,
isMuted: false, isMuted: false,
isProfileLoading: false, isProfileLoading: false,
isReady: false, isReady: false,
isReverseHeader: false, isReverseHeader: !!(props.navigation.state && props.navigation.state.params),
user: null, user: null,
}; };
} }
componentDidMount() { componentDidMount = () => {
const { navigation, isLoggedIn, currentAccount } = this.props; const { navigation, isLoggedIn, currentAccount } = this.props;
const selectedUser = navigation.state && navigation.state.params; const selectedUser = navigation.state && navigation.state.params;
@ -48,10 +47,13 @@ class ProfileContainer extends Component {
return; return;
} }
this._loadProfile(selectedUser ? selectedUser.username : currentAccount.name); if (selectedUser) {
this._loadProfile(selectedUser.username);
this.setState({ isReverseHeader: !!selectedUser }); this.setState({ isReverseHeader: true });
} } else {
this._loadProfile(currentAccount.name);
}
};
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
const { navigation } = this.props; const { navigation } = this.props;
@ -73,7 +75,6 @@ class ProfileContainer extends Component {
this.setState({ this.setState({
isReady: true, isReady: true,
comments: result, comments: result,
isLoading: false,
}); });
}) })
.catch((err) => {}); .catch((err) => {});
@ -84,7 +85,7 @@ class ProfileContainer extends Component {
const { currentAccount } = this.props; const { currentAccount } = this.props;
const digitPinCode = await getDigitPinCode(); const digitPinCode = await getDigitPinCode();
const privateKey = decryptKey(currentAccount.realm_object.postingKey, digitPinCode); const privateKey = decryptKey(currentAccount.local.postingKey, digitPinCode);
this.setState({ this.setState({
isProfileLoading: true, isProfileLoading: true,
@ -102,7 +103,7 @@ class ProfileContainer extends Component {
const { currentAccount } = this.props; const { currentAccount } = this.props;
const digitPinCode = await getDigitPinCode(); const digitPinCode = await getDigitPinCode();
const privateKey = decryptKey(currentAccount.realm_object.postingKey, digitPinCode); const privateKey = decryptKey(currentAccount.local.postingKey, digitPinCode);
this.setState({ this.setState({
isProfileLoading: true, isProfileLoading: true,
@ -250,7 +251,6 @@ class ProfileContainer extends Component {
isProfileLoading, isProfileLoading,
isFollowing, isFollowing,
isMuted, isMuted,
isLoading,
isReady, isReady,
isReverseHeader, isReverseHeader,
user, user,
@ -270,7 +270,6 @@ class ProfileContainer extends Component {
handleOnFollowsPress={this._handleFollowsPress} handleOnFollowsPress={this._handleFollowsPress}
isDarkTheme={isDarkTheme} isDarkTheme={isDarkTheme}
isFollowing={isFollowing} isFollowing={isFollowing}
isLoading={isLoading}
isLoggedIn={isLoggedIn} isLoggedIn={isLoggedIn}
isMuted={isMuted} isMuted={isMuted}
isProfileLoading={isProfileLoading} isProfileLoading={isProfileLoading}

View File

@ -37,7 +37,6 @@ class ProfileScreen extends Component {
intl, intl,
isDarkTheme, isDarkTheme,
isFollowing, isFollowing,
isLoading,
isLoggedIn, isLoggedIn,
isMuted, isMuted,
isProfileLoading, isProfileLoading,
@ -47,9 +46,7 @@ class ProfileScreen extends Component {
username, username,
} = this.props; } = this.props;
let _about; let _about;
let avatar;
let coverImage; let coverImage;
let name;
let location; let location;
let website; let website;
let votingPower; let votingPower;
@ -67,14 +64,12 @@ class ProfileScreen extends Component {
if (about) { if (about) {
_about = about.about; _about = about.about;
coverImage = about.cover_image; coverImage = about.cover_image;
avatar = about.profile_image;
location = about.location; location = about.location;
website = about.website; website = about.website;
name = about.name;
} }
return ( return (
<Fragment> <Fragment>
<Header user={user} isReverse={isReverseHeader} /> <Header selectedUser={user} isReverse={isReverseHeader} />
<View style={styles.container}> <View style={styles.container}>
{!isReady ? ( {!isReady ? (
<ProfileSummaryPlaceHolder /> <ProfileSummaryPlaceHolder />
@ -136,11 +131,8 @@ class ProfileScreen extends Component {
'FOLLOWS', 'FOLLOWS',
'REBLOGS', 'REBLOGS',
]} ]}
isLoginMust
getFor="blog" getFor="blog"
tag={username} tag={username}
user={user && user}
isLoggedIn={isLoggedIn}
/> />
)} )}
</View> </View>

View File

@ -52,7 +52,7 @@ export const parsePosts = (posts, user) => {
return posts; return posts;
}; };
export const parsePostsSummary = (posts, currentUser) => { export const parsePostsSummary = (posts, currentUserName) => {
posts.map((post) => { posts.map((post) => {
post.json_metadata = JSON.parse(post.json_metadata); post.json_metadata = JSON.parse(post.json_metadata);
post.json_metadata.image ? (post.image = post.json_metadata.image[0]) : null; post.json_metadata.image ? (post.image = post.json_metadata.image[0]) : null;
@ -64,7 +64,8 @@ export const parsePostsSummary = (posts, currentUser) => {
post.body = markDown2Html(post.body); post.body = markDown2Html(post.body);
post.summary = getPostSummary(post.body, 100); post.summary = getPostSummary(post.body, 100);
post.raw_body = post.body; post.raw_body = post.body;
post.is_voted = false; post.is_voted = isVoted(post.active_votes, currentUserName);
const totalPayout = parseFloat(post.pending_payout_value) const totalPayout = parseFloat(post.pending_payout_value)
+ parseFloat(post.total_payout_value) + parseFloat(post.total_payout_value)
@ -74,10 +75,7 @@ export const parsePostsSummary = (posts, currentUser) => {
const ratio = totalPayout / voteRshares; const ratio = totalPayout / voteRshares;
if (post && post.active_votes) { if (post && post.active_votes) {
for (const i in post.active_votes) { for (const i in post.active_votes) {
if (post.active_votes[i].voter === currentUser && post.active_votes[i].percent > 0) { post.vote_perecent = post.active_votes[i].voter === currentUserName ? post.active_votes[i].percent : null;
post.is_voted = true;
}
post.vote_perecent = post.active_votes[i].voter === currentUser ? post.active_votes[i].percent : null;
post.active_votes[i].value = (post.active_votes[i].rshares * ratio).toFixed(2); post.active_votes[i].value = (post.active_votes[i].rshares * ratio).toFixed(2);
post.active_votes[i].reputation = getReputation(post.active_votes[i].reputation); post.active_votes[i].reputation = getReputation(post.active_votes[i].reputation);
post.active_votes[i].percent = post.active_votes[i].percent / 100; post.active_votes[i].percent = post.active_votes[i].percent / 100;
@ -92,7 +90,7 @@ export const parsePostsSummary = (posts, currentUser) => {
return posts; return posts;
}; };
export const parsePost = (post, currentUser) => { export const parsePost = (post, currentUserName) => {
post.json_metadata = JSON.parse(post.json_metadata); post.json_metadata = JSON.parse(post.json_metadata);
post.json_metadata.image ? (post.image = post.json_metadata.image[0]) : ''; post.json_metadata.image ? (post.image = post.json_metadata.image[0]) : '';
post.pending_payout_value = parseFloat(post.pending_payout_value).toFixed(2); post.pending_payout_value = parseFloat(post.pending_payout_value).toFixed(2);
@ -110,12 +108,9 @@ export const parsePost = (post, currentUser) => {
const voteRshares = post.active_votes.reduce((a, b) => a + parseFloat(b.rshares), 0); const voteRshares = post.active_votes.reduce((a, b) => a + parseFloat(b.rshares), 0);
const ratio = totalPayout / voteRshares; const ratio = totalPayout / voteRshares;
post.is_voted = false; post.is_voted = isVoted(post.active_votes, currentUserName);
for (const i in post.active_votes) { for (const i in post.active_votes) {
if (post.active_votes[i].voter === currentUser && post.active_votes[i].percent > 0) {
post.is_voted = true;
}
post.active_votes[i].value = (post.active_votes[i].rshares * ratio).toFixed(2); post.active_votes[i].value = (post.active_votes[i].rshares * ratio).toFixed(2);
post.active_votes[i].reputation = getReputation(post.active_votes[i].reputation); post.active_votes[i].reputation = getReputation(post.active_votes[i].reputation);
post.active_votes[i].avatar = `https://steemitimages.com/u/${ post.active_votes[i].avatar = `https://steemitimages.com/u/${
@ -123,16 +118,11 @@ export const parsePost = (post, currentUser) => {
}/avatar/small`; }/avatar/small`;
} }
if (post.active_votes.length > 2) {
post.top_likers = [
post.active_votes[0].voter,
post.active_votes[1].voter,
post.active_votes[2].voter,
];
}
return post; return post;
}; };
const isVoted = (activeVotes, currentUserName) => activeVotes.some(v => v.voter === currentUserName && v.percent > 0);
export const protocolUrl2Obj = (url) => { export const protocolUrl2Obj = (url) => {
let urlPart = url.split('://')[1]; let urlPart = url.split('://')[1];