mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-11-27 03:14:56 +03:00
merged with master
This commit is contained in:
commit
1c06d3fe67
@ -32,7 +32,7 @@ class IconView extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
_getIcon = () => {
|
_getIcon = () => {
|
||||||
const { iconType } = this.props;
|
const { iconType, children } = this.props;
|
||||||
const name = this._getIconName();
|
const name = this._getIconName();
|
||||||
|
|
||||||
switch (iconType) {
|
switch (iconType) {
|
||||||
@ -41,13 +41,13 @@ class IconView extends Component {
|
|||||||
case 'FontAwesome':
|
case 'FontAwesome':
|
||||||
return <FontAwesome {...this.props} />;
|
return <FontAwesome {...this.props} />;
|
||||||
case 'SimpleLineIcons':
|
case 'SimpleLineIcons':
|
||||||
return <SimpleLineIcons {...this.props}>{this.props.children}</SimpleLineIcons>;
|
return <SimpleLineIcons {...this.props}>{children}</SimpleLineIcons>;
|
||||||
case 'AntDesign':
|
case 'AntDesign':
|
||||||
return <AntDesign {...this.props}>{this.props.children}</AntDesign>;
|
return <AntDesign {...this.props}>{children}</AntDesign>;
|
||||||
case 'MaterialCommunityIcons':
|
case 'MaterialCommunityIcons':
|
||||||
return (
|
return (
|
||||||
<MaterialCommunityIcons name={name} {...this.props}>
|
<MaterialCommunityIcons name={name} {...this.props}>
|
||||||
{this.props.children}
|
{children}
|
||||||
</MaterialCommunityIcons>
|
</MaterialCommunityIcons>
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
|
@ -9,6 +9,7 @@ import { NumericKeyboard } from './numericKeyboard';
|
|||||||
import { PinAnimatedInput } from './pinAnimatedInput';
|
import { PinAnimatedInput } from './pinAnimatedInput';
|
||||||
import { SideMenu } from './sideMenu';
|
import { SideMenu } from './sideMenu';
|
||||||
import Modal from './modal';
|
import Modal from './modal';
|
||||||
|
import Icon from './icon';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
Logo,
|
Logo,
|
||||||
@ -24,4 +25,5 @@ export {
|
|||||||
PinAnimatedInput,
|
PinAnimatedInput,
|
||||||
SideMenu,
|
SideMenu,
|
||||||
Modal,
|
Modal,
|
||||||
|
Icon,
|
||||||
};
|
};
|
||||||
|
@ -1,10 +1,20 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
// Actions
|
||||||
import { getUserData } from '../../../realm/realm';
|
import { getUserData } from '../../../realm/realm';
|
||||||
|
import { switchAccount } from '../../../providers/steem/auth';
|
||||||
|
import { updateCurrentAccount } from '../../../redux/actions/accountAction';
|
||||||
|
import { openPinCodeModal } from '../../../redux/actions/applicationActions';
|
||||||
|
|
||||||
|
// Constanst
|
||||||
|
import { default as ROUTES } from '../../../constants/routeNames';
|
||||||
|
|
||||||
// Component
|
// Component
|
||||||
import { SideMenuView } from '..';
|
import { SideMenuView } from '..';
|
||||||
|
|
||||||
|
const DEFAULT_IMAGE = require('../../../assets/esteem.png');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Props Name Description
|
* Props Name Description
|
||||||
*@props --> props name navigation coming from react-navigation
|
*@props --> props name navigation coming from react-navigation
|
||||||
@ -26,7 +36,15 @@ class SideMenuContainer extends Component {
|
|||||||
|
|
||||||
getUserData().then((userData) => {
|
getUserData().then((userData) => {
|
||||||
userData.forEach((element) => {
|
userData.forEach((element) => {
|
||||||
accounts.push({ name: element.username, image: 'test' });
|
accounts.push({
|
||||||
|
name: `@${element.username}`,
|
||||||
|
image: element.avatar ? { uri: element.avatar } : DEFAULT_IMAGE,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
accounts.push({
|
||||||
|
name: 'Add Account',
|
||||||
|
route: ROUTES.SCREENS.LOGIN,
|
||||||
|
icon: 'plus-square-o',
|
||||||
});
|
});
|
||||||
this.setState({ accounts });
|
this.setState({ accounts });
|
||||||
});
|
});
|
||||||
@ -36,7 +54,19 @@ class SideMenuContainer extends Component {
|
|||||||
|
|
||||||
_navigateToRoute = (route = null) => {
|
_navigateToRoute = (route = null) => {
|
||||||
const { navigation } = this.props;
|
const { navigation } = this.props;
|
||||||
navigation.navigate(route);
|
if (route) {
|
||||||
|
navigation.navigate(route);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
_switchAccount = (username = null) => {
|
||||||
|
const { dispatch } = this.props;
|
||||||
|
|
||||||
|
username = username.slice(1);
|
||||||
|
switchAccount(username).then((accountData) => {
|
||||||
|
dispatch(updateCurrentAccount(accountData));
|
||||||
|
dispatch(openPinCodeModal());
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@ -50,14 +80,15 @@ class SideMenuContainer extends Component {
|
|||||||
userAvatar={null}
|
userAvatar={null}
|
||||||
accounts={accounts}
|
accounts={accounts}
|
||||||
currentAccount={currentAccount}
|
currentAccount={currentAccount}
|
||||||
|
switchAccount={this._switchAccount}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
isLoggedIn: state.application.isLoggedIn,
|
isLoggedIn: state.application.isLoggedIn || false,
|
||||||
currentAccount: state.account.currentAccount,
|
currentAccount: state.account.currentAccount || {},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(mapStateToProps)(SideMenuContainer);
|
export default connect(mapStateToProps)(SideMenuContainer);
|
||||||
|
@ -24,6 +24,9 @@ export default EStyleSheet.create({
|
|||||||
userAvatar: {
|
userAvatar: {
|
||||||
marginLeft: '$deviceWidth / 10',
|
marginLeft: '$deviceWidth / 10',
|
||||||
},
|
},
|
||||||
|
otherUserAvatar: {
|
||||||
|
marginLeft: -15,
|
||||||
|
},
|
||||||
userInfoView: {
|
userInfoView: {
|
||||||
alignSelf: 'flex-end',
|
alignSelf: 'flex-end',
|
||||||
marginLeft: 15,
|
marginLeft: 15,
|
||||||
@ -71,4 +74,7 @@ export default EStyleSheet.create({
|
|||||||
flex: 1,
|
flex: 1,
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
},
|
},
|
||||||
|
addAccountIcon: {
|
||||||
|
padding: 10,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
@ -3,11 +3,10 @@ import { View, Text } from 'react-native';
|
|||||||
import {
|
import {
|
||||||
Thumbnail, List, ListItem, Container,
|
Thumbnail, List, ListItem, Container,
|
||||||
} from 'native-base';
|
} from 'native-base';
|
||||||
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
||||||
import LinearGradient from 'react-native-linear-gradient';
|
import LinearGradient from 'react-native-linear-gradient';
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import { IconButton } from '../..';
|
import { Icon, IconButton } from '../..';
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
import { default as MENU } from '../../../constants/sideMenuItems';
|
import { default as MENU } from '../../../constants/sideMenuItems';
|
||||||
@ -54,10 +53,32 @@ class SideMenuView extends Component {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_getNameOfUser = () => {
|
||||||
|
const { currentAccount } = this.props;
|
||||||
|
if (Object.keys(currentAccount).length === 0) return '';
|
||||||
|
const jsonMetadata = JSON.parse(currentAccount.json_metadata);
|
||||||
|
if (Object.keys(jsonMetadata).length !== 0) {
|
||||||
|
return jsonMetadata.profile.name;
|
||||||
|
}
|
||||||
|
return currentAccount.name;
|
||||||
|
};
|
||||||
|
|
||||||
|
_getUserAvatar = () => {
|
||||||
|
const { currentAccount } = this.props;
|
||||||
|
if (Object.keys(currentAccount).length === 0) return DEFAULT_IMAGE;
|
||||||
|
const jsonMetadata = JSON.parse(currentAccount.json_metadata);
|
||||||
|
if (Object.keys(jsonMetadata).length !== 0) {
|
||||||
|
return { uri: jsonMetadata.profile.cover_image };
|
||||||
|
}
|
||||||
|
return DEFAULT_IMAGE;
|
||||||
|
};
|
||||||
|
|
||||||
// Component Functions
|
// Component Functions
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { userAvatar, navigateToRoute, currentAccount } = this.props;
|
const {
|
||||||
|
navigateToRoute, currentAccount, isLoggedIn, switchAccount,
|
||||||
|
} = this.props;
|
||||||
const { menuItems, isAddAccountIconActive } = this.state;
|
const { menuItems, isAddAccountIconActive } = this.state;
|
||||||
// TODO: Change dummy data
|
// TODO: Change dummy data
|
||||||
return (
|
return (
|
||||||
@ -68,23 +89,28 @@ class SideMenuView extends Component {
|
|||||||
colors={['#357ce6', '#2d5aa0']}
|
colors={['#357ce6', '#2d5aa0']}
|
||||||
style={styles.headerView}
|
style={styles.headerView}
|
||||||
>
|
>
|
||||||
<View style={styles.headerContentView}>
|
{isLoggedIn && (
|
||||||
<Thumbnail style={styles.userAvatar} source={userAvatar || DEFAULT_IMAGE} />
|
<View style={styles.headerContentView}>
|
||||||
<View style={styles.userInfoView}>
|
<Thumbnail style={styles.userAvatar} source={this._getUserAvatar()} />
|
||||||
<Text style={styles.username}>Mustafa</Text>
|
<View style={styles.userInfoView}>
|
||||||
<Text style={styles.usernick}>@mistikk</Text>
|
<Text style={styles.username}>{this._getNameOfUser()}</Text>
|
||||||
|
<Text style={styles.usernick}>{`@${currentAccount.name}`}</Text>
|
||||||
|
</View>
|
||||||
|
<View style={styles.addAccountIconView}>
|
||||||
|
{/* TODO: delete android name */}
|
||||||
|
<IconButton
|
||||||
|
name={isAddAccountIconActive ? 'arrow-dropup' : 'add-circle-outline'}
|
||||||
|
androidName={
|
||||||
|
isAddAccountIconActive ? 'md-arrow-dropup' : 'ios-add-circle-outline'
|
||||||
|
}
|
||||||
|
color="white"
|
||||||
|
size={15}
|
||||||
|
handleOnPress={() => this._handleOnPressAddAccountIcon()}
|
||||||
|
style={styles.addAccountIcon}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.addAccountIconView}>
|
)}
|
||||||
{/* TODO: delete android name */}
|
|
||||||
<IconButton
|
|
||||||
name={isAddAccountIconActive ? 'arrow-dropup' : 'add-circle-outline'}
|
|
||||||
androidName={isAddAccountIconActive ? 'md-arrow-dropup' : 'ios-add-circle-outline'}
|
|
||||||
color="white"
|
|
||||||
size={15}
|
|
||||||
handleOnPress={() => this._handleOnPressAddAccountIcon()}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
</LinearGradient>
|
</LinearGradient>
|
||||||
<View style={styles.contentView}>
|
<View style={styles.contentView}>
|
||||||
<List
|
<List
|
||||||
@ -94,9 +120,18 @@ class SideMenuView extends Component {
|
|||||||
<ListItem
|
<ListItem
|
||||||
noBorder
|
noBorder
|
||||||
style={styles.listItem}
|
style={styles.listItem}
|
||||||
onPress={() => navigateToRoute(item.route)}
|
onPress={() => {
|
||||||
|
if (item.route) {
|
||||||
|
navigateToRoute(item.route);
|
||||||
|
} else {
|
||||||
|
switchAccount(item.name);
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Icon style={styles.listItemIcon} name={item.icon} />
|
{item.icon && <Icon iconType="FontAwesome" style={styles.listItemIcon} name={item.icon} />}
|
||||||
|
{item.image && (
|
||||||
|
<Thumbnail small style={styles.otherUserAvatar} source={item.image} />
|
||||||
|
)}
|
||||||
<Text style={styles.listItemText}>{item.name}</Text>
|
<Text style={styles.listItemText}>{item.name}</Text>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
)}
|
)}
|
||||||
|
@ -36,18 +36,18 @@ const authMenuItems = [
|
|||||||
route: 'Settings',
|
route: 'Settings',
|
||||||
icon: 'gear',
|
icon: 'gear',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: 'LoginTest',
|
|
||||||
route: ROUTES.SCREENS.LOGIN,
|
|
||||||
icon: 'user-o',
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const noAuthMenuItems = [
|
const noAuthMenuItems = [
|
||||||
{
|
{
|
||||||
name: 'Login',
|
name: 'Add Account',
|
||||||
route: ROUTES.SCREENS.LOGIN,
|
route: ROUTES.SCREENS.LOGIN,
|
||||||
icon: 'user-o',
|
icon: 'plus-square-o',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Settings',
|
||||||
|
route: 'Settings',
|
||||||
|
icon: 'gear',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import {
|
|||||||
updateUserData,
|
updateUserData,
|
||||||
setPinCode,
|
setPinCode,
|
||||||
getPinCode,
|
getPinCode,
|
||||||
|
updateCurrentUsername,
|
||||||
} from '../../realm/realm';
|
} from '../../realm/realm';
|
||||||
import { encryptKey, decryptKey } from '../../utils/crypto';
|
import { encryptKey, decryptKey } from '../../utils/crypto';
|
||||||
import steemConnect from './steemConnectAPI';
|
import steemConnect from './steemConnectAPI';
|
||||||
@ -21,6 +22,7 @@ export const Login = (username, password) => {
|
|||||||
posting: null,
|
posting: null,
|
||||||
};
|
};
|
||||||
let loginFlag = false;
|
let loginFlag = false;
|
||||||
|
let avatar = '';
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// Get user account data from STEEM Blockchain
|
// Get user account data from STEEM Blockchain
|
||||||
@ -53,9 +55,14 @@ export const Login = (username, password) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const jsonMetadata = JSON.parse(account.json_metadata);
|
||||||
|
if (Object.keys(jsonMetadata).length !== 0) {
|
||||||
|
avatar = jsonMetadata.profile.cover_image;
|
||||||
|
}
|
||||||
if (loginFlag) {
|
if (loginFlag) {
|
||||||
const userData = {
|
const userData = {
|
||||||
username,
|
username,
|
||||||
|
avatar,
|
||||||
authType: 'masterKey',
|
authType: 'masterKey',
|
||||||
masterKey: '',
|
masterKey: '',
|
||||||
postingKey: '',
|
postingKey: '',
|
||||||
@ -85,10 +92,17 @@ export const Login = (username, password) => {
|
|||||||
export const loginWithSC2 = async (accessToken) => {
|
export const loginWithSC2 = async (accessToken) => {
|
||||||
await steemConnect.setAccessToken(accessToken);
|
await steemConnect.setAccessToken(accessToken);
|
||||||
const account = await steemConnect.me();
|
const account = await steemConnect.me();
|
||||||
|
let avatar = '';
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
const jsonMetadata = JSON.parse(account.json_metadata);
|
||||||
|
if (Object.keys(jsonMetadata).length !== 0) {
|
||||||
|
avatar = jsonMetadata.profile.cover_image;
|
||||||
|
}
|
||||||
|
|
||||||
const userData = {
|
const userData = {
|
||||||
username: account.account.name,
|
username: account.account.name,
|
||||||
|
avatar,
|
||||||
authType: 'steemConnect',
|
authType: 'steemConnect',
|
||||||
masterKey: '',
|
masterKey: '',
|
||||||
postingKey: '',
|
postingKey: '',
|
||||||
@ -99,6 +113,7 @@ export const loginWithSC2 = async (accessToken) => {
|
|||||||
|
|
||||||
const authData = {
|
const authData = {
|
||||||
isLoggedIn: true,
|
isLoggedIn: true,
|
||||||
|
currentUsername: account.account.name,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isLoggedInUser(account.account.name)) {
|
if (isLoggedInUser(account.account.name)) {
|
||||||
@ -154,6 +169,7 @@ export const setUserDataWithPinCode = data => new Promise((resolve, reject) => {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
const authData = {
|
const authData = {
|
||||||
isLoggedIn: true,
|
isLoggedIn: true,
|
||||||
|
currentUsername: userData.username,
|
||||||
};
|
};
|
||||||
|
|
||||||
setAuthStatus(authData)
|
setAuthStatus(authData)
|
||||||
@ -227,6 +243,7 @@ export const verifyPinCode = async (data) => {
|
|||||||
if (loginFlag) {
|
if (loginFlag) {
|
||||||
const authData = {
|
const authData = {
|
||||||
isLoggedIn: true,
|
isLoggedIn: true,
|
||||||
|
currentUsername: data.username,
|
||||||
};
|
};
|
||||||
const response = {
|
const response = {
|
||||||
accessToken: decryptKey(userData.accessToken, data.pinCode),
|
accessToken: decryptKey(userData.accessToken, data.pinCode),
|
||||||
@ -249,6 +266,20 @@ export const verifyPinCode = async (data) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const switchAccount = username => new Promise((resolve, reject) => {
|
||||||
|
getAccount(username)
|
||||||
|
.then((result) => {
|
||||||
|
const account = result[0];
|
||||||
|
updateCurrentUsername(username).then(() => {
|
||||||
|
resolve(account);
|
||||||
|
}).catch(() => {
|
||||||
|
reject(new Error('Unknown error, please contact to eSteem.'));
|
||||||
|
});
|
||||||
|
}).catch(() => {
|
||||||
|
reject(new Error('Unknown error, please contact to eSteem.'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const getPrivateKeys = (username, password) => ({
|
const getPrivateKeys = (username, password) => ({
|
||||||
active: dsteem.PrivateKey.fromLogin(username, password, 'active'),
|
active: dsteem.PrivateKey.fromLogin(username, password, 'active'),
|
||||||
memo: dsteem.PrivateKey.fromLogin(username, password, 'memo'),
|
memo: dsteem.PrivateKey.fromLogin(username, password, 'memo'),
|
||||||
|
@ -8,6 +8,7 @@ const userSchema = {
|
|||||||
name: USER_SCHEMA,
|
name: USER_SCHEMA,
|
||||||
properties: {
|
properties: {
|
||||||
username: { type: 'string' },
|
username: { type: 'string' },
|
||||||
|
avatar: { type: 'string' },
|
||||||
authType: { type: 'string' },
|
authType: { type: 'string' },
|
||||||
postingKey: { type: 'string' },
|
postingKey: { type: 'string' },
|
||||||
activeKey: { type: 'string' },
|
activeKey: { type: 'string' },
|
||||||
@ -22,6 +23,7 @@ const authSchema = {
|
|||||||
properties: {
|
properties: {
|
||||||
isLoggedIn: { type: 'bool', default: false },
|
isLoggedIn: { type: 'bool', default: false },
|
||||||
pinCode: { type: 'string' },
|
pinCode: { type: 'string' },
|
||||||
|
currentUsername: { type: 'string' },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -104,7 +106,7 @@ export const getAuthStatus = () => new Promise((resolve, reject) => {
|
|||||||
try {
|
try {
|
||||||
const auth = realm.objects(AUTH_SCHEMA);
|
const auth = realm.objects(AUTH_SCHEMA);
|
||||||
if (auth['0']) {
|
if (auth['0']) {
|
||||||
resolve(auth['0'].isLoggedIn);
|
resolve(auth['0']);
|
||||||
} else {
|
} else {
|
||||||
resolve(false);
|
resolve(false);
|
||||||
}
|
}
|
||||||
@ -116,8 +118,6 @@ export const getAuthStatus = () => new Promise((resolve, reject) => {
|
|||||||
export const setAuthStatus = authStatus => new Promise((resolve, reject) => {
|
export const setAuthStatus = authStatus => new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
const auth = realm.objects(AUTH_SCHEMA);
|
const auth = realm.objects(AUTH_SCHEMA);
|
||||||
const test = Array.from(auth);
|
|
||||||
const test1 = Array.from(auth).length;
|
|
||||||
realm.write(() => {
|
realm.write(() => {
|
||||||
if (Array.from(auth).length > 0) {
|
if (Array.from(auth).length > 0) {
|
||||||
auth[0].isLoggedIn = authStatus.isLoggedIn;
|
auth[0].isLoggedIn = authStatus.isLoggedIn;
|
||||||
@ -132,6 +132,28 @@ export const setAuthStatus = authStatus => new Promise((resolve, reject) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const updateCurrentUsername = username => new Promise((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
const auth = realm.objects(AUTH_SCHEMA);
|
||||||
|
realm.write(() => {
|
||||||
|
if (Array.from(auth).length > 0) {
|
||||||
|
auth[0].currentUsername = username;
|
||||||
|
resolve(auth[0]);
|
||||||
|
} else {
|
||||||
|
const authData = {
|
||||||
|
isLoggedIn: false,
|
||||||
|
pinCode: '',
|
||||||
|
currentUsername: username,
|
||||||
|
};
|
||||||
|
realm.create(AUTH_SCHEMA, { ...authData });
|
||||||
|
resolve(authData);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
export const setPinCode = pinCode => new Promise((resolve, reject) => {
|
export const setPinCode = pinCode => new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
const auth = realm.objects(AUTH_SCHEMA);
|
const auth = realm.objects(AUTH_SCHEMA);
|
||||||
|
@ -104,7 +104,7 @@ class AuthorScreen extends Component {
|
|||||||
let user;
|
let user;
|
||||||
|
|
||||||
await getAuthStatus().then((res) => {
|
await getAuthStatus().then((res) => {
|
||||||
isLoggedIn = res;
|
isLoggedIn = res.isLoggedIn;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isLoggedIn) {
|
if (isLoggedIn) {
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
import React, { PureComponent, Fragment } from 'react';
|
import React, { PureComponent, Fragment } from 'react';
|
||||||
import { Text, View } 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';
|
||||||
|
|
||||||
// STEEM
|
// STEEM
|
||||||
import { getUserData, getAuthStatus } from '../../../realm/realm';
|
|
||||||
import { getUser } from '../../../providers/steem/dsteem';
|
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import { TabBar } from '../../../components/tabBar';
|
import { TabBar } from '../../../components/tabBar';
|
||||||
|
@ -60,7 +60,7 @@ class PostContainer extends Component {
|
|||||||
let isLoggedIn;
|
let isLoggedIn;
|
||||||
|
|
||||||
await getAuthStatus().then((res) => {
|
await getAuthStatus().then((res) => {
|
||||||
isLoggedIn = res;
|
isLoggedIn = res.isLoggedIn;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isLoggedIn) {
|
if (isLoggedIn) {
|
||||||
|
@ -75,7 +75,7 @@ class ProfilePage extends React.Component {
|
|||||||
let about;
|
let about;
|
||||||
|
|
||||||
await getAuthStatus().then((res) => {
|
await getAuthStatus().then((res) => {
|
||||||
isLoggedIn = res;
|
isLoggedIn = res.isLoggedIn;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isLoggedIn) {
|
if (isLoggedIn) {
|
||||||
|
@ -26,11 +26,13 @@ class SplashContainer extends Component {
|
|||||||
const { navigation, dispatch } = this.props;
|
const { navigation, dispatch } = this.props;
|
||||||
|
|
||||||
getAuthStatus().then((res) => {
|
getAuthStatus().then((res) => {
|
||||||
if (res) {
|
if (res.isLoggedIn) {
|
||||||
getUserData().then((response) => {
|
getUserData().then((response) => {
|
||||||
if (response.length > 0) {
|
if (response.length > 0) {
|
||||||
response.forEach((accountData) => {
|
response.forEach((accountData) => {
|
||||||
dispatch(addOtherAccount({ username: accountData.username }));
|
dispatch(
|
||||||
|
addOtherAccount({ username: accountData.username, avatar: accountData.avatar }),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
getUser(response[response.length - 1].username).then((accountData) => {
|
getUser(response[response.length - 1].username).then((accountData) => {
|
||||||
const realmObject = response[response.length - 1];
|
const realmObject = response[response.length - 1];
|
||||||
|
@ -42,7 +42,7 @@ class WalletPage extends Component {
|
|||||||
let globalProperties;
|
let globalProperties;
|
||||||
|
|
||||||
await getAuthStatus().then((res) => {
|
await getAuthStatus().then((res) => {
|
||||||
isLoggedIn = res;
|
isLoggedIn = res.isLoggedIn;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isLoggedIn) {
|
if (isLoggedIn) {
|
||||||
|
@ -2,7 +2,7 @@ import { getUserData, getAuthStatus } from '../realm/realm';
|
|||||||
|
|
||||||
export const getUserIsLoggedIn = () => {
|
export const getUserIsLoggedIn = () => {
|
||||||
getAuthStatus()
|
getAuthStatus()
|
||||||
.then(res => res)
|
.then(res => res.isLoggedIn)
|
||||||
.catch(() => null);
|
.catch(() => null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user