diff --git a/frontend/app_flowy/lib/user/application/user_listener.dart b/frontend/app_flowy/lib/user/application/user_listener.dart index 2f1b304455..aff5c18531 100644 --- a/frontend/app_flowy/lib/user/application/user_listener.dart +++ b/frontend/app_flowy/lib/user/application/user_listener.dart @@ -59,13 +59,7 @@ class UserListener { void _userNotificationCallback( user.UserNotification ty, Either result) { switch (ty) { - case user.UserNotification.UserUnauthorized: - result.fold( - (_) {}, - (error) => _authNotifier?.value = right(error), - ); - break; - case user.UserNotification.UserProfileUpdated: + case user.UserNotification.DidUpdateUserProfile: result.fold( (payload) => _profileNotifier?.value = left(UserProfilePB.fromBuffer(payload)), diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/user/application/notifications/user_listener.ts b/frontend/appflowy_tauri/src/appflowy_app/components/user/application/notifications/user_listener.ts index 851ef1557d..c8d57ebc36 100644 --- a/frontend/appflowy_tauri/src/appflowy_app/components/user/application/notifications/user_listener.ts +++ b/frontend/appflowy_tauri/src/appflowy_app/components/user/application/notifications/user_listener.ts @@ -18,14 +18,10 @@ export class UserNotificationListener extends AFNotificationListener { switch (notification) { - case UserNotification.UserAuthChanged: - break; - case UserNotification.UserProfileUpdated: + case UserNotification.DidUpdateUserProfile: this.onProfileUpdate?.(UserProfilePB.deserializeBinary(payload)); break; - case UserNotification.UserUnauthorized: - break; - case UserNotification.UserSignIn: + case UserNotification.DidUserSignIn: this.onUserSignIn?.(UserProfilePB.deserializeBinary(payload)); break; default: diff --git a/frontend/rust-lib/flowy-user/src/event_map.rs b/frontend/rust-lib/flowy-user/src/event_map.rs index 6280638064..37e0aae8ca 100644 --- a/frontend/rust-lib/flowy-user/src/event_map.rs +++ b/frontend/rust-lib/flowy-user/src/event_map.rs @@ -44,33 +44,43 @@ use strum_macros::Display; #[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)] #[event_err = "FlowyError"] pub enum UserEvent { - #[event()] - InitUser = 0, - + /// Logging into an account using a register email and password #[event(input = "SignInPayloadPB", output = "UserProfilePB")] - SignIn = 1, + SignIn = 0, + /// Creating a new account #[event(input = "SignUpPayloadPB", output = "UserProfilePB")] - SignUp = 2, + SignUp = 1, + /// Logging out fo an account #[event(passthrough)] - SignOut = 3, + SignOut = 2, + /// Update the user information #[event(input = "UpdateUserProfilePayloadPB")] - UpdateUserProfile = 4, + UpdateUserProfile = 3, + /// Get the user information #[event(output = "UserProfilePB")] - GetUserProfile = 5, + GetUserProfile = 4, + /// Check the user current session is valid or not #[event(output = "UserProfilePB")] - CheckUser = 6, + CheckUser = 5, + /// Initialize resources for the current user after launching the application + #[event()] + InitUser = 6, + + /// Change the visual elements of the interface, such as theme, font and more #[event(input = "AppearanceSettingsPB")] SetAppearanceSetting = 7, + /// Get the appearance setting #[event(output = "AppearanceSettingsPB")] GetAppearanceSetting = 8, + /// Get the settings of the user, such as the user storage folder #[event(output = "UserSettingPB")] GetUserSetting = 9, } diff --git a/frontend/rust-lib/flowy-user/src/notification.rs b/frontend/rust-lib/flowy-user/src/notification.rs index dd1ddb6e4c..1405eb7cc6 100644 --- a/frontend/rust-lib/flowy-user/src/notification.rs +++ b/frontend/rust-lib/flowy-user/src/notification.rs @@ -5,11 +5,8 @@ const OBSERVABLE_CATEGORY: &str = "User"; #[derive(ProtoBuf_Enum, Debug)] pub(crate) enum UserNotification { Unknown = 0, - UserAuthChanged = 1, - UserProfileUpdated = 2, - UserUnauthorized = 3, - UserWsConnectStateChanged = 4, - UserSignIn = 5, + DidUserSignIn = 1, + DidUpdateUserProfile = 2, } impl std::default::Default for UserNotification { @@ -29,5 +26,5 @@ pub(crate) fn send_notification(id: &str, ty: UserNotification) -> NotificationB } pub(crate) fn send_sign_in_notification() -> NotificationBuilder { - NotificationBuilder::new("", UserNotification::UserSignIn, OBSERVABLE_CATEGORY) + NotificationBuilder::new("", UserNotification::DidUserSignIn, OBSERVABLE_CATEGORY) } diff --git a/frontend/rust-lib/flowy-user/src/services/user_session.rs b/frontend/rust-lib/flowy-user/src/services/user_session.rs index 9d060df3c9..8a0ecfd0bb 100644 --- a/frontend/rust-lib/flowy-user/src/services/user_session.rs +++ b/frontend/rust-lib/flowy-user/src/services/user_session.rs @@ -161,7 +161,7 @@ impl UserSession { let user_profile = self.get_user_profile().await?; let profile_pb: UserProfilePB = user_profile.into(); - send_notification(&session.token, UserNotification::UserProfileUpdated) + send_notification(&session.token, UserNotification::DidUpdateUserProfile) .payload(profile_pb) .send(); self.update_user_on_server(&session.token, params).await?; @@ -220,22 +220,6 @@ impl UserSession { impl UserSession { fn read_user_profile_on_server(&self, _token: &str) -> Result<(), FlowyError> { - // let server = self.cloud_service.clone(); - // let token = token.to_owned(); - // tokio::spawn(async move { - // match server.get_user(&token).await { - // Ok(profile) => { - // dart_notify(&token, UserNotification::UserProfileUpdated) - // .payload(profile) - // .send(); - // } - // Err(e) => { - // dart_notify(&token, UserNotification::UserProfileUpdated) - // .error(e) - // .send(); - // } - // } - // }); Ok(()) }