mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-19 10:29:35 +03:00
Move to using stateless
This commit is contained in:
parent
118435a348
commit
7d7053b990
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -8395,6 +8395,7 @@ dependencies = [
|
|||||||
"command_palette",
|
"command_palette",
|
||||||
"context_menu",
|
"context_menu",
|
||||||
"ctor",
|
"ctor",
|
||||||
|
"db",
|
||||||
"diagnostics",
|
"diagnostics",
|
||||||
"easy-parallel",
|
"easy-parallel",
|
||||||
"editor",
|
"editor",
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
// "default_dock_anchor": "right"
|
// "default_dock_anchor": "right"
|
||||||
// 3. Position the dock full screen over the entire workspace"
|
// 3. Position the dock full screen over the entire workspace"
|
||||||
// "default_dock_anchor": "expanded"
|
// "default_dock_anchor": "expanded"
|
||||||
"default_dock_anchor": "right",
|
"default_dock_anchor": "bottom",
|
||||||
// Whether or not to remove any trailing whitespace from lines of a buffer
|
// Whether or not to remove any trailing whitespace from lines of a buffer
|
||||||
// before saving it.
|
// before saving it.
|
||||||
"remove_trailing_whitespace_on_save": true,
|
"remove_trailing_whitespace_on_save": true,
|
||||||
|
@ -39,7 +39,8 @@ const FALLBACK_DB_NAME: &'static str = "FALLBACK_MEMORY_DB";
|
|||||||
const DB_FILE_NAME: &'static str = "db.sqlite";
|
const DB_FILE_NAME: &'static str = "db.sqlite";
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
static ref ZED_STATELESS: bool = std::env::var("ZED_STATELESS").map_or(false, |v| !v.is_empty());
|
// !!!!!!! CHANGE BACK TO DEFAULT FALSE BEFORE SHIPPING
|
||||||
|
static ref ZED_STATELESS: bool = std::env::var("ZED_STATELESS").map_or(true, |v| !v.is_empty());
|
||||||
static ref DB_FILE_OPERATIONS: Mutex<()> = Mutex::new(());
|
static ref DB_FILE_OPERATIONS: Mutex<()> = Mutex::new(());
|
||||||
pub static ref BACKUP_DB_PATH: RwLock<Option<PathBuf>> = RwLock::new(None);
|
pub static ref BACKUP_DB_PATH: RwLock<Option<PathBuf>> = RwLock::new(None);
|
||||||
pub static ref ALL_FILE_DB_FAILED: AtomicBool = AtomicBool::new(false);
|
pub static ref ALL_FILE_DB_FAILED: AtomicBool = AtomicBool::new(false);
|
||||||
|
@ -29,6 +29,7 @@ context_menu = { path = "../context_menu" }
|
|||||||
client = { path = "../client" }
|
client = { path = "../client" }
|
||||||
clock = { path = "../clock" }
|
clock = { path = "../clock" }
|
||||||
diagnostics = { path = "../diagnostics" }
|
diagnostics = { path = "../diagnostics" }
|
||||||
|
db = { path = "../db" }
|
||||||
editor = { path = "../editor" }
|
editor = { path = "../editor" }
|
||||||
feedback = { path = "../feedback" }
|
feedback = { path = "../feedback" }
|
||||||
file_finder = { path = "../file_finder" }
|
file_finder = { path = "../file_finder" }
|
||||||
|
@ -13,6 +13,7 @@ use client::{
|
|||||||
http::{self, HttpClient},
|
http::{self, HttpClient},
|
||||||
UserStore, ZED_APP_VERSION, ZED_SECRET_CLIENT_TOKEN,
|
UserStore, ZED_APP_VERSION, ZED_SECRET_CLIENT_TOKEN,
|
||||||
};
|
};
|
||||||
|
use db::kvp::KEY_VALUE_STORE;
|
||||||
use futures::{
|
use futures::{
|
||||||
channel::{mpsc, oneshot},
|
channel::{mpsc, oneshot},
|
||||||
FutureExt, SinkExt, StreamExt,
|
FutureExt, SinkExt, StreamExt,
|
||||||
@ -43,9 +44,12 @@ use theme::ThemeRegistry;
|
|||||||
use util::StaffMode;
|
use util::StaffMode;
|
||||||
use util::{channel::RELEASE_CHANNEL, paths, ResultExt, TryFutureExt};
|
use util::{channel::RELEASE_CHANNEL, paths, ResultExt, TryFutureExt};
|
||||||
use workspace::{
|
use workspace::{
|
||||||
self, item::ItemHandle, notifications::NotifyResultExt, AppState, OpenPaths, Welcome, Workspace,
|
self, item::ItemHandle, notifications::NotifyResultExt, AppState, NewFile, OpenPaths, Workspace,
|
||||||
|
};
|
||||||
|
use zed::{
|
||||||
|
self, build_window_options, initialize_workspace, languages, menus, WelcomeExperience,
|
||||||
|
FIRST_OPEN,
|
||||||
};
|
};
|
||||||
use zed::{self, build_window_options, initialize_workspace, languages, menus};
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let http = http::client();
|
let http = http::client();
|
||||||
@ -258,9 +262,13 @@ async fn restore_or_create_workspace(mut cx: AsyncAppContext) {
|
|||||||
paths: location.paths().as_ref().clone(),
|
paths: location.paths().as_ref().clone(),
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
} else if matches!(KEY_VALUE_STORE.read_kvp(FIRST_OPEN), Ok(None)) {
|
||||||
|
cx.update(|cx| {
|
||||||
|
cx.dispatch_global_action(WelcomeExperience);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
cx.dispatch_global_action(Welcome);
|
cx.dispatch_global_action(NewFile);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ use breadcrumbs::Breadcrumbs;
|
|||||||
pub use client;
|
pub use client;
|
||||||
use collab_ui::{CollabTitlebarItem, ToggleContactsMenu};
|
use collab_ui::{CollabTitlebarItem, ToggleContactsMenu};
|
||||||
use collections::VecDeque;
|
use collections::VecDeque;
|
||||||
|
use db::kvp::KEY_VALUE_STORE;
|
||||||
pub use editor;
|
pub use editor;
|
||||||
use editor::{Editor, MultiBuffer};
|
use editor::{Editor, MultiBuffer};
|
||||||
|
|
||||||
@ -34,7 +35,9 @@ use std::{borrow::Cow, env, path::Path, str, sync::Arc};
|
|||||||
use util::{channel::ReleaseChannel, paths, ResultExt, StaffMode};
|
use util::{channel::ReleaseChannel, paths, ResultExt, StaffMode};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
pub use workspace;
|
pub use workspace;
|
||||||
use workspace::{sidebar::SidebarSide, AppState, Restart, Workspace};
|
use workspace::{sidebar::SidebarSide, AppState, Restart, Welcome, Workspace};
|
||||||
|
|
||||||
|
pub const FIRST_OPEN: &str = "first_open";
|
||||||
|
|
||||||
#[derive(Deserialize, Clone, PartialEq)]
|
#[derive(Deserialize, Clone, PartialEq)]
|
||||||
pub struct OpenBrowser {
|
pub struct OpenBrowser {
|
||||||
@ -67,6 +70,7 @@ actions!(
|
|||||||
ResetBufferFontSize,
|
ResetBufferFontSize,
|
||||||
InstallCommandLineInterface,
|
InstallCommandLineInterface,
|
||||||
ResetDatabase,
|
ResetDatabase,
|
||||||
|
WelcomeExperience
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -252,6 +256,25 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
cx.add_global_action(|_: &WelcomeExperience, cx| {
|
||||||
|
if !matches!(KEY_VALUE_STORE.read_kvp(FIRST_OPEN), Ok(None)) {
|
||||||
|
return; //noop, in case someone fires this from the command palette
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make a workspace, set it up with an open bottom dock and the welcome page
|
||||||
|
|
||||||
|
cx.dispatch_global_action(Welcome);
|
||||||
|
|
||||||
|
cx.background()
|
||||||
|
.spawn(async move {
|
||||||
|
KEY_VALUE_STORE
|
||||||
|
.write_kvp(FIRST_OPEN.to_string(), "false".to_string())
|
||||||
|
.await
|
||||||
|
.log_err();
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
|
});
|
||||||
|
|
||||||
activity_indicator::init(cx);
|
activity_indicator::init(cx);
|
||||||
call::init(app_state.client.clone(), app_state.user_store.clone(), cx);
|
call::init(app_state.client.clone(), app_state.user_store.clone(), cx);
|
||||||
settings::KeymapFileContent::load_defaults(cx);
|
settings::KeymapFileContent::load_defaults(cx);
|
||||||
|
Loading…
Reference in New Issue
Block a user