added delay for server response WA

This commit is contained in:
u-e 2019-04-06 12:28:06 +03:00
parent 9a3b5b0399
commit 783a4fc39f
2 changed files with 24 additions and 7 deletions

View File

@ -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 {

View File

@ -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,