diff --git a/crates/client/src/user.rs b/crates/client/src/user.rs index 98ca06e1fcfe624d50634d62b7931de6a8bfc437..01fd1773c41d466531870c013b839d57866d8695 100644 --- a/crates/client/src/user.rs +++ b/crates/client/src/user.rs @@ -7,7 +7,7 @@ use postage::{sink::Sink, watch}; use rpc::proto::{RequestMessage, UsersResponse}; use settings::Settings; use std::sync::{Arc, Weak}; -use util::{paths::StaffMode, TryFutureExt as _}; +use util::{StaffMode, TryFutureExt as _}; #[derive(Default, Debug)] pub struct User { @@ -149,11 +149,16 @@ impl UserStore { ); cx.update(|cx| { - cx.set_global( - info.as_ref() - .map(|info| StaffMode(info.staff)) - .unwrap_or(StaffMode(false)), - ); + cx.update_default_global(|staff_mode: &mut StaffMode, _| { + if !staff_mode.0 { + *staff_mode = StaffMode( + info.as_ref() + .map(|info| info.staff) + .unwrap_or_default(), + ) + } + () + }); }); current_user_tx.send(user).await.ok(); diff --git a/crates/theme_selector/src/theme_selector.rs b/crates/theme_selector/src/theme_selector.rs index ad22baf8b925d4599537ea1c4906ab57ce2ac9eb..d999730a0d8b7abe21c0d9b39bfc3a9fb4ca49ca 100644 --- a/crates/theme_selector/src/theme_selector.rs +++ b/crates/theme_selector/src/theme_selector.rs @@ -7,7 +7,7 @@ use picker::{Picker, PickerDelegate}; use settings::{settings_file::SettingsFile, Settings}; use std::sync::Arc; use theme::{Theme, ThemeMeta, ThemeRegistry}; -use util::paths::StaffMode; +use util::StaffMode; use workspace::{AppState, Workspace}; pub struct ThemeSelector { @@ -45,7 +45,7 @@ impl ThemeSelector { let original_theme = settings.theme.clone(); let mut theme_names = registry - .list(**cx.try_global::().unwrap_or(&StaffMode(false))) + .list(**cx.default_global::()) .collect::>(); theme_names.sort_unstable_by(|a, b| { a.is_light diff --git a/crates/util/src/lib.rs b/crates/util/src/lib.rs index e79cc269c9068a85fefe920ddecaf0c937a015d7..8cdbfc6438023f38b76b168a10ab95652590b689 100644 --- a/crates/util/src/lib.rs +++ b/crates/util/src/lib.rs @@ -13,6 +13,17 @@ use std::{ task::{Context, Poll}, }; +#[derive(Debug, Default)] +pub struct StaffMode(pub bool); + +impl std::ops::Deref for StaffMode { + type Target = bool; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + #[macro_export] macro_rules! debug_panic { ( $($fmt_arg:tt)* ) => { diff --git a/crates/util/src/paths.rs b/crates/util/src/paths.rs index 94af0aa75dba6d9d60fce2fccf27665cdaf76068..8698d6891e18e7e3e960a210ec7b3f23e308da72 100644 --- a/crates/util/src/paths.rs +++ b/crates/util/src/paths.rs @@ -1,15 +1,4 @@ -use std::{ops::Deref, path::PathBuf}; - -#[derive(Debug)] -pub struct StaffMode(pub bool); - -impl Deref for StaffMode { - type Target = bool; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} +use std::path::PathBuf; lazy_static::lazy_static! { pub static ref HOME: PathBuf = dirs::home_dir().expect("failed to determine home directory"); diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 4cef2c07758c1930483ffd72c522decf9f7081d5..98d2aa879f422e5b60f0d0489a08f372dc14e67c 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -39,11 +39,7 @@ use terminal_view::{get_working_directory, TerminalView}; use fs::RealFs; use settings::watched_json::{watch_keymap_file, watch_settings_file, WatchedJsonFile}; use theme::ThemeRegistry; -use util::{ - channel::RELEASE_CHANNEL, - paths::{self, StaffMode}, - ResultExt, TryFutureExt, -}; +use util::{channel::RELEASE_CHANNEL, paths, ResultExt, StaffMode, TryFutureExt}; use workspace::{ self, item::ItemHandle, notifications::NotifyResultExt, AppState, NewFile, OpenPaths, Workspace, }; @@ -109,8 +105,6 @@ fn main() { app.run(move |cx| { cx.set_global(*RELEASE_CHANNEL); - #[cfg(not(debug_assertions))] - cx.set_global(StaffMode(false)); #[cfg(debug_assertions)] cx.set_global(StaffMode(true)); diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index d1ec3f245150c950afe7606027456150ec31eb36..fc7f96a384b348ebb1844c52d01bbab5ad37a3d5 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -32,11 +32,7 @@ use serde::Deserialize; use serde_json::to_string_pretty; use settings::{keymap_file_json_schema, settings_file_json_schema, Settings}; use std::{borrow::Cow, env, path::Path, str, sync::Arc}; -use util::{ - channel::ReleaseChannel, - paths::{self, StaffMode}, - ResultExt, -}; +use util::{channel::ReleaseChannel, paths, ResultExt, StaffMode}; use uuid::Uuid; pub use workspace; use workspace::{sidebar::SidebarSide, AppState, Workspace}; @@ -303,7 +299,7 @@ pub fn initialize_workspace( let theme_names = app_state .themes - .list(**cx.try_global::().unwrap_or(&StaffMode(false))) + .list(**cx.default_global::()) .map(|meta| meta.name) .collect(); let language_names = app_state.languages.language_names();