Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
chore: add new event to update user name
appflowy8a0709ca231c
diff --git a/frontend/app_flowy/lib/workspace/application/menu/menu_user_bloc.dart b/frontend/app_flowy/lib/workspace/application/menu/menu_user_bloc.dartindex ee024bb1b2..07361cfe45 100644--- a/frontend/app_flowy/lib/workspace/application/menu/menu_user_bloc.dart+++ b/frontend/app_flowy/lib/workspace/application/menu/menu_user_bloc.dart@@ -31,6 +31,17 @@ class MenuUserBloc extends Bloc<MenuUserEvent, MenuUserState> {fetchWorkspaces: () async {//},+ didReceiveUserProfile: (UserProfile newUserProfile) {+ emit(state.copyWith(userProfile: newUserProfile));+ },+ updateUserName: (String name) {+ _userService.updateUserProfile(name: name).then((result) {+ result.fold(+ (l) => null,+ (err) => Log.error(err),+ );+ });+ },);});}@@ -47,7 +58,12 @@ class MenuUserBloc extends Bloc<MenuUserEvent, MenuUserState> {result.fold((l) => null, (error) => Log.error(error));}- void _profileUpdated(Either<UserProfile, FlowyError> userProfileOrFailed) {}+ void _profileUpdated(Either<UserProfile, FlowyError> userProfileOrFailed) {+ userProfileOrFailed.fold(+ (newUserProfile) => add(MenuUserEvent.didReceiveUserProfile(newUserProfile)),+ (err) => Log.error(err),+ );+ }void _workspaceListUpdated(Either<List<Workspace>, FlowyError> workspacesOrFailed) {// Do nothing by now@@ -58,6 +74,8 @@ class MenuUserBloc extends Bloc<MenuUserEvent, MenuUserState> {class MenuUserEvent with _$MenuUserEvent {const factory MenuUserEvent.initial() = _Initial;const factory MenuUserEvent.fetchWorkspaces() = _FetchWorkspaces;+ const factory MenuUserEvent.updateUserName(String name) = _UpdateUserName;+ const factory MenuUserEvent.didReceiveUserProfile(UserProfile newUserProfile) = _DidReceiveUserProfile;}@freezeddiff --git a/frontend/rust-lib/flowy-user/src/services/user_session.rs b/frontend/rust-lib/flowy-user/src/services/user_session.rsindex cf81b6be89..8167b05a19 100644--- a/frontend/rust-lib/flowy-user/src/services/user_session.rs+++ b/frontend/rust-lib/flowy-user/src/services/user_session.rs@@ -183,23 +183,23 @@ 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();- }- }- });+ 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(())}