61 lines
1.6 KiB
Rust
Raw Normal View History

2021-12-08 17:33:22 +08:00
pub mod event_builder;
pub mod helper;
2021-07-16 23:18:12 +08:00
use crate::helper::*;
use flowy_core::{FlowySDK, FlowySDKConfig};
2022-10-22 21:57:44 +08:00
use flowy_document::entities::DocumentVersionPB;
use flowy_net::get_client_server_configuration;
2022-07-19 14:40:56 +08:00
use flowy_user::entities::UserProfilePB;
2022-04-11 15:27:03 +08:00
use nanoid::nanoid;
2021-07-06 14:14:47 +08:00
pub mod prelude {
2021-12-08 17:33:22 +08:00
pub use crate::{event_builder::*, helper::*, *};
pub use lib_dispatch::prelude::*;
2021-07-06 14:14:47 +08:00
}
2021-09-04 15:12:53 +08:00
#[derive(Clone)]
2022-01-07 17:37:11 +08:00
pub struct FlowySDKTest {
pub inner: FlowySDK,
}
2021-12-08 17:33:22 +08:00
impl std::ops::Deref for FlowySDKTest {
type Target = FlowySDK;
2022-01-23 12:14:00 +08:00
fn deref(&self) -> &Self::Target {
&self.inner
}
2021-09-04 15:12:53 +08:00
}
2022-01-07 17:37:11 +08:00
impl std::default::Default for FlowySDKTest {
fn default() -> Self {
2022-10-22 21:57:44 +08:00
Self::new(DocumentVersionPB::V0)
2021-12-08 17:33:22 +08:00
}
2022-01-07 17:37:11 +08:00
}
2021-12-08 17:33:22 +08:00
2022-01-07 17:37:11 +08:00
impl FlowySDKTest {
2022-10-22 21:57:44 +08:00
pub fn new(document_version: DocumentVersionPB) -> Self {
let server_config = get_client_server_configuration().unwrap();
feat: Customize the storage folder path (#1538) * feat: support customize folder path * feat: add l10n and optimize the logic * chore: code refactor * feat: add file read/write permission for macOS * fix: add toast for restoring path * feat: fetch apps and show them * feat: fetch apps and show them * feat: implement select document logic * feat: l10n and add select item callback * feat: add space between tile * chore: move file exporter to settings * chore: update UI * feat: support customizing folder when launching the app * feat: auto register after customizing folder * feat: l10n * feat: l10n * chore: reinitialize flowy sdk when calling init_sdk * chore: remove flowysdk const keyword to make sure it can be rebuild * chore: clear kv values when user logout * chore: replace current workspace id key in kv.db * feat: add config.name as a part of seesion_cache_key * feat: support open folder when launching * chore: fix some bugs * chore: dart fix & flutter analyze * chore: wrap 'sign up with ramdom user' as interface * feat: dismiss settings view after changing the folder * fix: read kv value after initializaing with new path * chore: remove user_id prefix from current workspace key * fix: move open latest view action to bloc * test: add test utils for integration tests * chore: move integration_test to its parent directory * test: add integration_test ci * test: switch to B from A, then switch to A again * chore: fix warings and format code and fix tests * chore: remove comment out codes * chore: rename some properties name and optimize the logic * chore: abstract logic of settings file exporter widget to cubit * chore: abstract location customizer view from file system view * chore: abstract settings page index to enum type * chore: remove the redundant underscore * test: fix integration test error * chore: enable integration test for windows and ubuntu * feat: abstract file picker as service and mock it under integration test * chore: fix bloc test Co-authored-by: nathan <nathan@appflowy.io>
2022-12-20 11:14:42 +08:00
let config = FlowySDKConfig::new(&root_dir(), nanoid!(6), server_config)
2022-10-22 21:57:44 +08:00
.with_document_version(document_version)
.log_filter("info");
2022-01-24 16:27:40 +08:00
let sdk = std::thread::spawn(|| FlowySDK::new(config)).join().unwrap();
2022-01-07 17:37:11 +08:00
std::mem::forget(sdk.dispatcher());
Self { inner: sdk }
}
2021-09-27 23:23:23 +08:00
pub async fn sign_up(&self) -> SignUpContext {
async_sign_up(self.inner.dispatcher()).await
2021-09-04 15:12:53 +08:00
}
2022-07-19 14:40:56 +08:00
pub async fn init_user(&self) -> UserProfilePB {
2022-01-07 17:37:11 +08:00
let context = async_sign_up(self.inner.dispatcher()).await;
init_user_setting(self.inner.dispatcher()).await;
context.user_profile
}
2022-10-22 21:57:44 +08:00
pub fn document_version(&self) -> DocumentVersionPB {
self.inner.config.document.version.clone()
}
2021-07-06 14:14:47 +08:00
}