From b2e55c4e2e7c9c07e229c26689d697fe583940c2 Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Sun, 18 Feb 2024 16:40:18 +0800 Subject: [PATCH] Fix: init state (#4672) * chore: fix login state * chore: change log * chore: fix flutter version --- CHANGELOG.md | 4 ++++ frontend/Makefile.toml | 2 +- frontend/appflowy_flutter/pubspec.yaml | 2 +- frontend/rust-lib/flowy-server/src/af_cloud/server.rs | 6 +++--- frontend/rust-lib/flowy-user-pub/src/entities.rs | 1 + frontend/rust-lib/flowy-user/src/user_manager/manager.rs | 2 +- 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57ad262e1c..f4d52fe998 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Release Notes +## Version 0.4.9 - 02/17/2024 +### Bug Fixes +- Resolved the issue that caused users to be redirected to the Sign In page +- ## Version 0.4.8 - 02/13/2024 ### Bug Fixes - Fixed a possible error when loading workspaces diff --git a/frontend/Makefile.toml b/frontend/Makefile.toml index 7f05064bed..336b2f545c 100644 --- a/frontend/Makefile.toml +++ b/frontend/Makefile.toml @@ -26,7 +26,7 @@ CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true CARGO_MAKE_CRATE_FS_NAME = "dart_ffi" CARGO_MAKE_CRATE_NAME = "dart-ffi" LIB_NAME = "dart_ffi" -APPFLOWY_VERSION = "0.4.8" +APPFLOWY_VERSION = "0.4.9" FLUTTER_DESKTOP_FEATURES = "dart,rev-sqlite" PRODUCT_NAME = "AppFlowy" MACOSX_DEPLOYMENT_TARGET = "11.0" diff --git a/frontend/appflowy_flutter/pubspec.yaml b/frontend/appflowy_flutter/pubspec.yaml index 85edb513ff..9e81b44df5 100644 --- a/frontend/appflowy_flutter/pubspec.yaml +++ b/frontend/appflowy_flutter/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 0.4.8 +version: 0.4.9 environment: flutter: ">=3.18.0-0.2.pre" diff --git a/frontend/rust-lib/flowy-server/src/af_cloud/server.rs b/frontend/rust-lib/flowy-server/src/af_cloud/server.rs index f82297356c..e3b1d3c9f2 100644 --- a/frontend/rust-lib/flowy-server/src/af_cloud/server.rs +++ b/frontend/rust-lib/flowy-server/src/af_cloud/server.rs @@ -110,7 +110,7 @@ impl AppFlowyServer for AppFlowyCloudServer { fn subscribe_token_state(&self) -> Option> { let mut token_state_rx = self.client.subscribe_token_state(); - let (watch_tx, watch_rx) = watch::channel(UserTokenState::Invalid); + let (watch_tx, watch_rx) = watch::channel(UserTokenState::Init); let weak_client = Arc::downgrade(&self.client); af_spawn(async move { while let Ok(token_state) = token_state_rx.recv().await { @@ -265,7 +265,7 @@ fn spawn_ws_conn( event!(tracing::Level::INFO, "🟢reconnecting websocket"); let _ = ws_client.connect(ws_addr, &cloned_device_id).await; }, - Err(err) => error!("Failed to get ws url: {}", err), + Err(err) => error!("Failed to get ws url: {}, connect state:{:?}", err, state), } } } @@ -288,6 +288,7 @@ fn spawn_ws_conn( let weak_api_client = Arc::downgrade(api_client); af_spawn(async move { while let Ok(token_state) = token_state_rx.recv().await { + info!("🟢token state: {:?}", token_state); match token_state { TokenState::Refresh => { if let (Some(api_client), Some(ws_client)) = @@ -295,7 +296,6 @@ fn spawn_ws_conn( { match api_client.ws_url(&device_id).await { Ok(ws_addr) => { - info!("🟢token state: {:?}, reconnecting websocket", token_state); let _ = ws_client.connect(ws_addr, &device_id).await; }, Err(err) => error!("Failed to get ws url: {}", err), diff --git a/frontend/rust-lib/flowy-user-pub/src/entities.rs b/frontend/rust-lib/flowy-user-pub/src/entities.rs index cebab74836..9728c0cd09 100644 --- a/frontend/rust-lib/flowy-user-pub/src/entities.rs +++ b/frontend/rust-lib/flowy-user-pub/src/entities.rs @@ -375,6 +375,7 @@ pub struct AFCloudOAuthParams { #[derive(Clone, Debug)] pub enum UserTokenState { + Init, Refresh { token: String }, Invalid, } diff --git a/frontend/rust-lib/flowy-user/src/user_manager/manager.rs b/frontend/rust-lib/flowy-user/src/user_manager/manager.rs index 1e44a19b0b..af75c0d395 100644 --- a/frontend/rust-lib/flowy-user/src/user_manager/manager.rs +++ b/frontend/rust-lib/flowy-user/src/user_manager/manager.rs @@ -227,8 +227,8 @@ impl UserManager { { error!("Sign out when token invalid failed: {:?}", err); } - // Force user to sign out when the token is invalid }, + UserTokenState::Init => {}, } } });