docs: udpate user events (#1846)

This commit is contained in:
Nathan.fooo
2023-02-13 08:21:25 +08:00
committed by GitHub
parent 6c895ad4fe
commit e2496e734c
5 changed files with 26 additions and 45 deletions

View File

@ -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,
}

View File

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

View File

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