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:
Nathan.fooo
2024-02-08 23:53:05 +08:00
committed by GitHub
parent 747fe40648
commit 3b51a6e6be
26 changed files with 468 additions and 197 deletions

View File

@ -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)

View File

@ -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));