Take account from API before doing localStorage

This commit is contained in:
Marquis Kurt 2019-10-03 15:28:49 -04:00 committed by GitHub
parent 1a402d06c0
commit 9609686926
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 17 deletions

View File

@ -138,23 +138,23 @@ class SettingsPage extends Component<any, ISettingsState> {
});
this.getFederatedStatus();
let acct = localStorage.getItem("account");
if (acct) {
this.setState({ currentUser: JSON.parse(acct) });
} else {
this.client
.get("/accounts/verify_credentials")
.then((resp: any) => {
let data: Account = resp.data;
this.setState({ currentUser: data });
})
.catch((err: Error) => {
this.props.enqueueSnackbar(
"Couldn't find profile info: " + err.name
);
console.error(err.message);
});
}
this.client
.get("/accounts/verify_credentials")
.then((resp: any) => {
let data: Account = resp.data;
this.setState({ currentUser: data });
})
.catch((err: Error) => {
let acct = localStorage.getItem("account");
if (acct) {
this.setState({ currentUser: JSON.parse(acct) });
} else {
this.props.enqueueSnackbar(
"Couldn't find profile info: " + err.name
);
console.error(err.message);
}
});
}
getFederatedStatus() {