mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-24 22:03:21 +03:00
merged with master
This commit is contained in:
commit
e448d582b1
2
.gitignore
vendored
2
.gitignore
vendored
@ -60,3 +60,5 @@ config.js
|
||||
keystore/
|
||||
.env
|
||||
package-lock.json
|
||||
my-release-key.keystore
|
||||
gradle.properties
|
||||
|
@ -19,6 +19,7 @@ import com.facebook.react.ReactNativeHost;
|
||||
import com.facebook.react.ReactPackage;
|
||||
import com.facebook.react.shell.MainReactPackage;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
import com.facebook.react.BuildConfig;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -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";
|
||||
}
|
||||
}
|
@ -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
3
appcenter-post-build.sh
Normal file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
printf "Post-Build.sh\n"
|
@ -1,8 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
# 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 "%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"
|
||||
cat .env
|
||||
cat .env
|
||||
printf "\nEND OF .env\n"
|
Binary file not shown.
@ -36,7 +36,6 @@ class CommentsView extends Component {
|
||||
avatarSize,
|
||||
marginLeft,
|
||||
handleOnUserPress,
|
||||
currentUser,
|
||||
commentNumber,
|
||||
handleOnReplyPress,
|
||||
isProfilePreview,
|
||||
|
@ -29,9 +29,7 @@ class CommentsDisplayView extends Component {
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
currentUser, author, permlink, commentCount,
|
||||
} = this.props;
|
||||
const { author, permlink, commentCount } = this.props;
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
@ -44,7 +42,7 @@ class CommentsDisplayView extends Component {
|
||||
onDropdownSelect={this._handleOnDropdownSelect}
|
||||
/>
|
||||
<View style={{ padding: 16 }}>
|
||||
<Comments currentUser={currentUser} author={author} permlink={permlink} />
|
||||
<Comments author={author} permlink={permlink} />
|
||||
</View>
|
||||
</Fragment>
|
||||
)}
|
||||
|
@ -9,10 +9,13 @@ import { connect } from 'react-redux';
|
||||
// Constants
|
||||
|
||||
// Utilities
|
||||
import { getReputation } from '../../../utils/user';
|
||||
|
||||
// Component
|
||||
import { HeaderView } from '..';
|
||||
|
||||
const DEFAULT_IMAGE = require('../../../assets/avatar_default.png');
|
||||
|
||||
/*
|
||||
* Props Name Description Value
|
||||
*@props --> props name here description here Value Type Here
|
||||
@ -42,14 +45,37 @@ class HeaderContainer extends Component {
|
||||
};
|
||||
|
||||
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 (
|
||||
<HeaderView
|
||||
handleOnPressBackButton={this._handleOnPressBackButton}
|
||||
handleOpenDrawer={this._handleOpenDrawer}
|
||||
isLoggedIn={isLoggedIn}
|
||||
currentAccount={user || currentUser}
|
||||
{...this.props}
|
||||
isReverse={isReverse}
|
||||
isLoginDone={isLoginDone}
|
||||
avatar={avatar}
|
||||
displayName={displayName}
|
||||
userName={userName}
|
||||
reputation={reputation}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@ -57,7 +83,9 @@ class HeaderContainer extends Component {
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
isLoggedIn: state.application.isLoggedIn,
|
||||
currentUser: state.account.currentAccount,
|
||||
isLoginDone: state.application.isLoginDone,
|
||||
|
||||
currentAccount: state.account.currentAccount,
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps)(withNavigation(HeaderContainer));
|
||||
|
@ -1,14 +1,10 @@
|
||||
import React, { Component } from 'react';
|
||||
import {
|
||||
View, StatusBar, Text, SafeAreaView, TouchableOpacity,
|
||||
View, StatusBar, Text, SafeAreaView, TouchableOpacity, Image,
|
||||
} from 'react-native';
|
||||
import FastImage from 'react-native-fast-image';
|
||||
import LinearGradient from 'react-native-linear-gradient';
|
||||
import { injectIntl } from 'react-intl';
|
||||
|
||||
// Utils
|
||||
import { getReputation } from '../../../utils/user';
|
||||
|
||||
// Components
|
||||
import { SearchModal } from '../../searchModal';
|
||||
import { IconButton } from '../../iconButton';
|
||||
@ -42,18 +38,20 @@ class HeaderView extends Component {
|
||||
|
||||
render() {
|
||||
const {
|
||||
handleOpenDrawer,
|
||||
avatar,
|
||||
displayName,
|
||||
handleOnPressBackButton,
|
||||
handleOpenDrawer,
|
||||
hideStatusBar,
|
||||
isReverse,
|
||||
currentAccount,
|
||||
intl,
|
||||
isLoggedIn,
|
||||
isLoginDone,
|
||||
isReverse,
|
||||
reputation,
|
||||
userName,
|
||||
} = this.props;
|
||||
const { isSearchModalOpen } = this.state;
|
||||
const _reputation = getReputation(currentAccount.reputation);
|
||||
const _avatar = currentAccount.profile_image
|
||||
? { uri: currentAccount.profile_image }
|
||||
: DEFAULT_IMAGE;
|
||||
|
||||
return (
|
||||
<SafeAreaView style={[styles.container, isReverse && styles.containerReverse]}>
|
||||
{/* <StatusBar style={ { height: 20}} hidden={hideStatusBar} translucent /> */}
|
||||
@ -77,27 +75,27 @@ class HeaderView extends Component {
|
||||
isReverse ? styles.avatarButtonWrapperReverse : styles.avatarDefault,
|
||||
]}
|
||||
>
|
||||
<FastImage style={styles.avatar} source={_avatar} defaultSource={DEFAULT_IMAGE} />
|
||||
<Image style={styles.avatar} source={avatar} defaultSource={DEFAULT_IMAGE} />
|
||||
</LinearGradient>
|
||||
</TouchableOpacity>
|
||||
{currentAccount && currentAccount.name ? (
|
||||
{displayName || userName ? (
|
||||
<View style={styles.titleWrapper}>
|
||||
{currentAccount.display_name && (
|
||||
<Text style={styles.title}>{currentAccount.display_name}</Text>
|
||||
)}
|
||||
{displayName && <Text style={styles.title}>{displayName}</Text>}
|
||||
<Text style={styles.subTitle}>
|
||||
@
|
||||
{currentAccount.name}
|
||||
{`(${_reputation})`}
|
||||
{userName}
|
||||
{`(${reputation})`}
|
||||
</Text>
|
||||
</View>
|
||||
) : (
|
||||
<View style={styles.titleWrapper}>
|
||||
<Text style={styles.noAuthTitle}>
|
||||
{intl.formatMessage({
|
||||
id: 'header.title',
|
||||
})}
|
||||
</Text>
|
||||
{isLoginDone && !isLoggedIn && (
|
||||
<Text style={styles.noAuthTitle}>
|
||||
{intl.formatMessage({
|
||||
id: 'header.title',
|
||||
})}
|
||||
</Text>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
{isReverse && (
|
||||
|
@ -152,13 +152,14 @@ export default class MarkdownEditorView extends Component {
|
||||
iconType="FontAwesome"
|
||||
name="image"
|
||||
/>
|
||||
<DropdownButton
|
||||
{/* TODO: After alpha */}
|
||||
{/* <DropdownButton
|
||||
style={styles.dropdownStyle}
|
||||
options={['option1', 'option2', 'option3', 'option4']}
|
||||
iconName="md-more"
|
||||
iconStyle={styles.dropdownIconStyle}
|
||||
isHasChildIcon
|
||||
/>
|
||||
/> */}
|
||||
</View>
|
||||
</StickyBar>
|
||||
);
|
||||
|
@ -4,7 +4,6 @@ import {
|
||||
} from 'react-native';
|
||||
// import FastImage from 'react-native-fast-image';
|
||||
import { PostHeaderDescription } from '../../postElements';
|
||||
import { DropdownButton } from '../../dropdownButton';
|
||||
import { PostDropdown } from '../../postDropdown';
|
||||
import { Icon } from '../../icon';
|
||||
import { LineBreak } from '../../basicUIElements';
|
||||
@ -32,10 +31,10 @@ class PostCard extends Component {
|
||||
// Component Functions
|
||||
|
||||
_handleOnUserPress = () => {
|
||||
const { handleOnUserPress, content, user } = this.props;
|
||||
const { handleOnUserPress, content } = this.props;
|
||||
|
||||
if (handleOnUserPress && content && content.author !== user.name) {
|
||||
handleOnUserPress(content.author, content.author);
|
||||
if (handleOnUserPress && content) {
|
||||
handleOnUserPress(content.author);
|
||||
}
|
||||
};
|
||||
|
||||
@ -57,7 +56,7 @@ class PostCard extends Component {
|
||||
|
||||
render() {
|
||||
const {
|
||||
content, isLoggedIn, user, isHideImage,
|
||||
content, isHideImage,
|
||||
} = this.props;
|
||||
// const likersText = `@${content.top_likers[0]}, @${content.top_likers[1]}, @${
|
||||
// content.top_likers[2]
|
||||
@ -121,31 +120,6 @@ class PostCard extends Component {
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
<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>
|
||||
);
|
||||
}
|
||||
|
@ -53,13 +53,13 @@ class PostDisplayContainer extends Component {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { post, currentUser } = this.props;
|
||||
const { post, currentAccount } = this.props;
|
||||
|
||||
return (
|
||||
<PostDisplayView
|
||||
handleOnVotersPress={this._handleOnVotersPress}
|
||||
handleOnReplyPress={this._handleOnReplyPress}
|
||||
currentUser={currentUser}
|
||||
currentAccount={currentAccount}
|
||||
post={post}
|
||||
/>
|
||||
);
|
||||
|
@ -53,7 +53,7 @@ class PostDisplayView extends Component {
|
||||
_getTabBar = (isFixedFooter = false) => {
|
||||
const {
|
||||
post,
|
||||
currentUser,
|
||||
currentAccount,
|
||||
handleOnReplyPress,
|
||||
handleOnEditPress,
|
||||
handleOnVotersPress,
|
||||
@ -80,7 +80,7 @@ class PostDisplayView extends Component {
|
||||
iconType="FontAwesome"
|
||||
/>
|
||||
<View style={styles.stickyRightWrapper}>
|
||||
{post && currentUser && currentUser.name === post.author && (
|
||||
{post && currentAccount && currentAccount.name === post.author && (
|
||||
<IconButton
|
||||
iconStyle={styles.barIconRight}
|
||||
style={styles.barIconButton}
|
||||
@ -103,7 +103,7 @@ class PostDisplayView extends Component {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { post, currentUser } = this.props;
|
||||
const { post } = this.props;
|
||||
const { postHeight, scrollHeight, isLoadedComments } = this.state;
|
||||
|
||||
const isPostEnd = scrollHeight > postHeight;
|
||||
@ -145,7 +145,6 @@ class PostDisplayView extends Component {
|
||||
</View>
|
||||
{post && (isGetComment || isLoadedComments) && (
|
||||
<CommentsDisplay
|
||||
currentUser={currentUser}
|
||||
author={post.author}
|
||||
permlink={post.permlink}
|
||||
commentCount={post.children}
|
||||
|
@ -1,13 +1,15 @@
|
||||
import React, { Component } from 'react';
|
||||
import React, { Component, Fragment } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
// Component
|
||||
import { PostsView } from '..';
|
||||
import { PostCardPlaceHolder } from '../../basicUIElements';
|
||||
|
||||
/*
|
||||
* Props Name Description Value
|
||||
*@props --> props name here description here Value Type Here
|
||||
*
|
||||
*/
|
||||
* Props Name Description Value
|
||||
*@props --> props name here description here Value Type Here
|
||||
*
|
||||
*/
|
||||
|
||||
class PostsContainer extends Component {
|
||||
constructor(props) {
|
||||
@ -20,8 +22,29 @@ class PostsContainer extends Component {
|
||||
// Component Functions
|
||||
|
||||
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);
|
||||
|
@ -18,7 +18,6 @@ class PostsView extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
user: props.user || null,
|
||||
posts: [],
|
||||
startAuthor: '',
|
||||
startPermlink: '',
|
||||
@ -30,53 +29,42 @@ class PostsView extends Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { user, isLoggedIn, isLoginMust } = this.state;
|
||||
const isCanLoad = isLoginMust ? isLoggedIn : true;
|
||||
|
||||
isCanLoad && this._loadPosts(user);
|
||||
this._loadPosts();
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { user } = 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;
|
||||
_loadPosts = (filter = null) => {
|
||||
const { getFor, tag, currentAccountUsername } = this.props;
|
||||
let options;
|
||||
_getFor ? (options = { limit: 3 }) : (options = { tag: _tag || tag, limit: 3 });
|
||||
|
||||
if (user) {
|
||||
getPostsSummary(_getFor || getFor, options, user && user.name, isHideImage)
|
||||
.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);
|
||||
});
|
||||
if (!filter) {
|
||||
options = { tag, limit: 3 };
|
||||
} else {
|
||||
options = { limit: 3 };
|
||||
}
|
||||
|
||||
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 = () => {
|
||||
// TODO: merge above function with this func (after alpha).
|
||||
const {
|
||||
posts, startAuthor, startPermlink, user, isHideImage,
|
||||
posts, startAuthor, startPermlink,
|
||||
} = this.state;
|
||||
const { getFor, tag } = this.props;
|
||||
const { getFor, tag, currentAccountUsername } = this.props;
|
||||
|
||||
this.setState({ isLoading: true });
|
||||
|
||||
@ -88,8 +76,7 @@ class PostsView extends Component {
|
||||
start_author: startAuthor,
|
||||
start_permlink: startPermlink,
|
||||
},
|
||||
(user && user.name) || 'esteemapp',
|
||||
isHideImage,
|
||||
currentAccountUsername,
|
||||
).then((result) => {
|
||||
const _posts = result;
|
||||
_posts.shift();
|
||||
@ -102,14 +89,12 @@ class PostsView extends Component {
|
||||
};
|
||||
|
||||
_handleOnRefreshPosts = () => {
|
||||
const { user } = this.state;
|
||||
|
||||
this.setState(
|
||||
{
|
||||
refreshing: true,
|
||||
},
|
||||
() => {
|
||||
this._loadPosts(user);
|
||||
this._loadPosts();
|
||||
},
|
||||
);
|
||||
};
|
||||
@ -128,9 +113,8 @@ class PostsView extends Component {
|
||||
};
|
||||
|
||||
_handleOnDropdownSelect = (index) => {
|
||||
const { user } = this.state;
|
||||
this.setState({ isPostsLoading: true });
|
||||
this._loadPosts(user, null, filters[index]);
|
||||
this._loadPosts(filters[index]);
|
||||
};
|
||||
|
||||
_onRightIconPress = () => {
|
||||
@ -141,11 +125,9 @@ class PostsView extends Component {
|
||||
|
||||
render() {
|
||||
const {
|
||||
refreshing, posts, user, isPostsLoading, isHideImage,
|
||||
refreshing, posts, isPostsLoading, isHideImage,
|
||||
} = this.state;
|
||||
const {
|
||||
componentId, filterOptions, isLoggedIn, intl,
|
||||
} = this.props;
|
||||
const { componentId, filterOptions, intl } = this.props;
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
@ -160,18 +142,12 @@ class PostsView extends Component {
|
||||
onRightIconPress={this._onRightIconPress}
|
||||
/>
|
||||
)}
|
||||
{user && posts && posts.length > 0 && !isPostsLoading ? (
|
||||
{posts && posts.length > 0 && !isPostsLoading ? (
|
||||
<FlatList
|
||||
data={posts}
|
||||
showsVerticalScrollIndicator={false}
|
||||
renderItem={({ item }) => (
|
||||
<PostCard
|
||||
componentId={componentId}
|
||||
content={item}
|
||||
user={user}
|
||||
isLoggedIn={isLoggedIn}
|
||||
isHideImage={isHideImage}
|
||||
/>
|
||||
<PostCard componentId={componentId} content={item} isHideImage={isHideImage} />
|
||||
)}
|
||||
keyExtractor={(post, index) => index.toString()}
|
||||
onEndReached={this._loadMore}
|
||||
|
@ -4,7 +4,6 @@ import {
|
||||
} from 'react-native';
|
||||
import { injectIntl } from 'react-intl';
|
||||
import LinearGradient from 'react-native-linear-gradient';
|
||||
import FastImage from 'react-native-fast-image';
|
||||
|
||||
// Components
|
||||
import { Icon, IconButton } from '../..';
|
||||
@ -69,12 +68,8 @@ class SideMenuView extends Component {
|
||||
navigateToRoute, currentAccount, isLoggedIn, switchAccount, intl,
|
||||
} = this.props;
|
||||
const { menuItems, isAddAccountIconActive } = this.state;
|
||||
const _avatar = currentAccount.profile_image
|
||||
? { uri: currentAccount.profile_image }
|
||||
: DEFAULT_IMAGE;
|
||||
|
||||
console.log(_avatar);
|
||||
console.log(menuItems);
|
||||
const _avatar = currentAccount.avatar ? { uri: currentAccount.avatar } : DEFAULT_IMAGE;
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<LinearGradient
|
||||
|
@ -1,14 +1,6 @@
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
// Services and Actions
|
||||
|
||||
// Middleware
|
||||
|
||||
// Constants
|
||||
|
||||
// Utilities
|
||||
|
||||
// Component
|
||||
import { UpvoteView } from '..';
|
||||
|
||||
@ -29,7 +21,32 @@ class UpvoteContainer extends Component {
|
||||
// Component Functions
|
||||
|
||||
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}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React, { Component, Fragment } from 'react';
|
||||
import {
|
||||
View, TouchableOpacity, ActivityIndicator, Text,
|
||||
View, TouchableOpacity, ActivityIndicator, Text, Alert,
|
||||
} from 'react-native';
|
||||
import { Popover, PopoverController } from 'react-native-modal-popover';
|
||||
import Slider from 'react-native-slider';
|
||||
@ -28,16 +28,23 @@ class UpvoteView extends Component {
|
||||
this.state = {
|
||||
sliderValue: 0.0,
|
||||
isVoting: false,
|
||||
isVoted: props.content ? props.content.is_voted : false,
|
||||
amount: '0.00',
|
||||
isModalVisible: false,
|
||||
isVoted: props.isVoted,
|
||||
amount: '0.00000',
|
||||
};
|
||||
}
|
||||
|
||||
// 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 () => {
|
||||
const { currentAccount } = this.props;
|
||||
// Calculate total vesting shares
|
||||
@ -62,7 +69,7 @@ class UpvoteView extends Component {
|
||||
};
|
||||
|
||||
_upvoteContent = async () => {
|
||||
const { currentAccount, content } = this.props;
|
||||
const { currentAccount, author, permlink } = this.props;
|
||||
const { sliderValue } = this.state;
|
||||
|
||||
this.setState({
|
||||
@ -70,25 +77,26 @@ class UpvoteView extends Component {
|
||||
});
|
||||
|
||||
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(
|
||||
{
|
||||
voter: currentAccount && currentAccount.username,
|
||||
author: content && content.author,
|
||||
permlink: content && content.permlink,
|
||||
weight: sliderValue ? (sliderValue * 100).toFixed(0) * 100 : 0,
|
||||
author,
|
||||
permlink,
|
||||
weight: _weight,
|
||||
},
|
||||
postingKey,
|
||||
)
|
||||
.then((res) => {
|
||||
.then(() => {
|
||||
this.setState({
|
||||
isVoted: !!sliderValue,
|
||||
isVoting: false,
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
alert(err);
|
||||
Alert.alert('Failed!', err);
|
||||
this.setState({
|
||||
isVoted: false,
|
||||
isVoting: false,
|
||||
@ -97,10 +105,17 @@ class UpvoteView extends Component {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { isLoggedIn, isShowPayoutValue, content } = this.props;
|
||||
const { isLoggedIn, isShowPayoutValue, pendingPayoutValue } = this.props;
|
||||
const {
|
||||
isVoting, isModalVisible, amount, sliderValue, isVoted,
|
||||
isVoting, amount, sliderValue, isVoted,
|
||||
} = this.state;
|
||||
let iconName = 'ios-arrow-dropup';
|
||||
let iconType;
|
||||
|
||||
if (isVoted) {
|
||||
iconName = 'upcircle';
|
||||
iconType = 'AntDesign';
|
||||
}
|
||||
|
||||
const _percent = `${(sliderValue * 100).toFixed(0)}%`;
|
||||
const _amount = `$${amount}`;
|
||||
@ -124,14 +139,14 @@ class UpvoteView extends Component {
|
||||
<Icon
|
||||
style={[styles.upvoteIcon]}
|
||||
active={!isLoggedIn}
|
||||
iconType={isVoted && isLoggedIn && 'AntDesign'}
|
||||
name={isVoted && isLoggedIn ? 'upcircle' : 'ios-arrow-dropup'}
|
||||
iconType={iconType}
|
||||
name={iconName}
|
||||
/>
|
||||
{isShowPayoutValue && (
|
||||
<Text style={styles.payoutValue}>
|
||||
$
|
||||
{' '}
|
||||
{content && content.pending_payout_value}
|
||||
{pendingPayoutValue}
|
||||
</Text>
|
||||
)}
|
||||
</Fragment>
|
||||
@ -163,8 +178,8 @@ class UpvoteView extends Component {
|
||||
size={20}
|
||||
style={[styles.upvoteIcon, { color: '#007ee5' }]}
|
||||
active={!isLoggedIn}
|
||||
iconType="AntDesign"
|
||||
name={isVoted ? 'upcircle' : 'upcircleo'}
|
||||
iconType={iconType}
|
||||
name={iconName}
|
||||
/>
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
|
@ -53,7 +53,7 @@ export const Login = (username, password) => {
|
||||
|
||||
const jsonMetadata = JSON.parse(account.json_metadata);
|
||||
if (Object.keys(jsonMetadata).length !== 0) {
|
||||
avatar = jsonMetadata.profile.profile_image;
|
||||
avatar = jsonMetadata.profile.avatar;
|
||||
}
|
||||
if (loginFlag) {
|
||||
const userData = {
|
||||
@ -93,7 +93,7 @@ export const loginWithSC2 = async (accessToken) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const jsonMetadata = JSON.parse(account.json_metadata);
|
||||
if (Object.keys(jsonMetadata).length !== 0) {
|
||||
avatar = jsonMetadata.profile.profile_image;
|
||||
avatar = jsonMetadata.profile.avatar;
|
||||
}
|
||||
|
||||
const userData = {
|
||||
|
@ -88,7 +88,7 @@ export const getUser = async (user) => {
|
||||
);
|
||||
|
||||
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);
|
||||
|
||||
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 {
|
||||
let posts = await client.database.getDiscussions(by, query);
|
||||
|
||||
posts = await parsePostsSummary(posts, currentUser);
|
||||
posts = await parsePostsSummary(posts, currentUserName);
|
||||
return posts;
|
||||
} catch (error) {
|
||||
return error;
|
||||
@ -263,13 +263,13 @@ export const getUserComments = async (query) => {
|
||||
* @method getUser get user data
|
||||
* @param user post author
|
||||
* @param permlink post permlink
|
||||
* @param currentUserName active accounts username
|
||||
*/
|
||||
export const getPost = async (user, permlink, currentUser) => {
|
||||
export const getPost = async (author, permlink, currentUserName) => {
|
||||
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 posts;
|
||||
return await parsePost(post, currentUserName);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
@ -640,7 +640,7 @@ export const postComment = (
|
||||
opArray.push(e);
|
||||
}
|
||||
|
||||
const key = decryptKey(account.realm_object.postingKey, digitPinCode);
|
||||
const key = decryptKey(account.local.postingKey, digitPinCode);
|
||||
const privateKey = PrivateKey.fromString(key);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -657,7 +657,7 @@ export const postComment = (
|
||||
|
||||
export const reblog = async (account, author, permlink) => {
|
||||
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 follower = account.name;
|
||||
|
||||
|
@ -9,6 +9,7 @@ import {
|
||||
SET_LANGUAGE,
|
||||
IS_NOTIFICATION_OPEN,
|
||||
IS_DARK_THEME,
|
||||
IS_LOGIN_DONE,
|
||||
} from '../constants/constants';
|
||||
|
||||
export const login = () => ({
|
||||
@ -19,6 +20,10 @@ export const logout = () => ({
|
||||
type: LOGOUT,
|
||||
});
|
||||
|
||||
export const isLoginDone = () => ({
|
||||
type: IS_LOGIN_DONE,
|
||||
});
|
||||
|
||||
export const openPinCodeModal = () => ({
|
||||
type: OPEN_PIN_CODE_MODAL,
|
||||
});
|
||||
|
@ -7,6 +7,7 @@ export const LOGIN = 'LOGIN';
|
||||
export const LOGOUT = 'LOGOUT';
|
||||
export const LOGOUT_SUCCESS = 'LOGOUT_SUCCESS';
|
||||
export const LOGOUT_FAIL = 'LOGOUT_FAIL';
|
||||
export const IS_LOGIN_DONE = 'IS_LOGIN_DONE';
|
||||
|
||||
export const ADD_OTHER_ACCOUNT = 'ADD_OTHER_ACCOUNT';
|
||||
export const UPDATE_CURRENT_ACCOUNT = 'UPDATE_CURRENT_ACCOUNT';
|
||||
|
@ -9,6 +9,7 @@ import {
|
||||
SET_LANGUAGE,
|
||||
IS_NOTIFICATION_OPEN,
|
||||
IS_DARK_THEME,
|
||||
IS_LOGIN_DONE,
|
||||
} from '../constants/constants';
|
||||
|
||||
const initialState = {
|
||||
@ -21,6 +22,7 @@ const initialState = {
|
||||
currency: 'usd',
|
||||
api: 'api.steemit.com',
|
||||
isDarkTheme: false,
|
||||
isLoginDone: false,
|
||||
};
|
||||
|
||||
export default function (state = initialState, action) {
|
||||
@ -30,6 +32,11 @@ export default function (state = initialState, action) {
|
||||
...state,
|
||||
isLoggedIn: true,
|
||||
};
|
||||
case IS_LOGIN_DONE:
|
||||
return {
|
||||
...state,
|
||||
isLoginDone: true,
|
||||
};
|
||||
case LOGOUT:
|
||||
return {
|
||||
...state,
|
||||
|
@ -29,13 +29,14 @@ import {
|
||||
} from '../../../redux/actions/accountAction';
|
||||
import {
|
||||
activeApplication,
|
||||
isDarkTheme,
|
||||
isLoginDone,
|
||||
isNotificationOpen,
|
||||
login,
|
||||
openPinCodeModal,
|
||||
setLanguage,
|
||||
isNotificationOpen,
|
||||
setCurrency,
|
||||
setApi,
|
||||
isDarkTheme,
|
||||
setCurrency,
|
||||
setLanguage,
|
||||
} from '../../../redux/actions/applicationActions';
|
||||
|
||||
// Container
|
||||
@ -51,54 +52,62 @@ class ApplicationContainer extends Component {
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount = () => {
|
||||
this._getUserData();
|
||||
componentDidMount = async () => {
|
||||
await this._getUserData();
|
||||
this._getSettings();
|
||||
};
|
||||
|
||||
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 }));
|
||||
}
|
||||
}
|
||||
|
||||
_getUserData = () => {
|
||||
_getUserData = async () => {
|
||||
const { dispatch } = this.props;
|
||||
let realmData;
|
||||
|
||||
getAuthStatus().then((res) => {
|
||||
await getAuthStatus().then((res) => {
|
||||
if (res.isLoggedIn) {
|
||||
getUserData().then((response) => {
|
||||
if (response.length > 0) {
|
||||
realmData = response;
|
||||
|
||||
response.forEach((accountData) => {
|
||||
dispatch(
|
||||
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 = () => {
|
||||
|
@ -138,7 +138,7 @@ class EditorContainer extends Component {
|
||||
// For new image api
|
||||
// const { currentAccount } = this.props;
|
||||
// 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 data = new Buffer(media.data, 'base64');
|
||||
};
|
||||
@ -208,7 +208,7 @@ class EditorContainer extends Component {
|
||||
const permlink = generatePermlink(fields.title);
|
||||
const digitPinCode = await getDigitPinCode();
|
||||
|
||||
const postingKey = decryptKey(currentAccount.realm_object.postingKey, digitPinCode);
|
||||
const postingKey = decryptKey(currentAccount.local.postingKey, digitPinCode);
|
||||
|
||||
const post = {
|
||||
...fields,
|
||||
|
@ -1,22 +1,14 @@
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
// Services and Actions
|
||||
|
||||
// Middleware
|
||||
|
||||
// Constants
|
||||
|
||||
// Utilities
|
||||
|
||||
// Component
|
||||
import { HomeScreen } from '..';
|
||||
|
||||
/*
|
||||
* Props Name Description Value
|
||||
*@props --> props name here description here Value Type Here
|
||||
*
|
||||
*/
|
||||
* Props Name Description Value
|
||||
*@props --> props name here description here Value Type Here
|
||||
*
|
||||
*/
|
||||
|
||||
class HomeContainer extends Component {
|
||||
constructor(props) {
|
||||
@ -29,12 +21,22 @@ class HomeContainer extends Component {
|
||||
// Component Functions
|
||||
|
||||
render() {
|
||||
return <HomeScreen {...this.props} />;
|
||||
const { isLoggedIn, isLoginDone, currentAccount } = this.props;
|
||||
|
||||
return (
|
||||
<HomeScreen
|
||||
isLoggedIn={isLoggedIn}
|
||||
isLoginDone={isLoginDone}
|
||||
currentAccount={currentAccount}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
isLoggedIn: state.application.isLoggedIn,
|
||||
isLoginDone: state.application.isLoginDone,
|
||||
|
||||
currentAccount: state.account.currentAccount,
|
||||
});
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
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 { injectIntl } from 'react-intl';
|
||||
|
||||
@ -20,7 +20,7 @@ class HomeScreen extends PureComponent {
|
||||
|
||||
render() {
|
||||
const {
|
||||
componentId, isLoggedIn, currentAccount, intl,
|
||||
currentAccount, intl, isLoggedIn, isLoginDone,
|
||||
} = this.props;
|
||||
const _filterOptions = [
|
||||
'FEED',
|
||||
@ -33,12 +33,17 @@ class HomeScreen extends PureComponent {
|
||||
'COMMENTS',
|
||||
'PAYOUT',
|
||||
];
|
||||
let tag;
|
||||
|
||||
if (isLoginDone && !isLoggedIn) {
|
||||
tag = 'esteemapp';
|
||||
}
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<Header />
|
||||
|
||||
<View style={styles.container} key="overlay">
|
||||
<View style={styles.container}>
|
||||
<ScrollableTabView
|
||||
style={styles.tabView}
|
||||
renderTabBar={() => (
|
||||
@ -59,10 +64,7 @@ class HomeScreen extends PureComponent {
|
||||
<Posts
|
||||
filterOptions={_filterOptions}
|
||||
getFor="feed"
|
||||
tag={isLoggedIn ? currentAccount.name : 'esteemapp'}
|
||||
user={currentAccount}
|
||||
isLoggedIn={isLoggedIn}
|
||||
componentId={componentId}
|
||||
tag={tag || currentAccount.username}
|
||||
/>
|
||||
</View>
|
||||
<View
|
||||
@ -71,13 +73,7 @@ class HomeScreen extends PureComponent {
|
||||
})}
|
||||
style={styles.tabbarItem}
|
||||
>
|
||||
<Posts
|
||||
filterOptions={_filterOptions}
|
||||
getFor="trending"
|
||||
user={currentAccount}
|
||||
isLoggedIn={isLoggedIn}
|
||||
componentId={componentId}
|
||||
/>
|
||||
<Posts filterOptions={_filterOptions} getFor="trending" />
|
||||
</View>
|
||||
</ScrollableTabView>
|
||||
</View>
|
||||
|
@ -132,7 +132,7 @@ class PinCodeContainer extends Component {
|
||||
setPinCode={this._setPinCode}
|
||||
showForgotButton={isExistUser}
|
||||
username={currentAccount ? currentAccount.name : 'unknow'}
|
||||
avatar={currentAccount.profile_image}
|
||||
avatar={currentAccount.avatar}
|
||||
intl={intl}
|
||||
/>
|
||||
);
|
||||
|
@ -27,6 +27,7 @@ export default EStyleSheet.create({
|
||||
informationView: {
|
||||
flex: 1,
|
||||
alignItems: 'center',
|
||||
color: '$primaryBlack',
|
||||
},
|
||||
animatedView: {
|
||||
flex: 1,
|
||||
|
@ -1,15 +1,9 @@
|
||||
import React, { Component } from 'react';
|
||||
// import { connect } from 'react-redux';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
// Services and Actions
|
||||
import { getUserData, getAuthStatus } from '../../../realm/realm';
|
||||
import { getPost, getUser } from '../../../providers/steem/dsteem';
|
||||
import { getPost } from '../../../providers/steem/dsteem';
|
||||
|
||||
// Middleware
|
||||
|
||||
// Constants
|
||||
|
||||
// Utilities
|
||||
// Component
|
||||
import { PostScreen } from '..';
|
||||
|
||||
@ -25,25 +19,23 @@ class PostContainer extends Component {
|
||||
this.state = {
|
||||
post: null,
|
||||
error: null,
|
||||
currentUser: null,
|
||||
};
|
||||
}
|
||||
|
||||
// Component Life Cycle Functions
|
||||
componentDidMount() {
|
||||
async componentDidMount() {
|
||||
const { navigation } = this.props;
|
||||
const { author, permlink } = navigation.state && navigation.state.params;
|
||||
|
||||
this._loadPost(author, permlink);
|
||||
this._getUser();
|
||||
await this._loadPost(author, permlink);
|
||||
}
|
||||
|
||||
// Component Functions
|
||||
|
||||
_loadPost = (author, permlink) => {
|
||||
const { currentUser } = this.state;
|
||||
// TODO: get from redux for cureentUser
|
||||
getPost(author, permlink, currentUser && currentUser.name)
|
||||
_loadPost = async (author, permlink) => {
|
||||
const { currentAccount } = this.props;
|
||||
|
||||
await getPost(author, permlink, currentAccount && currentAccount.name)
|
||||
.then((result) => {
|
||||
if (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() {
|
||||
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);
|
||||
|
@ -23,7 +23,7 @@ class PostScreen extends Component {
|
||||
// Component Functions
|
||||
|
||||
render() {
|
||||
const { post, currentUser } = this.props;
|
||||
const { post, currentAccount } = this.props;
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
@ -33,7 +33,7 @@ class PostScreen extends Component {
|
||||
content={post}
|
||||
dropdownComponent={<PostDropdown content={post} />}
|
||||
/>
|
||||
<PostDisplay post={post} currentUser={currentUser} />
|
||||
<PostDisplay post={post} currentAccount={currentAccount} />
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
|
@ -30,16 +30,15 @@ class ProfileContainer extends Component {
|
||||
comments: [],
|
||||
follows: {},
|
||||
isFollowing: false,
|
||||
isLoading: false,
|
||||
isMuted: false,
|
||||
isProfileLoading: false,
|
||||
isReady: false,
|
||||
isReverseHeader: false,
|
||||
isReverseHeader: !!(props.navigation.state && props.navigation.state.params),
|
||||
user: null,
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
componentDidMount = () => {
|
||||
const { navigation, isLoggedIn, currentAccount } = this.props;
|
||||
const selectedUser = navigation.state && navigation.state.params;
|
||||
|
||||
@ -48,10 +47,13 @@ class ProfileContainer extends Component {
|
||||
return;
|
||||
}
|
||||
|
||||
this._loadProfile(selectedUser ? selectedUser.username : currentAccount.name);
|
||||
|
||||
this.setState({ isReverseHeader: !!selectedUser });
|
||||
}
|
||||
if (selectedUser) {
|
||||
this._loadProfile(selectedUser.username);
|
||||
this.setState({ isReverseHeader: true });
|
||||
} else {
|
||||
this._loadProfile(currentAccount.name);
|
||||
}
|
||||
};
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { navigation } = this.props;
|
||||
@ -73,7 +75,6 @@ class ProfileContainer extends Component {
|
||||
this.setState({
|
||||
isReady: true,
|
||||
comments: result,
|
||||
isLoading: false,
|
||||
});
|
||||
})
|
||||
.catch((err) => {});
|
||||
@ -84,7 +85,7 @@ class ProfileContainer extends Component {
|
||||
const { currentAccount } = this.props;
|
||||
const digitPinCode = await getDigitPinCode();
|
||||
|
||||
const privateKey = decryptKey(currentAccount.realm_object.postingKey, digitPinCode);
|
||||
const privateKey = decryptKey(currentAccount.local.postingKey, digitPinCode);
|
||||
|
||||
this.setState({
|
||||
isProfileLoading: true,
|
||||
@ -102,7 +103,7 @@ class ProfileContainer extends Component {
|
||||
const { currentAccount } = this.props;
|
||||
const digitPinCode = await getDigitPinCode();
|
||||
|
||||
const privateKey = decryptKey(currentAccount.realm_object.postingKey, digitPinCode);
|
||||
const privateKey = decryptKey(currentAccount.local.postingKey, digitPinCode);
|
||||
|
||||
this.setState({
|
||||
isProfileLoading: true,
|
||||
@ -250,7 +251,6 @@ class ProfileContainer extends Component {
|
||||
isProfileLoading,
|
||||
isFollowing,
|
||||
isMuted,
|
||||
isLoading,
|
||||
isReady,
|
||||
isReverseHeader,
|
||||
user,
|
||||
@ -270,7 +270,6 @@ class ProfileContainer extends Component {
|
||||
handleOnFollowsPress={this._handleFollowsPress}
|
||||
isDarkTheme={isDarkTheme}
|
||||
isFollowing={isFollowing}
|
||||
isLoading={isLoading}
|
||||
isLoggedIn={isLoggedIn}
|
||||
isMuted={isMuted}
|
||||
isProfileLoading={isProfileLoading}
|
||||
|
@ -37,7 +37,6 @@ class ProfileScreen extends Component {
|
||||
intl,
|
||||
isDarkTheme,
|
||||
isFollowing,
|
||||
isLoading,
|
||||
isLoggedIn,
|
||||
isMuted,
|
||||
isProfileLoading,
|
||||
@ -47,9 +46,7 @@ class ProfileScreen extends Component {
|
||||
username,
|
||||
} = this.props;
|
||||
let _about;
|
||||
let avatar;
|
||||
let coverImage;
|
||||
let name;
|
||||
let location;
|
||||
let website;
|
||||
let votingPower;
|
||||
@ -67,14 +64,12 @@ class ProfileScreen extends Component {
|
||||
if (about) {
|
||||
_about = about.about;
|
||||
coverImage = about.cover_image;
|
||||
avatar = about.profile_image;
|
||||
location = about.location;
|
||||
website = about.website;
|
||||
name = about.name;
|
||||
}
|
||||
return (
|
||||
<Fragment>
|
||||
<Header user={user} isReverse={isReverseHeader} />
|
||||
<Header selectedUser={user} isReverse={isReverseHeader} />
|
||||
<View style={styles.container}>
|
||||
{!isReady ? (
|
||||
<ProfileSummaryPlaceHolder />
|
||||
@ -136,11 +131,8 @@ class ProfileScreen extends Component {
|
||||
'FOLLOWS',
|
||||
'REBLOGS',
|
||||
]}
|
||||
isLoginMust
|
||||
getFor="blog"
|
||||
tag={username}
|
||||
user={user && user}
|
||||
isLoggedIn={isLoggedIn}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
|
@ -52,7 +52,7 @@ export const parsePosts = (posts, user) => {
|
||||
return posts;
|
||||
};
|
||||
|
||||
export const parsePostsSummary = (posts, currentUser) => {
|
||||
export const parsePostsSummary = (posts, currentUserName) => {
|
||||
posts.map((post) => {
|
||||
post.json_metadata = JSON.parse(post.json_metadata);
|
||||
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.summary = getPostSummary(post.body, 100);
|
||||
post.raw_body = post.body;
|
||||
post.is_voted = false;
|
||||
post.is_voted = isVoted(post.active_votes, currentUserName);
|
||||
|
||||
|
||||
const totalPayout = parseFloat(post.pending_payout_value)
|
||||
+ parseFloat(post.total_payout_value)
|
||||
@ -74,10 +75,7 @@ export const parsePostsSummary = (posts, currentUser) => {
|
||||
const ratio = totalPayout / voteRshares;
|
||||
if (post && 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.vote_perecent = post.active_votes[i].voter === currentUser ? post.active_votes[i].percent : null;
|
||||
post.vote_perecent = post.active_votes[i].voter === currentUserName ? post.active_votes[i].percent : null;
|
||||
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].percent = post.active_votes[i].percent / 100;
|
||||
@ -92,7 +90,7 @@ export const parsePostsSummary = (posts, currentUser) => {
|
||||
return posts;
|
||||
};
|
||||
|
||||
export const parsePost = (post, currentUser) => {
|
||||
export const parsePost = (post, currentUserName) => {
|
||||
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);
|
||||
@ -110,12 +108,9 @@ export const parsePost = (post, currentUser) => {
|
||||
|
||||
const voteRshares = post.active_votes.reduce((a, b) => a + parseFloat(b.rshares), 0);
|
||||
const ratio = totalPayout / voteRshares;
|
||||
post.is_voted = false;
|
||||
post.is_voted = isVoted(post.active_votes, currentUserName);
|
||||
|
||||
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].reputation = getReputation(post.active_votes[i].reputation);
|
||||
post.active_votes[i].avatar = `https://steemitimages.com/u/${
|
||||
@ -123,16 +118,11 @@ export const parsePost = (post, currentUser) => {
|
||||
}/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;
|
||||
};
|
||||
|
||||
const isVoted = (activeVotes, currentUserName) => activeVotes.some(v => v.voter === currentUserName && v.percent > 0);
|
||||
|
||||
export const protocolUrl2Obj = (url) => {
|
||||
let urlPart = url.split('://')[1];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user