client: Don't fetch the authenticated user once we have them (#35385)
This PR makes it so we don't keep fetching the authenticated user once we have them. Release Notes: - N/A
This commit is contained in:
parent
e1e2775b80
commit
b90fd4287f
1 changed files with 17 additions and 10 deletions
|
@ -23,16 +23,23 @@ impl CloudUserStore {
|
||||||
};
|
};
|
||||||
|
|
||||||
if cloud_client.has_credentials() {
|
if cloud_client.has_credentials() {
|
||||||
if let Some(response) = cloud_client
|
let already_fetched_authenticated_user = this
|
||||||
.get_authenticated_user()
|
.read_with(cx, |this, _cx| this.authenticated_user().is_some())
|
||||||
.await
|
.unwrap_or(false);
|
||||||
.context("failed to fetch authenticated user")
|
|
||||||
.log_err()
|
if already_fetched_authenticated_user {
|
||||||
{
|
// We already fetched the authenticated user; nothing to do.
|
||||||
this.update(cx, |this, _cx| {
|
} else {
|
||||||
this.authenticated_user = Some(Arc::new(response.user));
|
let authenticated_user_result = cloud_client
|
||||||
})
|
.get_authenticated_user()
|
||||||
.ok();
|
.await
|
||||||
|
.context("failed to fetch authenticated user");
|
||||||
|
if let Some(response) = authenticated_user_result.log_err() {
|
||||||
|
this.update(cx, |this, _cx| {
|
||||||
|
this.authenticated_user = Some(Arc::new(response.user));
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.update(cx, |this, _cx| {
|
this.update(cx, |this, _cx| {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue