get from dsteem user data

This commit is contained in:
ue 2018-10-24 11:36:42 +03:00
parent 00ea600774
commit 43a230a86a
2 changed files with 7 additions and 12 deletions

View File

@ -38,9 +38,7 @@ export const getUserData = () => new Promise((resolve, reject) => {
export const getUserDataWithUsername = (username) => {
try {
const user = Array.from(
realm.objects(USER_SCHEMA).filtered('username = $0', username),
);
const user = Array.from(realm.objects(USER_SCHEMA).filtered('username = $0', username));
return user;
} catch (error) {
return error;
@ -66,9 +64,7 @@ export const setUserData = userData => new Promise((resolve, reject) => {
export const updateUserData = userData => new Promise((resolve, reject) => {
try {
const account = realm
.objects(USER_SCHEMA)
.filtered('username = $0', userData.username);
const account = realm.objects(USER_SCHEMA).filtered('username = $0', userData.username);
if (Array.from(account).length > 0) {
realm.write(() => {

View File

@ -5,10 +5,9 @@ import { ProfileScreen } from '..';
// Utilitites
import {
getUser, getFollows, getPosts, getUserComments,
getFollows, getPosts, getUser, getUserComments,
} from '../../../providers/steem/dsteem';
import { getUserData, getAuthStatus, getUserDataWithUsername } from '../../../realm/realm';
import { getFormatedCreatedDate } from '../../../utils/time';
import { getUserData, getAuthStatus } from '../../../realm/realm';
class ProfileContainer extends Component {
constructor(props) {
@ -43,12 +42,12 @@ class ProfileContainer extends Component {
});
if (selectedUser) {
const _userData = getUserDataWithUsername(selectedUser.username);
const _userData = await getUser(selectedUser.username);
console.log(selectedUser);
console.log('holllyy');
console.log(_userData);
userData = _userData && _userData[0];
userData = _userData;
} else if (isLoggedIn) {
await getUserData().then((res) => {
userData = Array.from(res)[0];
@ -64,7 +63,7 @@ class ProfileContainer extends Component {
follows = res;
});
user = await getUser(userData.username);
user = await getUser(userData.username || selectedUser.username);
about = user.json_metadata && JSON.parse(user.json_metadata);