mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: add new event to update user name
This commit is contained in:
parent
957b83ecd5
commit
8a0709ca23
@ -31,6 +31,17 @@ class MenuUserBloc extends Bloc<MenuUserEvent, MenuUserState> {
|
|||||||
fetchWorkspaces: () async {
|
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));
|
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) {
|
void _workspaceListUpdated(Either<List<Workspace>, FlowyError> workspacesOrFailed) {
|
||||||
// Do nothing by now
|
// Do nothing by now
|
||||||
@ -58,6 +74,8 @@ class MenuUserBloc extends Bloc<MenuUserEvent, MenuUserState> {
|
|||||||
class MenuUserEvent with _$MenuUserEvent {
|
class MenuUserEvent with _$MenuUserEvent {
|
||||||
const factory MenuUserEvent.initial() = _Initial;
|
const factory MenuUserEvent.initial() = _Initial;
|
||||||
const factory MenuUserEvent.fetchWorkspaces() = _FetchWorkspaces;
|
const factory MenuUserEvent.fetchWorkspaces() = _FetchWorkspaces;
|
||||||
|
const factory MenuUserEvent.updateUserName(String name) = _UpdateUserName;
|
||||||
|
const factory MenuUserEvent.didReceiveUserProfile(UserProfile newUserProfile) = _DidReceiveUserProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
|
@ -183,23 +183,23 @@ impl UserSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl UserSession {
|
impl UserSession {
|
||||||
fn read_user_profile_on_server(&self, token: &str) -> Result<(), FlowyError> {
|
fn read_user_profile_on_server(&self, _token: &str) -> Result<(), FlowyError> {
|
||||||
let server = self.cloud_service.clone();
|
// let server = self.cloud_service.clone();
|
||||||
let token = token.to_owned();
|
// let token = token.to_owned();
|
||||||
tokio::spawn(async move {
|
// tokio::spawn(async move {
|
||||||
match server.get_user(&token).await {
|
// match server.get_user(&token).await {
|
||||||
Ok(profile) => {
|
// Ok(profile) => {
|
||||||
// dart_notify(&token, UserNotification::UserProfileUpdated)
|
// dart_notify(&token, UserNotification::UserProfileUpdated)
|
||||||
// .payload(profile)
|
// .payload(profile)
|
||||||
// .send();
|
// .send();
|
||||||
}
|
// }
|
||||||
Err(_e) => {
|
// Err(e) => {
|
||||||
// dart_notify(&token, UserNotification::UserProfileUpdated)
|
// dart_notify(&token, UserNotification::UserProfileUpdated)
|
||||||
// .error(e)
|
// .error(e)
|
||||||
// .send();
|
// .send();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user