diff --git a/index.js b/index.js
index 7e2341806..85fa049fe 100644
--- a/index.js
+++ b/index.js
@@ -2,6 +2,4 @@ import 'core-js';
import { AppRegistry } from 'react-native';
import { name as appName } from './app.json';
-global.Intl = require('intl');
-
AppRegistry.registerComponent(appName, () => require('./App').default);
diff --git a/src/components/comments/view/commentsView.js b/src/components/comments/view/commentsView.js
index fc934cbf3..963198a51 100644
--- a/src/components/comments/view/commentsView.js
+++ b/src/components/comments/view/commentsView.js
@@ -36,7 +36,6 @@ class CommentsView extends Component {
avatarSize,
marginLeft,
handleOnUserPress,
- currentUser,
commentNumber,
handleOnReplyPress,
isProfilePreview,
diff --git a/src/components/commentsDisplay/view/commentsDisplayView.js b/src/components/commentsDisplay/view/commentsDisplayView.js
index 1ee81895c..6fbb8088b 100644
--- a/src/components/commentsDisplay/view/commentsDisplayView.js
+++ b/src/components/commentsDisplay/view/commentsDisplayView.js
@@ -29,9 +29,7 @@ class CommentsDisplayView extends Component {
};
render() {
- const {
- currentUser, author, permlink, commentCount,
- } = this.props;
+ const { author, permlink, commentCount } = this.props;
return (
@@ -44,7 +42,7 @@ class CommentsDisplayView extends Component {
onDropdownSelect={this._handleOnDropdownSelect}
/>
-
+
)}
diff --git a/src/components/markdownEditor/view/markdownEditorView.js b/src/components/markdownEditor/view/markdownEditorView.js
index 4787d7c44..a436402d5 100644
--- a/src/components/markdownEditor/view/markdownEditorView.js
+++ b/src/components/markdownEditor/view/markdownEditorView.js
@@ -152,13 +152,14 @@ export default class MarkdownEditorView extends Component {
iconType="FontAwesome"
name="image"
/>
-
+ /> */}
);
diff --git a/src/components/postCard/view/postCardView.js b/src/components/postCard/view/postCardView.js
index b03d528c6..eb7859e48 100644
--- a/src/components/postCard/view/postCardView.js
+++ b/src/components/postCard/view/postCardView.js
@@ -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';
diff --git a/src/components/postView/container/postDisplayContainer.js b/src/components/postView/container/postDisplayContainer.js
index c5b594221..397d25d42 100644
--- a/src/components/postView/container/postDisplayContainer.js
+++ b/src/components/postView/container/postDisplayContainer.js
@@ -53,13 +53,13 @@ class PostDisplayContainer extends Component {
};
render() {
- const { post, currentUser } = this.props;
+ const { post, currentAccount } = this.props;
return (
);
diff --git a/src/components/postView/view/postDisplayView.js b/src/components/postView/view/postDisplayView.js
index 2acdd5f97..06071b526 100644
--- a/src/components/postView/view/postDisplayView.js
+++ b/src/components/postView/view/postDisplayView.js
@@ -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"
/>
- {post && currentUser && currentUser.name === post.author && (
+ {post && currentAccount && currentAccount.name === post.author && (
postHeight;
@@ -145,7 +145,6 @@ class PostDisplayView extends Component {
{post && (isGetComment || isLoadedComments) && (
;
+ 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 (
+
+ );
}
}
diff --git a/src/components/upvote/view/upvoteView.js b/src/components/upvote/view/upvoteView.js
index 73e52dd67..27abf7160 100644
--- a/src/components/upvote/view/upvoteView.js
+++ b/src/components/upvote/view/upvoteView.js
@@ -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,22 @@ 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: false,
+ amount: '0.00000',
};
}
// Component Life Cycles
- // Component Functions
+ componentWillReceiveProps(nextProps) {
+ const { isVoted } = this.props;
+ if (isVoted !== nextProps.isVoted) {
+ this.setState({ isVoted: nextProps.isVoted });
+ }
+ }
+
+ // Component Functions
_calculateEstimatedAmount = async () => {
const { currentAccount } = this.props;
// Calculate total vesting shares
@@ -62,7 +68,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 +76,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 +104,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 +138,14 @@ class UpvoteView extends Component {
{isShowPayoutValue && (
$
{' '}
- {content && content.pending_payout_value}
+ {pendingPayoutValue}
)}
diff --git a/src/providers/steem/dsteem.js b/src/providers/steem/dsteem.js
index deeea1b49..b554081a1 100644
--- a/src/providers/steem/dsteem.js
+++ b/src/providers/steem/dsteem.js
@@ -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;
diff --git a/src/screens/application/container/applicationContainer.js b/src/screens/application/container/applicationContainer.js
index f3d537a38..95fc92a19 100644
--- a/src/screens/application/container/applicationContainer.js
+++ b/src/screens/application/container/applicationContainer.js
@@ -57,9 +57,9 @@ class ApplicationContainer extends Component {
};
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 }));
}
}
@@ -71,6 +71,8 @@ class ApplicationContainer extends Component {
if (res.isLoggedIn) {
getUserData().then((response) => {
if (response.length > 0) {
+ // Initial login
+
response.forEach((accountData) => {
dispatch(
addOtherAccount({ username: accountData.username, avatar: accountData.avatar }),
@@ -78,12 +80,14 @@ class ApplicationContainer extends Component {
});
getUser(response[response.length - 1].username)
.then((accountData) => {
- const realmObject = response[response.length - 1];
- accountData.realm_object = realmObject;
-
dispatch(login());
+
+ const realmObject = response[response.length - 1];
+ accountData.local = realmObject;
+
dispatch(updateCurrentAccount(accountData));
dispatch(activeApplication());
+ // If in dev mode pin code does not show
if (__DEV__ === false) {
dispatch(openPinCodeModal());
}
diff --git a/src/screens/editor/container/editorContainer.js b/src/screens/editor/container/editorContainer.js
index b3fcd2b4e..4a65b2292 100644
--- a/src/screens/editor/container/editorContainer.js
+++ b/src/screens/editor/container/editorContainer.js
@@ -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,
diff --git a/src/screens/home/screen/homeScreen.js b/src/screens/home/screen/homeScreen.js
index 04552d1dd..94db9cdec 100644
--- a/src/screens/home/screen/homeScreen.js
+++ b/src/screens/home/screen/homeScreen.js
@@ -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';
@@ -19,9 +19,7 @@ class HomeScreen extends PureComponent {
}
render() {
- const {
- componentId, isLoggedIn, currentAccount, intl,
- } = this.props;
+ const { isLoggedIn, currentAccount, intl } = this.props;
const _filterOptions = [
'FEED',
'TRENDING',
@@ -33,12 +31,17 @@ class HomeScreen extends PureComponent {
'COMMENTS',
'PAYOUT',
];
+ let tag;
+
+ if (!isLoggedIn || (!currentAccount && !currentAccount.name)) {
+ tag = 'esteemapp';
+ }
return (
-
+
(
@@ -59,10 +62,9 @@ class HomeScreen extends PureComponent {
diff --git a/src/screens/pinCode/screen/pinCodeStyles.js b/src/screens/pinCode/screen/pinCodeStyles.js
index f1ac45495..2d25bb6a9 100644
--- a/src/screens/pinCode/screen/pinCodeStyles.js
+++ b/src/screens/pinCode/screen/pinCodeStyles.js
@@ -27,6 +27,7 @@ export default EStyleSheet.create({
informationView: {
flex: 1,
alignItems: 'center',
+ color: '$primaryBlack',
},
animatedView: {
flex: 1,
diff --git a/src/screens/post/container/postContainer.js b/src/screens/post/container/postContainer.js
index 7e3da757f..cbba1a6d2 100644
--- a/src/screens/post/container/postContainer.js
+++ b/src/screens/post/container/postContainer.js
@@ -1,23 +1,17 @@
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 '..';
/*
- * Props Name Description Value
- *@props --> content which is include all post data Object
- *
- */
+ * Props Name Description Value
+ *@props --> content which is include all post data Object
+ *
+ */
class PostContainer extends Component {
constructor(props) {
@@ -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,35 +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 (
-
- );
+ return ;
}
}
-export default PostContainer;
+const mapStateToProps = state => ({
+ currentAccount: state.account.currentAccount,
+});
+
+export default connect(mapStateToProps)(PostContainer);
diff --git a/src/screens/post/screen/postScreen.js b/src/screens/post/screen/postScreen.js
index 4175ba14b..874990e7a 100644
--- a/src/screens/post/screen/postScreen.js
+++ b/src/screens/post/screen/postScreen.js
@@ -23,7 +23,7 @@ class PostScreen extends Component {
// Component Functions
render() {
- const { post, currentUser } = this.props;
+ const { post, currentAccount } = this.props;
return (
@@ -33,7 +33,7 @@ class PostScreen extends Component {
content={post}
dropdownComponent={}
/>
-
+
);
}
diff --git a/src/screens/profile/container/profileContainer.js b/src/screens/profile/container/profileContainer.js
index 508abaf77..c2dd5a5d4 100644
--- a/src/screens/profile/container/profileContainer.js
+++ b/src/screens/profile/container/profileContainer.js
@@ -84,7 +84,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 +102,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,
diff --git a/src/utils/postParser.js b/src/utils/postParser.js
index 1af00d0d7..e97417101 100644
--- a/src/utils/postParser.js
+++ b/src/utils/postParser.js
@@ -131,7 +131,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);
@@ -152,7 +152,7 @@ export const parsePost = (post, currentUser) => {
post.is_voted = false;
for (const i in post.active_votes) {
- if (post.active_votes[i].voter === currentUser && post.active_votes[i].percent > 0) {
+ if (post.active_votes[i].voter === currentUserName && post.active_votes[i].percent > 0) {
post.is_voted = true;
}
post.active_votes[i].value = (post.active_votes[i].rshares * ratio).toFixed(2);
@@ -162,16 +162,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 groomVotes = (activeVotes, currentUserName) => {};
+
export const protocolUrl2Obj = (url) => {
let urlPart = url.split('://')[1];