Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

client: Respect the default organization ID from the server (#51777)

Marshall Bowers29403eee7c78
diff --git a/crates/client/src/test.rs b/crates/client/src/test.rs
index b506cee822f..99fc594e7fd 100644
--- a/crates/client/src/test.rs
+++ b/crates/client/src/test.rs
@@ -269,6 +269,7 @@ pub fn make_get_authenticated_user_response(
},
feature_flags: vec![],
organizations: vec![],
+ default_organization_id: None,
plans_by_organization: BTreeMap::new(),
plan: PlanInfo {
plan: KnownOrUnknown::Known(Plan::ZedPro),
diff --git a/crates/client/src/user.rs b/crates/client/src/user.rs
index 71b05dc58f5..df0c00d8663 100644
--- a/crates/client/src/user.rs
+++ b/crates/client/src/user.rs
@@ -816,7 +816,15 @@ impl UserStore {
}
self.organizations = response.organizations.into_iter().map(Arc::new).collect();
- self.current_organization = self.organizations.first().cloned();
+ self.current_organization = response
+ .default_organization_id
+ .and_then(|default_organization_id| {
+ self.organizations
+ .iter()
+ .find(|organization| organization.id == default_organization_id)
+ .cloned()
+ })
+ .or_else(|| self.organizations.first().cloned());
self.plans_by_organization = response
.plans_by_organization
.into_iter()
diff --git a/crates/cloud_api_types/src/cloud_api_types.rs b/crates/cloud_api_types/src/cloud_api_types.rs
index e2c517edcc7..286bdbbc1fb 100644
--- a/crates/cloud_api_types/src/cloud_api_types.rs
+++ b/crates/cloud_api_types/src/cloud_api_types.rs
@@ -23,6 +23,8 @@ pub struct GetAuthenticatedUserResponse {
#[serde(default)]
pub organizations: Vec<Organization>,
#[serde(default)]
+ pub default_organization_id: Option<OrganizationId>,
+ #[serde(default)]
pub plans_by_organization: BTreeMap<OrganizationId, KnownOrUnknown<Plan, String>>,
pub plan: PlanInfo,
}