mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: reload workspace when fail to load at the first time (#4633)
* chore: reload workspace when fail to load at the first time * fix: clippy * chore: update client api * chore: fix wasm build * chore: fix test
This commit is contained in:
@ -331,7 +331,9 @@ async fn get_admin_client(client: &Arc<AFCloudClient>) -> FlowyResult<Client> {
|
||||
client.base_url(),
|
||||
client.ws_addr(),
|
||||
client.gotrue_url(),
|
||||
&client.device_id,
|
||||
ClientConfiguration::default(),
|
||||
&client.client_id,
|
||||
);
|
||||
admin_client
|
||||
.sign_in_password(&admin_email, &admin_password)
|
||||
|
@ -12,7 +12,8 @@ use client_api::{Client, ClientConfiguration};
|
||||
use flowy_storage::ObjectStorageService;
|
||||
use tokio::sync::watch;
|
||||
use tokio_stream::wrappers::WatchStream;
|
||||
use tracing::{error, event, info};
|
||||
use tracing::{error, event, info, warn};
|
||||
use uuid::Uuid;
|
||||
|
||||
use flowy_database_pub::cloud::DatabaseCloudService;
|
||||
use flowy_document_pub::cloud::DocumentCloudService;
|
||||
@ -38,20 +39,32 @@ pub struct AppFlowyCloudServer {
|
||||
pub(crate) client: Arc<AFCloudClient>,
|
||||
enable_sync: Arc<AtomicBool>,
|
||||
network_reachable: Arc<AtomicBool>,
|
||||
#[allow(dead_code)]
|
||||
device_id: String,
|
||||
pub device_id: String,
|
||||
ws_client: Arc<WSClient>,
|
||||
}
|
||||
|
||||
impl AppFlowyCloudServer {
|
||||
pub fn new(config: AFCloudConfiguration, enable_sync: bool, device_id: String) -> Self {
|
||||
pub fn new(
|
||||
config: AFCloudConfiguration,
|
||||
enable_sync: bool,
|
||||
mut device_id: String,
|
||||
app_version: &str,
|
||||
) -> Self {
|
||||
// The device id can't be empty, so we generate a new one if it is.
|
||||
if device_id.is_empty() {
|
||||
warn!("Device ID is empty, generating a new one");
|
||||
device_id = Uuid::new_v4().to_string();
|
||||
}
|
||||
|
||||
let api_client = AFCloudClient::new(
|
||||
&config.base_url,
|
||||
&config.ws_base_url,
|
||||
&config.gotrue_url,
|
||||
&device_id,
|
||||
ClientConfiguration::default()
|
||||
.with_compression_buffer_size(10240)
|
||||
.with_compression_quality(8),
|
||||
app_version,
|
||||
);
|
||||
let token_state_rx = api_client.subscribe_token_state();
|
||||
let enable_sync = Arc::new(AtomicBool::new(enable_sync));
|
||||
|
@ -26,7 +26,12 @@ pub fn get_af_cloud_config() -> Option<AFCloudConfiguration> {
|
||||
|
||||
pub fn af_cloud_server(config: AFCloudConfiguration) -> Arc<AppFlowyCloudServer> {
|
||||
let fake_device_id = uuid::Uuid::new_v4().to_string();
|
||||
Arc::new(AppFlowyCloudServer::new(config, true, fake_device_id))
|
||||
Arc::new(AppFlowyCloudServer::new(
|
||||
config,
|
||||
true,
|
||||
fake_device_id,
|
||||
"flowy-server-test",
|
||||
))
|
||||
}
|
||||
|
||||
pub async fn generate_sign_in_url(user_email: &str, config: &AFCloudConfiguration) -> String {
|
||||
@ -34,7 +39,9 @@ pub async fn generate_sign_in_url(user_email: &str, config: &AFCloudConfiguratio
|
||||
&config.base_url,
|
||||
&config.ws_base_url,
|
||||
&config.gotrue_url,
|
||||
"fake_device_id",
|
||||
ClientConfiguration::default(),
|
||||
"test",
|
||||
);
|
||||
let admin_email = std::env::var("GOTRUE_ADMIN_EMAIL").unwrap();
|
||||
let admin_password = std::env::var("GOTRUE_ADMIN_PASSWORD").unwrap();
|
||||
@ -42,7 +49,9 @@ pub async fn generate_sign_in_url(user_email: &str, config: &AFCloudConfiguratio
|
||||
client.base_url(),
|
||||
client.ws_addr(),
|
||||
client.gotrue_url(),
|
||||
"fake_device_id",
|
||||
ClientConfiguration::default(),
|
||||
&client.client_id,
|
||||
);
|
||||
admin_client
|
||||
.sign_in_password(&admin_email, &admin_password)
|
||||
|
Reference in New Issue
Block a user