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: reanme flowy-user crate
appflowy8e18d3a93784
diff --git a/frontend/app_flowy/lib/startup/deps_resolver.dart b/frontend/app_flowy/lib/startup/deps_resolver.dartindex 6f1d7e64a4..1864a2aa62 100644--- a/frontend/app_flowy/lib/startup/deps_resolver.dart+++ b/frontend/app_flowy/lib/startup/deps_resolver.dart@@ -51,14 +51,14 @@ void _resolveHomeDeps(GetIt getIt) {getIt.registerSingleton(MenuSharedState());- getIt.registerFactoryParam<UserListener, UserProfile, void>(+ getIt.registerFactoryParam<UserListener, UserProfilePB, void>((user, _) => UserListener(userProfile: user),);//getIt.registerLazySingleton<HomeStackManager>(() => HomeStackManager());- getIt.registerFactoryParam<WelcomeBloc, UserProfile, void>(+ getIt.registerFactoryParam<WelcomeBloc, UserProfilePB, void>((user, _) => WelcomeBloc(userService: UserService(userId: user.id),userWorkspaceListener: UserWorkspaceListener(userProfile: user),@@ -73,7 +73,7 @@ void _resolveHomeDeps(GetIt getIt) {void _resolveFolderDeps(GetIt getIt) {//workspace- getIt.registerFactoryParam<WorkspaceListener, UserProfile, String>(+ getIt.registerFactoryParam<WorkspaceListener, UserProfilePB, String>((user, workspaceId) => WorkspaceListener(user: user, workspaceId: workspaceId));// ViewPB@@ -90,14 +90,14 @@ void _resolveFolderDeps(GetIt getIt) {);//Menu- getIt.registerFactoryParam<MenuBloc, UserProfile, String>(+ getIt.registerFactoryParam<MenuBloc, UserProfilePB, String>((user, workspaceId) => MenuBloc(workspaceId: workspaceId,listener: getIt<WorkspaceListener>(param1: user, param2: workspaceId),),);- getIt.registerFactoryParam<MenuUserBloc, UserProfile, void>(+ getIt.registerFactoryParam<MenuUserBloc, UserProfilePB, void>((user, _) => MenuUserBloc(user),);diff --git a/frontend/app_flowy/lib/user/application/auth_service.dart b/frontend/app_flowy/lib/user/application/auth_service.dartindex 28f7dc5d0e..c2ce625ccf 100644--- a/frontend/app_flowy/lib/user/application/auth_service.dart+++ b/frontend/app_flowy/lib/user/application/auth_service.dart@@ -1,21 +1,21 @@import 'package:dartz/dartz.dart';import 'package:flowy_sdk/dispatch/dispatch.dart';-import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show SignInPayload, SignUpPayload, UserProfile;+import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show SignInPayloadPB, SignUpPayloadPB, UserProfilePB;import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';class AuthService {- Future<Either<UserProfile, FlowyError>> signIn({required String? email, required String? password}) {+ Future<Either<UserProfilePB, FlowyError>> signIn({required String? email, required String? password}) {//- final request = SignInPayload.create()+ final request = SignInPayloadPB.create()..email = email ?? ''..password = password ?? '';return UserEventSignIn(request).send();}- Future<Either<UserProfile, FlowyError>> signUp(+ Future<Either<UserProfilePB, FlowyError>> signUp({required String? name, required String? password, required String? email}) {- final request = SignUpPayload.create()+ final request = SignUpPayloadPB.create()..email = email ?? ''..name = name ?? ''..password = password ?? '';diff --git a/frontend/app_flowy/lib/user/application/sign_in_bloc.dart b/frontend/app_flowy/lib/user/application/sign_in_bloc.dartindex 45b6ee1eb5..1b5838d9c4 100644--- a/frontend/app_flowy/lib/user/application/sign_in_bloc.dart+++ b/frontend/app_flowy/lib/user/application/sign_in_bloc.dart@@ -2,7 +2,7 @@ import 'package:app_flowy/user/application/auth_service.dart';import 'package:dartz/dartz.dart';import 'package:flowy_sdk/protobuf/flowy-error-code/code.pb.dart';import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';-import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfile;+import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfilePB;import 'package:freezed_annotation/freezed_annotation.dart';import 'package:flutter_bloc/flutter_bloc.dart';@@ -69,7 +69,7 @@ class SignInState with _$SignInState {required bool isSubmitting,required Option<String> passwordError,required Option<String> emailError,- required Option<Either<UserProfile, FlowyError>> successOrFail,+ required Option<Either<UserProfilePB, FlowyError>> successOrFail,}) = _SignInState;factory SignInState.initial() => SignInState(diff --git a/frontend/app_flowy/lib/user/application/sign_up_bloc.dart b/frontend/app_flowy/lib/user/application/sign_up_bloc.dartindex b94a02bf09..0c103fd4d7 100644--- a/frontend/app_flowy/lib/user/application/sign_up_bloc.dart+++ b/frontend/app_flowy/lib/user/application/sign_up_bloc.dart@@ -2,7 +2,7 @@ import 'package:app_flowy/user/application/auth_service.dart';import 'package:dartz/dartz.dart';import 'package:easy_localization/easy_localization.dart';import 'package:flowy_sdk/protobuf/flowy-error-code/code.pb.dart';-import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfile;+import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfilePB;import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';import 'package:freezed_annotation/freezed_annotation.dart';import 'package:flutter_bloc/flutter_bloc.dart';@@ -120,7 +120,7 @@ class SignUpState with _$SignUpState {required Option<String> passwordError,required Option<String> repeatPasswordError,required Option<String> emailError,- required Option<Either<UserProfile, FlowyError>> successOrFail,+ required Option<Either<UserProfilePB, FlowyError>> successOrFail,}) = _SignUpState;factory SignUpState.initial() => SignUpState(diff --git a/frontend/app_flowy/lib/user/application/user_listener.dart b/frontend/app_flowy/lib/user/application/user_listener.dartindex ec3cd5ac1d..5483926e71 100644--- a/frontend/app_flowy/lib/user/application/user_listener.dart+++ b/frontend/app_flowy/lib/user/application/user_listener.dart@@ -13,7 +13,7 @@ import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';import 'package:flowy_sdk/protobuf/flowy-user/dart_notification.pb.dart' as user;import 'package:flowy_sdk/rust_stream.dart';-typedef UserProfileNotifyValue = Either<UserProfile, FlowyError>;+typedef UserProfileNotifyValue = Either<UserProfilePB, FlowyError>;typedef AuthNotifyValue = Either<Unit, FlowyError>;class UserListener {@@ -22,9 +22,9 @@ class UserListener {PublishNotifier<UserProfileNotifyValue>? _profileNotifier = PublishNotifier();UserNotificationParser? _userParser;- final UserProfile _userProfile;+ final UserProfilePB _userProfile;UserListener({- required UserProfile userProfile,+ required UserProfilePB userProfile,}) : _userProfile = userProfile;void start({@@ -65,7 +65,7 @@ class UserListener {break;case user.UserNotification.UserProfileUpdated:result.fold(- (payload) => _profileNotifier?.value = left(UserProfile.fromBuffer(payload)),+ (payload) => _profileNotifier?.value = left(UserProfilePB.fromBuffer(payload)),(error) => _profileNotifier?.value = right(error),);break;@@ -84,10 +84,10 @@ class UserWorkspaceListener {PublishNotifier<WorkspaceSettingNotifyValue>? _settingChangedNotifier = PublishNotifier();FolderNotificationListener? _listener;- final UserProfile _userProfile;+ final UserProfilePB _userProfile;UserWorkspaceListener({- required UserProfile userProfile,+ required UserProfilePB userProfile,}) : _userProfile = userProfile;void start({diff --git a/frontend/app_flowy/lib/user/application/user_service.dart b/frontend/app_flowy/lib/user/application/user_service.dartindex 8685205567..48bea6aa41 100644--- a/frontend/app_flowy/lib/user/application/user_service.dart+++ b/frontend/app_flowy/lib/user/application/user_service.dart@@ -11,7 +11,7 @@ class UserService {UserService({required this.userId,});- Future<Either<UserProfile, FlowyError>> getUserProfile({required String userId}) {+ Future<Either<UserProfilePB, FlowyError>> getUserProfile({required String userId}) {return UserEventGetUserProfile().send();}@@ -20,7 +20,7 @@ class UserService {String? password,String? email,}) {- var payload = UpdateUserProfilePayload.create()..id = userId;+ var payload = UpdateUserProfilePayloadPB.create()..id = userId;if (name != null) {payload.name = name;diff --git a/frontend/app_flowy/lib/user/application/user_settings_service.dart b/frontend/app_flowy/lib/user/application/user_settings_service.dartindex eb93ab150d..28309d202c 100644--- a/frontend/app_flowy/lib/user/application/user_settings_service.dart+++ b/frontend/app_flowy/lib/user/application/user_settings_service.dart@@ -5,11 +5,11 @@ import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';import 'package:flowy_sdk/protobuf/flowy-user/user_setting.pb.dart';class UserSettingsService {- Future<AppearanceSettings> getAppearanceSettings() async {+ Future<AppearanceSettingsPB> getAppearanceSettings() async {final result = await UserEventGetAppearanceSetting().send();return result.fold(- (AppearanceSettings setting) {+ (AppearanceSettingsPB setting) {return setting;},(error) {@@ -18,7 +18,7 @@ class UserSettingsService {);}- Future<Either<Unit, FlowyError>> setAppearanceSettings(AppearanceSettings settings) {+ Future<Either<Unit, FlowyError>> setAppearanceSettings(AppearanceSettingsPB settings) {return UserEventSetAppearanceSetting(settings).send();}}diff --git a/frontend/app_flowy/lib/user/domain/auth_state.dart b/frontend/app_flowy/lib/user/domain/auth_state.dartindex e2d3a33b09..ae0c259573 100644--- a/frontend/app_flowy/lib/user/domain/auth_state.dart+++ b/frontend/app_flowy/lib/user/domain/auth_state.dart@@ -1,11 +1,11 @@-import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfile;+import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfilePB;import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';import 'package:freezed_annotation/freezed_annotation.dart';part 'auth_state.freezed.dart';@freezedclass AuthState with _$AuthState {- const factory AuthState.authenticated(UserProfile userProfile) = Authenticated;+ const factory AuthState.authenticated(UserProfilePB userProfile) = Authenticated;const factory AuthState.unauthenticated(FlowyError error) = Unauthenticated;const factory AuthState.initial() = _Initial;}diff --git a/frontend/app_flowy/lib/user/presentation/router.dart b/frontend/app_flowy/lib/user/presentation/router.dartindex 5f863a8d99..2928154ebe 100644--- a/frontend/app_flowy/lib/user/presentation/router.dart+++ b/frontend/app_flowy/lib/user/presentation/router.dart@@ -7,7 +7,7 @@ import 'package:app_flowy/user/presentation/welcome_screen.dart';import 'package:app_flowy/workspace/presentation/home/home_screen.dart';import 'package:flowy_infra/time/duration.dart';import 'package:flowy_infra_ui/widget/route/animation.dart';-import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfile;+import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfilePB;import 'package:flowy_sdk/protobuf/flowy-folder/protobuf.dart';import 'package:flutter/material.dart';@@ -16,7 +16,7 @@ class AuthRouter {// TODO: implement showForgetPasswordScreen}- void pushWelcomeScreen(BuildContext context, UserProfile userProfile) {+ void pushWelcomeScreen(BuildContext context, UserProfilePB userProfile) {getIt<SplashRoute>().pushWelcomeScreen(context, userProfile);}@@ -28,7 +28,7 @@ class AuthRouter {);}- void pushHomeScreen(BuildContext context, UserProfile profile, CurrentWorkspaceSettingPB workspaceSetting) {+ void pushHomeScreen(BuildContext context, UserProfilePB profile, CurrentWorkspaceSettingPB workspaceSetting) {Navigator.push(context,PageRoutes.fade(() => HomeScreen(profile, workspaceSetting), RouteDurations.slow.inMilliseconds * .001),@@ -37,7 +37,7 @@ class AuthRouter {}class SplashRoute {- Future<void> pushWelcomeScreen(BuildContext context, UserProfile userProfile) async {+ Future<void> pushWelcomeScreen(BuildContext context, UserProfilePB userProfile) async {final screen = WelcomeScreen(userProfile: userProfile);final workspaceId = await Navigator.of(context).push(PageRoutes.fade(@@ -49,7 +49,7 @@ class SplashRoute {pushHomeScreen(context, userProfile, workspaceId);}- void pushHomeScreen(BuildContext context, UserProfile userProfile, CurrentWorkspaceSettingPB workspaceSetting) {+ void pushHomeScreen(BuildContext context, UserProfilePB userProfile, CurrentWorkspaceSettingPB workspaceSetting) {Navigator.push(context,PageRoutes.fade(() => HomeScreen(userProfile, workspaceSetting), RouteDurations.slow.inMilliseconds * .001),diff --git a/frontend/app_flowy/lib/user/presentation/sign_in_screen.dart b/frontend/app_flowy/lib/user/presentation/sign_in_screen.dartindex baa8ef0ccb..ee3600e782 100644--- a/frontend/app_flowy/lib/user/presentation/sign_in_screen.dart+++ b/frontend/app_flowy/lib/user/presentation/sign_in_screen.dart@@ -10,7 +10,7 @@ import 'package:flowy_infra_ui/widget/rounded_input_field.dart';import 'package:flowy_infra_ui/widget/spacing.dart';import 'package:flowy_infra_ui/style_widget/snap_bar.dart';import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';-import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfile;+import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfilePB;import 'package:flutter/material.dart';import 'package:flutter_bloc/flutter_bloc.dart';import 'package:dartz/dartz.dart';@@ -39,7 +39,7 @@ class SignInScreen extends StatelessWidget {);}- void _handleSuccessOrFail(Either<UserProfile, FlowyError> result, BuildContext context) {+ void _handleSuccessOrFail(Either<UserProfilePB, FlowyError> result, BuildContext context) {result.fold((user) => router.pushWelcomeScreen(context, user),(error) => showSnapBar(context, error.msg),diff --git a/frontend/app_flowy/lib/user/presentation/sign_up_screen.dart b/frontend/app_flowy/lib/user/presentation/sign_up_screen.dartindex 6a0b8f1d85..d0cb7f8b90 100644--- a/frontend/app_flowy/lib/user/presentation/sign_up_screen.dart+++ b/frontend/app_flowy/lib/user/presentation/sign_up_screen.dart@@ -8,7 +8,7 @@ import 'package:flowy_infra_ui/widget/rounded_button.dart';import 'package:flowy_infra_ui/widget/rounded_input_field.dart';import 'package:flowy_infra_ui/widget/spacing.dart';import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';-import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfile;+import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfilePB;import 'package:flowy_infra_ui/style_widget/snap_bar.dart';import 'package:flutter/material.dart';import 'package:flutter_bloc/flutter_bloc.dart';@@ -36,7 +36,7 @@ class SignUpScreen extends StatelessWidget {);}- void _handleSuccessOrFail(BuildContext context, Either<UserProfile, FlowyError> result) {+ void _handleSuccessOrFail(BuildContext context, Either<UserProfilePB, FlowyError> result) {result.fold((user) => router.pushWelcomeScreen(context, user),(error) => showSnapBar(context, error.msg),diff --git a/frontend/app_flowy/lib/user/presentation/skip_log_in_screen.dart b/frontend/app_flowy/lib/user/presentation/skip_log_in_screen.dartindex a6feeae3ff..6e3ae5ea52 100644--- a/frontend/app_flowy/lib/user/presentation/skip_log_in_screen.dart+++ b/frontend/app_flowy/lib/user/presentation/skip_log_in_screen.dart@@ -116,7 +116,7 @@ class _SkipLogInScreenState extends State<SkipLogInScreen> {void _openCurrentWorkspace(BuildContext context,- UserProfile user,+ UserProfilePB user,dartz.Either<CurrentWorkspaceSettingPB, FlowyError> workspacesOrError,) {workspacesOrError.fold(diff --git a/frontend/app_flowy/lib/user/presentation/welcome_screen.dart b/frontend/app_flowy/lib/user/presentation/welcome_screen.dartindex 45a3ce9bcc..31b06d8bd1 100644--- a/frontend/app_flowy/lib/user/presentation/welcome_screen.dart+++ b/frontend/app_flowy/lib/user/presentation/welcome_screen.dart@@ -12,7 +12,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';import 'package:app_flowy/generated/locale_keys.g.dart';class WelcomeScreen extends StatelessWidget {- final UserProfile userProfile;+ final UserProfilePB userProfile;const WelcomeScreen({Key? key,required this.userProfile,diff --git a/frontend/app_flowy/lib/workspace/application/appearance.dart b/frontend/app_flowy/lib/workspace/application/appearance.dartindex f3ff7801ce..0e47fa2be6 100644--- a/frontend/app_flowy/lib/workspace/application/appearance.dart+++ b/frontend/app_flowy/lib/workspace/application/appearance.dart@@ -9,7 +9,7 @@ import 'package:flutter/material.dart';import 'package:easy_localization/easy_localization.dart';class AppearanceSettingModel extends ChangeNotifier with EquatableMixin {- AppearanceSettings setting;+ AppearanceSettingsPB setting;AppTheme _theme;Locale _locale;Timer? _saveOperation;diff --git a/frontend/app_flowy/lib/workspace/application/home/home_bloc.dart b/frontend/app_flowy/lib/workspace/application/home/home_bloc.dartindex 21f29d2658..a4ddef0945 100644--- a/frontend/app_flowy/lib/workspace/application/home/home_bloc.dart+++ b/frontend/app_flowy/lib/workspace/application/home/home_bloc.dart@@ -13,7 +13,7 @@ part 'home_bloc.freezed.dart';class HomeBloc extends Bloc<HomeEvent, HomeState> {final UserWorkspaceListener _listener;- HomeBloc(UserProfile user, CurrentWorkspaceSettingPB workspaceSetting)+ HomeBloc(UserProfilePB user, CurrentWorkspaceSettingPB workspaceSetting): _listener = UserWorkspaceListener(userProfile: user),super(HomeState.initial(workspaceSetting)) {on<HomeEvent>((event, emit) async {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 ce222e4eac..0f30bb9d45 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@@ -14,7 +14,7 @@ class MenuUserBloc extends Bloc<MenuUserEvent, MenuUserState> {final UserService _userService;final UserListener _userListener;final UserWorkspaceListener _userWorkspaceListener;- final UserProfile userProfile;+ final UserProfilePB userProfile;MenuUserBloc(this.userProfile): _userListener = UserListener(userProfile: userProfile),@@ -31,7 +31,7 @@ class MenuUserBloc extends Bloc<MenuUserEvent, MenuUserState> {fetchWorkspaces: () async {//},- didReceiveUserProfile: (UserProfile newUserProfile) {+ didReceiveUserProfile: (UserProfilePB newUserProfile) {emit(state.copyWith(userProfile: newUserProfile));},updateUserName: (String name) {@@ -58,7 +58,7 @@ class MenuUserBloc extends Bloc<MenuUserEvent, MenuUserState> {result.fold((l) => null, (error) => Log.error(error));}- void _profileUpdated(Either<UserProfile, FlowyError> userProfileOrFailed) {+ void _profileUpdated(Either<UserProfilePB, FlowyError> userProfileOrFailed) {userProfileOrFailed.fold((newUserProfile) => add(MenuUserEvent.didReceiveUserProfile(newUserProfile)),(err) => Log.error(err),@@ -75,18 +75,18 @@ 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;+ const factory MenuUserEvent.didReceiveUserProfile(UserProfilePB newUserProfile) = _DidReceiveUserProfile;}@freezedclass MenuUserState with _$MenuUserState {const factory MenuUserState({- required UserProfile userProfile,+ required UserProfilePB userProfile,required Option<List<WorkspacePB>> workspaces,required Either<Unit, String> successOrFailure,}) = _MenuUserState;- factory MenuUserState.initial(UserProfile userProfile) => MenuUserState(+ factory MenuUserState.initial(UserProfilePB userProfile) => MenuUserState(userProfile: userProfile,workspaces: none(),successOrFailure: left(unit),diff --git a/frontend/app_flowy/lib/workspace/application/workspace/workspace_listener.dart b/frontend/app_flowy/lib/workspace/application/workspace/workspace_listener.dartindex dab4d7cbcf..2d7a100e8b 100644--- a/frontend/app_flowy/lib/workspace/application/workspace/workspace_listener.dart+++ b/frontend/app_flowy/lib/workspace/application/workspace/workspace_listener.dart@@ -3,7 +3,7 @@ import 'dart:typed_data';import 'package:app_flowy/core/folder_notification.dart';import 'package:dartz/dartz.dart';import 'package:flowy_infra/notifier.dart';-import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfile;+import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfilePB;import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart';import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart';import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';@@ -17,7 +17,7 @@ class WorkspaceListener {PublishNotifier<WorkspaceNotifyValue>? _workspaceUpdatedNotifier = PublishNotifier();FolderNotificationListener? _listener;- final UserProfile user;+ final UserProfilePB user;final String workspaceId;WorkspaceListener({diff --git a/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart b/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dartindex a9aa15a77a..f3a9f6773a 100644--- a/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart+++ b/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart@@ -5,7 +5,7 @@ import 'package:app_flowy/workspace/presentation/widgets/float_bubble/question_bimport 'package:app_flowy/startup/startup.dart';import 'package:flowy_sdk/log.dart';import 'package:flowy_infra_ui/style_widget/container.dart';-import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfile;+import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfilePB;import 'package:flowy_sdk/protobuf/flowy-folder/protobuf.dart';import 'package:flutter/material.dart';import 'package:flutter_bloc/flutter_bloc.dart';@@ -18,7 +18,7 @@ import 'home_stack.dart';import 'menu/menu.dart';class HomeScreen extends StatefulWidget {- final UserProfile user;+ final UserProfilePB user;final CurrentWorkspaceSettingPB workspaceSetting;const HomeScreen(this.user, this.workspaceSetting, {Key? key}) : super(key: key);diff --git a/frontend/app_flowy/lib/workspace/presentation/home/menu/menu.dart b/frontend/app_flowy/lib/workspace/presentation/home/menu/menu.dartindex 529441df82..ef5e20bb6b 100644--- a/frontend/app_flowy/lib/workspace/presentation/home/menu/menu.dart+++ b/frontend/app_flowy/lib/workspace/presentation/home/menu/menu.dart@@ -10,7 +10,7 @@ import 'package:flowy_infra/size.dart';import 'package:flowy_infra/theme.dart';import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart';import 'package:flowy_infra_ui/widget/spacing.dart';-import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfile;+import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfilePB;import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart';import 'package:flutter/material.dart';@@ -32,7 +32,7 @@ import 'menu_user.dart';class HomeMenu extends StatelessWidget {final PublishNotifier<bool> _collapsedNotifier;- final UserProfile user;+ final UserProfilePB user;final CurrentWorkspaceSettingPB workspaceSetting;const HomeMenu({diff --git a/frontend/app_flowy/lib/workspace/presentation/home/menu/menu_user.dart b/frontend/app_flowy/lib/workspace/presentation/home/menu/menu_user.dartindex 6b75c9ef3f..6c9ffdece2 100644--- a/frontend/app_flowy/lib/workspace/presentation/home/menu/menu_user.dart+++ b/frontend/app_flowy/lib/workspace/presentation/home/menu/menu_user.dart@@ -6,14 +6,14 @@ import 'package:flowy_infra/size.dart';import 'package:flowy_infra/theme.dart';import 'package:flowy_infra_ui/style_widget/text.dart';import 'package:flowy_infra_ui/widget/spacing.dart';-import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfile;+import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfilePB;import 'package:flutter/material.dart';import 'package:flutter_bloc/flutter_bloc.dart';import 'package:app_flowy/generated/locale_keys.g.dart';import 'package:easy_localization/easy_localization.dart';class MenuUser extends StatelessWidget {- final UserProfile user;+ final UserProfilePB user;MenuUser(this.user, {Key? key}) : super(key: ValueKey(user.id));@overridediff --git a/frontend/app_flowy/test/util/test_env.dart b/frontend/app_flowy/test/util/test_env.dartindex 40006295a4..1743e4b920 100644--- a/frontend/app_flowy/test/util/test_env.dart+++ b/frontend/app_flowy/test/util/test_env.dart@@ -14,7 +14,7 @@ class FlowyTest {return FlowyTest();}- Future<UserProfile> signIn() async {+ Future<UserProfilePB> signIn() async {final authService = getIt<AuthService>();const password = "AppFlowy123@";final uid = uuid();diff --git a/frontend/app_flowy/test/workspace_bloc_test.dart b/frontend/app_flowy/test/workspace_bloc_test.dartindex 680726b401..d0b898cc42 100644--- a/frontend/app_flowy/test/workspace_bloc_test.dart+++ b/frontend/app_flowy/test/workspace_bloc_test.dart@@ -7,7 +7,7 @@ import 'package:bloc_test/bloc_test.dart';import 'util/test_env.dart';void main() {- UserProfile? userInfo;+ UserProfilePB? userInfo;setUpAll(() async {final flowyTest = await FlowyTest.setup();userInfo = await flowyTest.signIn();diff --git a/frontend/rust-lib/flowy-net/src/http_server/user.rs b/frontend/rust-lib/flowy-net/src/http_server/user.rsindex faf5621161..7768c91bb6 100644--- a/frontend/rust-lib/flowy-net/src/http_server/user.rs+++ b/frontend/rust-lib/flowy-net/src/http_server/user.rs@@ -1,7 +1,7 @@use crate::{configuration::*, request::HttpRequestBuilder};use flowy_error::FlowyError;use flowy_user::entities::{- SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserProfileParams, UserProfile,+ SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserProfileParams, UserProfilePB,};use flowy_user::event_map::UserCloudService;use http_flowy::errors::ServerError;@@ -51,7 +51,7 @@ impl UserCloudService for UserHttpCloudService {})}- fn get_user(&self, token: &str) -> FutureResult<UserProfile, FlowyError> {+ fn get_user(&self, token: &str) -> FutureResult<UserProfilePB, FlowyError> {let token = token.to_owned();let url = self.config.user_profile_url();FutureResult::new(async move {@@ -92,7 +92,7 @@ pub async fn user_sign_out_request(token: &str, url: &str) -> Result<(), ServerEOk(())}-pub async fn get_user_profile_request(token: &str, url: &str) -> Result<UserProfile, ServerError> {+pub async fn get_user_profile_request(token: &str, url: &str) -> Result<UserProfilePB, ServerError> {let user_profile = request_builder().get(&url.to_owned()).header(HEADER_TOKEN, token)diff --git a/frontend/rust-lib/flowy-net/src/local_server/server.rs b/frontend/rust-lib/flowy-net/src/local_server/server.rsindex e6ee90df69..338697f432 100644--- a/frontend/rust-lib/flowy-net/src/local_server/server.rs+++ b/frontend/rust-lib/flowy-net/src/local_server/server.rs@@ -263,7 +263,7 @@ use flowy_folder_data_model::revision::{};use flowy_text_block::BlockCloudService;use flowy_user::entities::{- SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserProfileParams, UserProfile,+ SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserProfileParams, UserProfilePB,};use flowy_user::event_map::UserCloudService;use lib_infra::{future::FutureResult, util::timestamp};@@ -405,8 +405,8 @@ impl UserCloudService for LocalServer {FutureResult::new(async { Ok(()) })}- fn get_user(&self, _token: &str) -> FutureResult<UserProfile, FlowyError> {- FutureResult::new(async { Ok(UserProfile::default()) })+ fn get_user(&self, _token: &str) -> FutureResult<UserProfilePB, FlowyError> {+ FutureResult::new(async { Ok(UserProfilePB::default()) })}fn ws_addr(&self) -> String {diff --git a/frontend/rust-lib/flowy-test/src/event_builder.rs b/frontend/rust-lib/flowy-test/src/event_builder.rsindex ed6f3c3bc8..d9841d6b4a 100644--- a/frontend/rust-lib/flowy-test/src/event_builder.rs+++ b/frontend/rust-lib/flowy-test/src/event_builder.rs@@ -1,5 +1,5 @@use crate::FlowySDKTest;-use flowy_user::{entities::UserProfile, errors::FlowyError};+use flowy_user::{entities::UserProfilePB, errors::FlowyError};use lib_dispatch::prelude::{EventDispatcher, EventResponse, FromBytes, ModuleRequest, StatusCode, ToBytes, *};use std::{convert::TryFrom,@@ -14,7 +14,7 @@ impl FolderEventBuilder {pub fn new(sdk: FlowySDKTest) -> Self {EventBuilder::test(TestContext::new(sdk))}- pub fn user_profile(&self) -> &Option<UserProfile> {+ pub fn user_profile(&self) -> &Option<UserProfilePB> {&self.user_profile}}@@ -24,7 +24,7 @@ pub type UserModuleEventBuilder = FolderEventBuilder;#[derive(Clone)]pub struct EventBuilder<E> {context: TestContext,- user_profile: Option<UserProfile>,+ user_profile: Option<UserProfilePB>,err_phantom: PhantomData<E>,}diff --git a/frontend/rust-lib/flowy-test/src/helper.rs b/frontend/rust-lib/flowy-test/src/helper.rsindex dda5e31370..1265bd695c 100644--- a/frontend/rust-lib/flowy-test/src/helper.rs+++ b/frontend/rust-lib/flowy-test/src/helper.rs@@ -9,7 +9,7 @@ use flowy_folder::{event_map::FolderEvent::{CreateWorkspace, OpenWorkspace, *},};use flowy_user::{- entities::{SignInPayload, SignUpPayload, UserProfile},+ entities::{SignInPayloadPB, SignUpPayloadPB, UserProfilePB},errors::FlowyError,event_map::UserEvent::{InitUser, SignIn, SignOut, SignUp},};@@ -138,13 +138,13 @@ pub fn login_password() -> String {}pub struct SignUpContext {- pub user_profile: UserProfile,+ pub user_profile: UserProfilePB,pub password: String,}pub fn sign_up(dispatch: Arc<EventDispatcher>) -> SignUpContext {let password = login_password();- let payload = SignUpPayload {+ let payload = SignUpPayloadPB {email: random_email(),name: "app flowy".to_string(),password: password.clone(),@@ -154,7 +154,7 @@ pub fn sign_up(dispatch: Arc<EventDispatcher>) -> SignUpContext {let request = ModuleRequest::new(SignUp).payload(payload);let user_profile = EventDispatcher::sync_send(dispatch, request)- .parse::<UserProfile, FlowyError>()+ .parse::<UserProfilePB, FlowyError>().unwrap().unwrap();@@ -164,7 +164,7 @@ pub fn sign_up(dispatch: Arc<EventDispatcher>) -> SignUpContext {pub async fn async_sign_up(dispatch: Arc<EventDispatcher>) -> SignUpContext {let password = login_password();let email = random_email();- let payload = SignUpPayload {+ let payload = SignUpPayloadPB {email,name: "app flowy".to_string(),password: password.clone(),@@ -175,7 +175,7 @@ pub async fn async_sign_up(dispatch: Arc<EventDispatcher>) -> SignUpContext {let request = ModuleRequest::new(SignUp).payload(payload);let user_profile = EventDispatcher::async_send(dispatch.clone(), request).await- .parse::<UserProfile, FlowyError>()+ .parse::<UserProfilePB, FlowyError>().unwrap().unwrap();@@ -189,8 +189,8 @@ pub async fn init_user_setting(dispatch: Arc<EventDispatcher>) {}#[allow(dead_code)]-fn sign_in(dispatch: Arc<EventDispatcher>) -> UserProfile {- let payload = SignInPayload {+fn sign_in(dispatch: Arc<EventDispatcher>) -> UserProfilePB {+ let payload = SignInPayloadPB {email: login_email(),password: login_password(),name: "rust".to_owned(),@@ -200,7 +200,7 @@ fn sign_in(dispatch: Arc<EventDispatcher>) -> UserProfile {let request = ModuleRequest::new(SignIn).payload(payload);EventDispatcher::sync_send(dispatch, request)- .parse::<UserProfile, FlowyError>()+ .parse::<UserProfilePB, FlowyError>().unwrap().unwrap()}diff --git a/frontend/rust-lib/flowy-test/src/lib.rs b/frontend/rust-lib/flowy-test/src/lib.rsindex 70159edf19..8f6aacb44d 100644--- a/frontend/rust-lib/flowy-test/src/lib.rs+++ b/frontend/rust-lib/flowy-test/src/lib.rs@@ -4,7 +4,7 @@ pub mod helper;use crate::helper::*;use flowy_net::{get_client_server_configuration, ClientServerConfiguration};use flowy_sdk::{FlowySDK, FlowySDKConfig};-use flowy_user::entities::UserProfile;+use flowy_user::entities::UserProfilePB;use nanoid::nanoid;pub mod prelude {@@ -47,7 +47,7 @@ impl FlowySDKTest {context}- pub async fn init_user(&self) -> UserProfile {+ pub async fn init_user(&self) -> UserProfilePB {let context = async_sign_up(self.inner.dispatcher()).await;init_user_setting(self.inner.dispatcher()).await;context.user_profilediff --git a/frontend/rust-lib/flowy-user/src/entities/auth.rs b/frontend/rust-lib/flowy-user/src/entities/auth.rsindex 14224ae231..f7625b37d7 100644--- a/frontend/rust-lib/flowy-user/src/entities/auth.rs+++ b/frontend/rust-lib/flowy-user/src/entities/auth.rs@@ -4,7 +4,7 @@ use flowy_derive::ProtoBuf;use std::convert::TryInto;#[derive(ProtoBuf, Default)]-pub struct SignInPayload {+pub struct SignInPayloadPB {#[pb(index = 1)]pub email: String,@@ -42,7 +42,7 @@ pub struct SignInResponse {pub token: String,}-impl TryInto<SignInParams> for SignInPayload {+impl TryInto<SignInParams> for SignInPayloadPB {type Error = ErrorCode;fn try_into(self) -> Result<SignInParams, Self::Error> {@@ -58,7 +58,7 @@ impl TryInto<SignInParams> for SignInPayload {}#[derive(ProtoBuf, Default)]-pub struct SignUpPayload {+pub struct SignUpPayloadPB {#[pb(index = 1)]pub email: String,@@ -68,7 +68,7 @@ pub struct SignUpPayload {#[pb(index = 3)]pub password: String,}-impl TryInto<SignUpParams> for SignUpPayload {+impl TryInto<SignUpParams> for SignUpPayloadPB {type Error = ErrorCode;fn try_into(self) -> Result<SignUpParams, Self::Error> {diff --git a/frontend/rust-lib/flowy-user/src/entities/user_profile.rs b/frontend/rust-lib/flowy-user/src/entities/user_profile.rsindex 82553e8050..276894ffc8 100644--- a/frontend/rust-lib/flowy-user/src/entities/user_profile.rs+++ b/frontend/rust-lib/flowy-user/src/entities/user_profile.rs@@ -7,13 +7,13 @@ use crate::{};#[derive(Default, ProtoBuf)]-pub struct UserToken {+pub struct UserTokenPB {#[pb(index = 1)]pub token: String,}#[derive(ProtoBuf, Default, Debug, PartialEq, Eq, Clone)]-pub struct UserProfile {+pub struct UserProfilePB {#[pb(index = 1)]pub id: String,@@ -28,7 +28,7 @@ pub struct UserProfile {}#[derive(ProtoBuf, Default)]-pub struct UpdateUserProfilePayload {+pub struct UpdateUserProfilePayloadPB {#[pb(index = 1)]pub id: String,@@ -42,7 +42,7 @@ pub struct UpdateUserProfilePayload {pub password: Option<String>,}-impl UpdateUserProfilePayload {+impl UpdateUserProfilePayloadPB {pub fn new(id: &str) -> Self {Self {id: id.to_owned(),@@ -85,7 +85,9 @@ impl UpdateUserProfileParams {pub fn new(user_id: &str) -> Self {Self {id: user_id.to_owned(),- ..Default::default()+ name: None,+ email: None,+ password: None,}}@@ -105,7 +107,7 @@ impl UpdateUserProfileParams {}}-impl TryInto<UpdateUserProfileParams> for UpdateUserProfilePayload {+impl TryInto<UpdateUserProfileParams> for UpdateUserProfilePayloadPB {type Error = ErrorCode;fn try_into(self) -> Result<UpdateUserProfileParams, Self::Error> {diff --git a/frontend/rust-lib/flowy-user/src/entities/user_setting.rs b/frontend/rust-lib/flowy-user/src/entities/user_setting.rsindex 8f7beadb4a..23c74b6d5f 100644--- a/frontend/rust-lib/flowy-user/src/entities/user_setting.rs+++ b/frontend/rust-lib/flowy-user/src/entities/user_setting.rs@@ -2,22 +2,22 @@ use flowy_derive::ProtoBuf;use serde::{Deserialize, Serialize};#[derive(ProtoBuf, Default, Debug, Clone)]-pub struct UserPreferences {+pub struct UserPreferencesPB {#[pb(index = 1)]user_id: String,#[pb(index = 2)]- appearance_setting: AppearanceSettings,+ appearance_setting: AppearanceSettingsPB,}#[derive(ProtoBuf, Serialize, Deserialize, Debug, Clone)]-pub struct AppearanceSettings {+pub struct AppearanceSettingsPB {#[pb(index = 1)]pub theme: String,#[pb(index = 2)]#[serde(default)]- pub locale: LocaleSettings,+ pub locale: LocaleSettingsPB,#[pb(index = 3)]#[serde(default = "DEFAULT_RESET_VALUE")]@@ -27,7 +27,7 @@ pub struct AppearanceSettings {const DEFAULT_RESET_VALUE: fn() -> bool = || APPEARANCE_RESET_AS_DEFAULT;#[derive(ProtoBuf, Serialize, Deserialize, Debug, Clone)]-pub struct LocaleSettings {+pub struct LocaleSettingsPB {#[pb(index = 1)]pub language_code: String,@@ -35,7 +35,7 @@ pub struct LocaleSettings {pub country_code: String,}-impl std::default::Default for LocaleSettings {+impl std::default::Default for LocaleSettingsPB {fn default() -> Self {Self {language_code: "en".to_owned(),@@ -47,11 +47,11 @@ impl std::default::Default for LocaleSettings {pub const APPEARANCE_DEFAULT_THEME: &str = "light";const APPEARANCE_RESET_AS_DEFAULT: bool = true;-impl std::default::Default for AppearanceSettings {+impl std::default::Default for AppearanceSettingsPB {fn default() -> Self {- AppearanceSettings {+ AppearanceSettingsPB {theme: APPEARANCE_DEFAULT_THEME.to_owned(),- locale: LocaleSettings::default(),+ locale: LocaleSettingsPB::default(),reset_as_default: APPEARANCE_RESET_AS_DEFAULT,}}diff --git a/frontend/rust-lib/flowy-user/src/event_map.rs b/frontend/rust-lib/flowy-user/src/event_map.rsindex 348da177d3..ced1ede179 100644--- a/frontend/rust-lib/flowy-user/src/event_map.rs+++ b/frontend/rust-lib/flowy-user/src/event_map.rs@@ -1,5 +1,5 @@use crate::entities::{- SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserProfileParams, UserProfile,+ SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserProfileParams, UserProfilePB,};use crate::{errors::FlowyError, handlers::*, services::UserSession};use lib_dispatch::prelude::*;@@ -26,7 +26,7 @@ pub trait UserCloudService: Send + Sync {fn sign_in(&self, params: SignInParams) -> FutureResult<SignInResponse, FlowyError>;fn sign_out(&self, token: &str) -> FutureResult<(), FlowyError>;fn update_user(&self, token: &str, params: UpdateUserProfileParams) -> FutureResult<(), FlowyError>;- fn get_user(&self, token: &str) -> FutureResult<UserProfile, FlowyError>;+ fn get_user(&self, token: &str) -> FutureResult<UserProfilePB, FlowyError>;fn ws_addr(&self) -> String;}@@ -39,27 +39,27 @@ pub enum UserEvent {#[event()]InitUser = 0,- #[event(input = "SignInPayload", output = "UserProfile")]+ #[event(input = "SignInPayloadPB", output = "UserProfilePB")]SignIn = 1,- #[event(input = "SignUpPayload", output = "UserProfile")]+ #[event(input = "SignUpPayloadPB", output = "UserProfilePB")]SignUp = 2,#[event(passthrough)]SignOut = 3,- #[event(input = "UpdateUserProfilePayload")]+ #[event(input = "UpdateUserProfilePayloadPB")]UpdateUserProfile = 4,- #[event(output = "UserProfile")]+ #[event(output = "UserProfilePB")]GetUserProfile = 5,- #[event(output = "UserProfile")]+ #[event(output = "UserProfilePB")]CheckUser = 6,- #[event(input = "AppearanceSettings")]+ #[event(input = "AppearanceSettingsPB")]SetAppearanceSetting = 7,- #[event(output = "AppearanceSettings")]+ #[event(output = "AppearanceSettingsPB")]GetAppearanceSetting = 8,}diff --git a/frontend/rust-lib/flowy-user/src/handlers/auth_handler.rs b/frontend/rust-lib/flowy-user/src/handlers/auth_handler.rsindex 22a17d887c..8ff5bdb7e2 100644--- a/frontend/rust-lib/flowy-user/src/handlers/auth_handler.rs+++ b/frontend/rust-lib/flowy-user/src/handlers/auth_handler.rs@@ -7,9 +7,9 @@ use std::{convert::TryInto, sync::Arc};// tracing instrument 👉🏻 https://docs.rs/tracing/0.1.26/tracing/attr.instrument.html#[tracing::instrument(level = "debug", name = "sign_in", skip(data, session), fields(email = %data.email), err)]pub async fn sign_in(- data: Data<SignInPayload>,+ data: Data<SignInPayloadPB>,session: AppData<Arc<UserSession>>,-) -> DataResult<UserProfile, FlowyError> {+) -> DataResult<UserProfilePB, FlowyError> {let params: SignInParams = data.into_inner().try_into()?;let user_profile = session.sign_in(params).await?;data_result(user_profile)@@ -26,9 +26,9 @@ pub async fn sign_in(err)]pub async fn sign_up(- data: Data<SignUpPayload>,+ data: Data<SignUpPayloadPB>,session: AppData<Arc<UserSession>>,-) -> DataResult<UserProfile, FlowyError> {+) -> DataResult<UserProfilePB, FlowyError> {let params: SignUpParams = data.into_inner().try_into()?;let user_profile = session.sign_up(params).await?;diff --git a/frontend/rust-lib/flowy-user/src/handlers/user_handler.rs b/frontend/rust-lib/flowy-user/src/handlers/user_handler.rsindex 6ee62519e7..8a10dd89e2 100644--- a/frontend/rust-lib/flowy-user/src/handlers/user_handler.rs+++ b/frontend/rust-lib/flowy-user/src/handlers/user_handler.rs@@ -1,5 +1,5 @@use crate::entities::{- AppearanceSettings, UpdateUserProfileParams, UpdateUserProfilePayload, UserProfile, APPEARANCE_DEFAULT_THEME,+ AppearanceSettingsPB, UpdateUserProfileParams, UpdateUserProfilePayloadPB, UserProfilePB, APPEARANCE_DEFAULT_THEME,};use crate::{errors::FlowyError, services::UserSession};use flowy_database::kv::KV;@@ -13,13 +13,13 @@ pub async fn init_user_handler(session: AppData<Arc<UserSession>>) -> Result<(),}#[tracing::instrument(level = "debug", skip(session))]-pub async fn check_user_handler(session: AppData<Arc<UserSession>>) -> DataResult<UserProfile, FlowyError> {+pub async fn check_user_handler(session: AppData<Arc<UserSession>>) -> DataResult<UserProfilePB, FlowyError> {let user_profile = session.check_user().await?;data_result(user_profile)}#[tracing::instrument(level = "debug", skip(session))]-pub async fn get_user_profile_handler(session: AppData<Arc<UserSession>>) -> DataResult<UserProfile, FlowyError> {+pub async fn get_user_profile_handler(session: AppData<Arc<UserSession>>) -> DataResult<UserProfilePB, FlowyError> {let user_profile = session.get_user_profile().await?;data_result(user_profile)}@@ -32,7 +32,7 @@ pub async fn sign_out(session: AppData<Arc<UserSession>>) -> Result<(), FlowyErr#[tracing::instrument(level = "debug", skip(data, session))]pub async fn update_user_profile_handler(- data: Data<UpdateUserProfilePayload>,+ data: Data<UpdateUserProfilePayloadPB>,session: AppData<Arc<UserSession>>,) -> Result<(), FlowyError> {let params: UpdateUserProfileParams = data.into_inner().try_into()?;@@ -43,7 +43,7 @@ pub async fn update_user_profile_handler(const APPEARANCE_SETTING_CACHE_KEY: &str = "appearance_settings";#[tracing::instrument(level = "debug", skip(data), err)]-pub async fn set_appearance_setting(data: Data<AppearanceSettings>) -> Result<(), FlowyError> {+pub async fn set_appearance_setting(data: Data<AppearanceSettingsPB>) -> Result<(), FlowyError> {let mut setting = data.into_inner();if setting.theme.is_empty() {setting.theme = APPEARANCE_DEFAULT_THEME.to_string();@@ -55,15 +55,15 @@ pub async fn set_appearance_setting(data: Data<AppearanceSettings>) -> Result<()}#[tracing::instrument(err)]-pub async fn get_appearance_setting() -> DataResult<AppearanceSettings, FlowyError> {+pub async fn get_appearance_setting() -> DataResult<AppearanceSettingsPB, FlowyError> {match KV::get_str(APPEARANCE_SETTING_CACHE_KEY) {- None => data_result(AppearanceSettings::default()),+ None => data_result(AppearanceSettingsPB::default()),Some(s) => {let setting = match serde_json::from_str(&s) {Ok(setting) => setting,Err(e) => {tracing::error!("Deserialize AppearanceSettings failed: {:?}, fallback to default", e);- AppearanceSettings::default()+ AppearanceSettingsPB::default()}};data_result(setting)diff --git a/frontend/rust-lib/flowy-user/src/services/database.rs b/frontend/rust-lib/flowy-user/src/services/database.rsindex eaf5b7f6cb..64ebd705a7 100644--- a/frontend/rust-lib/flowy-user/src/services/database.rs+++ b/frontend/rust-lib/flowy-user/src/services/database.rs@@ -1,4 +1,4 @@-use crate::entities::{SignInResponse, SignUpResponse, UpdateUserProfileParams, UserProfile};+use crate::entities::{SignInResponse, SignUpResponse, UpdateUserProfileParams, UserProfilePB};use flowy_database::ConnectionPool;use flowy_database::{schema::user_table, DBConnection, Database};use flowy_error::{ErrorCode, FlowyError};@@ -113,9 +113,9 @@ impl std::convert::From<SignInResponse> for UserTable {}}-impl std::convert::From<UserTable> for UserProfile {+impl std::convert::From<UserTable> for UserProfilePB {fn from(table: UserTable) -> Self {- UserProfile {+ UserProfilePB {id: table.id,email: table.email,name: table.name,diff --git a/frontend/rust-lib/flowy-user/src/services/notifier.rs b/frontend/rust-lib/flowy-user/src/services/notifier.rsindex 9500988d99..4efdc301ac 100644--- a/frontend/rust-lib/flowy-user/src/services/notifier.rs+++ b/frontend/rust-lib/flowy-user/src/services/notifier.rs@@ -1,4 +1,4 @@-use crate::entities::UserProfile;+use crate::entities::UserProfilePB;use tokio::sync::{broadcast, mpsc};#[derive(Clone)]@@ -14,7 +14,7 @@ pub enum UserStatus {token: String,},SignUp {- profile: UserProfile,+ profile: UserProfilePB,ret: mpsc::Sender<()>,},}@@ -42,7 +42,7 @@ impl UserNotifier {});}- pub(crate) fn notify_sign_up(&self, ret: mpsc::Sender<()>, user_profile: &UserProfile) {+ pub(crate) fn notify_sign_up(&self, ret: mpsc::Sender<()>, user_profile: &UserProfilePB) {let _ = self.user_status_notifier.send(UserStatus::SignUp {profile: user_profile.clone(),ret,diff --git a/frontend/rust-lib/flowy-user/src/services/user_session.rs b/frontend/rust-lib/flowy-user/src/services/user_session.rsindex 48e6ef9661..3822a8a0db 100644--- a/frontend/rust-lib/flowy-user/src/services/user_session.rs+++ b/frontend/rust-lib/flowy-user/src/services/user_session.rs@@ -1,5 +1,5 @@use crate::entities::{- SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserProfileParams, UserProfile,+ SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserProfileParams, UserProfilePB,};use crate::{dart_notification::*,@@ -80,7 +80,7 @@ impl UserSession {}#[tracing::instrument(level = "debug", skip(self))]- pub async fn sign_in(&self, params: SignInParams) -> Result<UserProfile, FlowyError> {+ pub async fn sign_in(&self, params: SignInParams) -> Result<UserProfilePB, FlowyError> {if self.is_user_login(¶ms.email) {self.get_user_profile().await} else {@@ -88,14 +88,14 @@ impl UserSession {let session: Session = resp.clone().into();let _ = self.set_session(Some(session))?;let user_table = self.save_user(resp.into()).await?;- let user_profile: UserProfile = user_table.into();+ let user_profile: UserProfilePB = user_table.into();self.notifier.notify_login(&user_profile.token, &user_profile.id);Ok(user_profile)}}#[tracing::instrument(level = "debug", skip(self))]- pub async fn sign_up(&self, params: SignUpParams) -> Result<UserProfile, FlowyError> {+ pub async fn sign_up(&self, params: SignUpParams) -> Result<UserProfilePB, FlowyError> {if self.is_user_login(¶ms.email) {self.get_user_profile().await} else {@@ -103,7 +103,7 @@ impl UserSession {let session: Session = resp.clone().into();let _ = self.set_session(Some(session))?;let user_table = self.save_user(resp.into()).await?;- let user_profile: UserProfile = user_table.into();+ let user_profile: UserProfilePB = user_table.into();let (ret, mut tx) = mpsc::channel(1);self.notifier.notify_sign_up(ret, &user_profile);@@ -143,7 +143,7 @@ impl UserSession {Ok(())}- pub async fn check_user(&self) -> Result<UserProfile, FlowyError> {+ pub async fn check_user(&self) -> Result<UserProfilePB, FlowyError> {let (user_id, token) = self.get_session()?.into_part();let user = dsl::user_table@@ -154,7 +154,7 @@ impl UserSession {Ok(user.into())}- pub async fn get_user_profile(&self) -> Result<UserProfile, FlowyError> {+ pub async fn get_user_profile(&self) -> Result<UserProfilePB, FlowyError> {let (user_id, token) = self.get_session()?.into_part();let user = dsl::user_table.filter(user_table::id.eq(&user_id))diff --git a/frontend/rust-lib/flowy-user/tests/event/auth_test.rs b/frontend/rust-lib/flowy-user/tests/event/auth_test.rsindex 39b22a9af0..288b9d8b08 100644--- a/frontend/rust-lib/flowy-user/tests/event/auth_test.rs+++ b/frontend/rust-lib/flowy-user/tests/event/auth_test.rs@@ -1,13 +1,13 @@use crate::helper::*;use flowy_test::{event_builder::UserModuleEventBuilder, FlowySDKTest};-use flowy_user::entities::{SignInPayload, SignUpPayload, UserProfile};+use flowy_user::entities::{SignInPayloadPB, SignUpPayloadPB, UserProfilePB};use flowy_user::{errors::ErrorCode, event_map::UserEvent::*};#[tokio::test]async fn sign_up_with_invalid_email() {for email in invalid_email_test_case() {let sdk = FlowySDKTest::default();- let request = SignUpPayload {+ let request = SignUpPayloadPB {email: email.to_string(),name: valid_name(),password: login_password(),@@ -29,7 +29,7 @@ async fn sign_up_with_invalid_email() {async fn sign_up_with_invalid_password() {for password in invalid_password_test_case() {let sdk = FlowySDKTest::default();- let request = SignUpPayload {+ let request = SignUpPayloadPB {email: random_email(),name: valid_name(),password,@@ -50,7 +50,7 @@ async fn sign_in_success() {let _ = UserModuleEventBuilder::new(test.clone()).event(SignOut).sync_send();let sign_up_context = test.sign_up().await;- let request = SignInPayload {+ let request = SignInPayloadPB {email: sign_up_context.user_profile.email.clone(),password: sign_up_context.password.clone(),name: "".to_string(),@@ -61,7 +61,7 @@ async fn sign_in_success() {.payload(request).async_send().await- .parse::<UserProfile>();+ .parse::<UserProfilePB>();dbg!(&response);}@@ -69,7 +69,7 @@ async fn sign_in_success() {async fn sign_in_with_invalid_email() {for email in invalid_email_test_case() {let sdk = FlowySDKTest::default();- let request = SignInPayload {+ let request = SignInPayloadPB {email: email.to_string(),password: login_password(),name: "".to_string(),@@ -93,7 +93,7 @@ async fn sign_in_with_invalid_password() {for password in invalid_password_test_case() {let sdk = FlowySDKTest::default();- let request = SignInPayload {+ let request = SignInPayloadPB {email: random_email(),password,name: "".to_string(),diff --git a/frontend/rust-lib/flowy-user/tests/event/user_profile_test.rs b/frontend/rust-lib/flowy-user/tests/event/user_profile_test.rsindex b01a533336..fa77b69509 100644--- a/frontend/rust-lib/flowy-user/tests/event/user_profile_test.rs+++ b/frontend/rust-lib/flowy-user/tests/event/user_profile_test.rs@@ -1,6 +1,6 @@use crate::helper::*;use flowy_test::{event_builder::UserModuleEventBuilder, FlowySDKTest};-use flowy_user::entities::{UpdateUserProfilePayload, UserProfile};+use flowy_user::entities::{UpdateUserProfilePayloadPB, UserProfilePB};use flowy_user::{errors::ErrorCode, event_map::UserEvent::*};use nanoid::nanoid;@@ -24,7 +24,7 @@ async fn user_profile_get() {let user = UserModuleEventBuilder::new(test.clone()).event(GetUserProfile).sync_send()- .parse::<UserProfile>();+ .parse::<UserProfilePB>();assert_eq!(user_profile, user);}@@ -33,7 +33,7 @@ async fn user_update_with_name() {let sdk = FlowySDKTest::default();let user = sdk.init_user().await;let new_name = "hello_world".to_owned();- let request = UpdateUserProfilePayload::new(&user.id).name(&new_name);+ let request = UpdateUserProfilePayloadPB::new(&user.id).name(&new_name);let _ = UserModuleEventBuilder::new(sdk.clone()).event(UpdateUserProfile).payload(request)@@ -43,7 +43,7 @@ async fn user_update_with_name() {.event(GetUserProfile).assert_error().sync_send()- .parse::<UserProfile>();+ .parse::<UserProfilePB>();assert_eq!(user_profile.name, new_name,);}@@ -53,7 +53,7 @@ async fn user_update_with_email() {let sdk = FlowySDKTest::default();let user = sdk.init_user().await;let new_email = format!("{}@gmail.com", nanoid!(6));- let request = UpdateUserProfilePayload::new(&user.id).email(&new_email);+ let request = UpdateUserProfilePayloadPB::new(&user.id).email(&new_email);let _ = UserModuleEventBuilder::new(sdk.clone()).event(UpdateUserProfile).payload(request)@@ -62,7 +62,7 @@ async fn user_update_with_email() {.event(GetUserProfile).assert_error().sync_send()- .parse::<UserProfile>();+ .parse::<UserProfilePB>();assert_eq!(user_profile.email, new_email,);}@@ -72,7 +72,7 @@ async fn user_update_with_password() {let sdk = FlowySDKTest::default();let user = sdk.init_user().await;let new_password = "H123world!".to_owned();- let request = UpdateUserProfilePayload::new(&user.id).password(&new_password);+ let request = UpdateUserProfilePayloadPB::new(&user.id).password(&new_password);let _ = UserModuleEventBuilder::new(sdk.clone()).event(UpdateUserProfile)@@ -86,7 +86,7 @@ async fn user_update_with_invalid_email() {let test = FlowySDKTest::default();let user = test.init_user().await;for email in invalid_email_test_case() {- let request = UpdateUserProfilePayload::new(&user.id).email(&email);+ let request = UpdateUserProfilePayloadPB::new(&user.id).email(&email);assert_eq!(UserModuleEventBuilder::new(test.clone()).event(UpdateUserProfile)@@ -104,7 +104,7 @@ async fn user_update_with_invalid_password() {let test = FlowySDKTest::default();let user = test.init_user().await;for password in invalid_password_test_case() {- let request = UpdateUserProfilePayload::new(&user.id).password(&password);+ let request = UpdateUserProfilePayloadPB::new(&user.id).password(&password);UserModuleEventBuilder::new(test.clone()).event(UpdateUserProfile)@@ -118,7 +118,7 @@ async fn user_update_with_invalid_password() {async fn user_update_with_invalid_name() {let test = FlowySDKTest::default();let user = test.init_user().await;- let request = UpdateUserProfilePayload::new(&user.id).name("");+ let request = UpdateUserProfilePayloadPB::new(&user.id).name("");UserModuleEventBuilder::new(test.clone()).event(UpdateUserProfile).payload(request)