From 783a4fc39f776cbf569b8274549bff593d64335f Mon Sep 17 00:00:00 2001 From: u-e Date: Sat, 6 Apr 2019 12:28:06 +0300 Subject: [PATCH] added delay for server response WA --- src/providers/steem/dsteem.js | 2 +- .../profile/container/profileContainer.js | 29 +++++++++++++++---- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/providers/steem/dsteem.js b/src/providers/steem/dsteem.js index 27902c65f..695349c97 100644 --- a/src/providers/steem/dsteem.js +++ b/src/providers/steem/dsteem.js @@ -192,7 +192,7 @@ export const getFollowSearch = (user, targetUser) => new Promise((resolve, rejec }); }); -export const getIsMuted = async (username, targetUsername) => { +export const getIsMuted = async (targetUsername, username) => { let resp; try { diff --git a/src/screens/profile/container/profileContainer.js b/src/screens/profile/container/profileContainer.js index 2047cc9f6..bc69c9080 100644 --- a/src/screens/profile/container/profileContainer.js +++ b/src/screens/profile/container/profileContainer.js @@ -76,7 +76,10 @@ class ProfileContainer extends Component { componentWillReceiveProps(nextProps) { const { - navigation, currentAccount, activeBottomTab, isLoggedIn, + navigation, + currentAccount, + activeBottomTab, + isLoggedIn, } = this.props; const currentUsername = currentAccount.name !== nextProps.currentAccount.name && nextProps.currentAccount.name; @@ -97,6 +100,10 @@ class ProfileContainer extends Component { } } + componentWillUnmount() { + clearInterval(this.fetchProfileTimer); + } + _getReplies = async (user) => { const { isReverseHeader } = this.state; if (isReverseHeader) { @@ -184,21 +191,25 @@ class ProfileContainer extends Component { _profileActionDone = (error = null) => { const { username } = this.state; - this.setState({ - isProfileLoading: false, - }); - if (error) { this.setState({ error, }); alert(error); } else { - this._fetchProfile(username); + /** + * This follow code totally a work arround + * Ceated for server response delay. + */ + this.fetchProfileTimer = setTimeout(() => { + this._fetchProfile(username); + }, 8000); } }; + _fetchProfile = async (username = null) => { + const { isProfileLoading } = this.state; if (username) { const { isLoggedIn, currentAccount } = this.props; let isFollowing; @@ -222,6 +233,12 @@ class ProfileContainer extends Component { follows = null; } + if (isProfileLoading) { + this.setState({ + isProfileLoading: false, + }); + } + this.setState({ follows, isFollowing,