2021-07-17 02:26:05 +00:00
|
|
|
use crate::flowy_server::{ArcFlowyServer, FlowyServerMocker};
|
2021-07-19 13:05:49 +00:00
|
|
|
use flowy_dispatch::prelude::Module;
|
2021-07-22 14:26:38 +00:00
|
|
|
use flowy_editor::prelude::*;
|
2021-07-19 03:32:33 +00:00
|
|
|
use flowy_user::prelude::*;
|
|
|
|
|
2021-07-23 06:37:18 +00:00
|
|
|
use crate::deps_resolve::{EditorDatabaseImpl, WorkspaceDatabaseImpl, WorkspaceUserImpl};
|
2021-07-19 03:32:33 +00:00
|
|
|
use std::sync::Arc;
|
2021-06-30 15:11:27 +00:00
|
|
|
|
2021-07-09 15:31:44 +00:00
|
|
|
pub struct ModuleConfig {
|
|
|
|
pub root: String,
|
|
|
|
}
|
|
|
|
|
2021-07-16 15:18:12 +00:00
|
|
|
pub fn build_modules(config: ModuleConfig, _server: ArcFlowyServer) -> Vec<Module> {
|
2021-07-14 13:12:52 +00:00
|
|
|
let user_session = Arc::new(
|
|
|
|
UserSessionBuilder::new()
|
|
|
|
.root_dir(&config.root)
|
2021-07-17 02:26:05 +00:00
|
|
|
.build(Arc::new(FlowyServerMocker {})),
|
2021-07-14 13:12:52 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
let workspace_user_impl = Arc::new(WorkspaceUserImpl {
|
|
|
|
user_session: user_session.clone(),
|
|
|
|
});
|
2021-07-13 15:08:20 +00:00
|
|
|
|
2021-07-23 06:37:18 +00:00
|
|
|
let workspace_db = Arc::new(WorkspaceDatabaseImpl {
|
2021-07-20 06:03:21 +00:00
|
|
|
user_session: user_session.clone(),
|
|
|
|
});
|
|
|
|
|
2021-07-23 06:37:18 +00:00
|
|
|
let editor_db = Arc::new(EditorDatabaseImpl {
|
|
|
|
user_session: user_session.clone(),
|
|
|
|
});
|
|
|
|
let editor_config = EditorConfig::new(&config.root);
|
|
|
|
|
2021-07-14 00:07:25 +00:00
|
|
|
vec![
|
|
|
|
flowy_user::module::create(user_session),
|
2021-07-23 06:37:18 +00:00
|
|
|
flowy_workspace::module::create(workspace_user_impl, workspace_db),
|
|
|
|
flowy_editor::module::create(editor_db, editor_config),
|
2021-07-14 00:07:25 +00:00
|
|
|
]
|
2021-07-09 15:31:44 +00:00
|
|
|
}
|