mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
rename user detail
This commit is contained in:
parent
36c044173d
commit
9771066d80
@ -35,8 +35,8 @@ class SignInBloc extends Bloc<SignInEvent, SignInState> {
|
|||||||
|
|
||||||
final result = await authImpl.signIn(state.email, state.password);
|
final result = await authImpl.signIn(state.email, state.password);
|
||||||
yield result.fold(
|
yield result.fold(
|
||||||
(userDetail) => state.copyWith(
|
(UserProfile) => state.copyWith(
|
||||||
isSubmitting: false, successOrFail: some(left(userDetail))),
|
isSubmitting: false, successOrFail: some(left(UserProfile))),
|
||||||
(error) => stateFromCode(error),
|
(error) => stateFromCode(error),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ abstract class SignInState with _$SignInState {
|
|||||||
required bool isSubmitting,
|
required bool isSubmitting,
|
||||||
required Option<String> passwordError,
|
required Option<String> passwordError,
|
||||||
required Option<String> emailError,
|
required Option<String> emailError,
|
||||||
required Option<Either<UserDetail, UserError>> successOrFail,
|
required Option<Either<UserProfile, UserError>> successOrFail,
|
||||||
}) = _SignInState;
|
}) = _SignInState;
|
||||||
|
|
||||||
factory SignInState.initial() => SignInState(
|
factory SignInState.initial() => SignInState(
|
||||||
|
@ -440,7 +440,7 @@ class _$SignInStateTearOff {
|
|||||||
required bool isSubmitting,
|
required bool isSubmitting,
|
||||||
required Option<String> passwordError,
|
required Option<String> passwordError,
|
||||||
required Option<String> emailError,
|
required Option<String> emailError,
|
||||||
required Option<Either<UserDetail, UserError>> successOrFail}) {
|
required Option<Either<UserProfile, UserError>> successOrFail}) {
|
||||||
return _SignInState(
|
return _SignInState(
|
||||||
email: email,
|
email: email,
|
||||||
password: password,
|
password: password,
|
||||||
@ -462,7 +462,7 @@ mixin _$SignInState {
|
|||||||
bool get isSubmitting => throw _privateConstructorUsedError;
|
bool get isSubmitting => throw _privateConstructorUsedError;
|
||||||
Option<String> get passwordError => throw _privateConstructorUsedError;
|
Option<String> get passwordError => throw _privateConstructorUsedError;
|
||||||
Option<String> get emailError => throw _privateConstructorUsedError;
|
Option<String> get emailError => throw _privateConstructorUsedError;
|
||||||
Option<Either<UserDetail, UserError>> get successOrFail =>
|
Option<Either<UserProfile, UserError>> get successOrFail =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@ -481,7 +481,7 @@ abstract class $SignInStateCopyWith<$Res> {
|
|||||||
bool isSubmitting,
|
bool isSubmitting,
|
||||||
Option<String> passwordError,
|
Option<String> passwordError,
|
||||||
Option<String> emailError,
|
Option<String> emailError,
|
||||||
Option<Either<UserDetail, UserError>> successOrFail});
|
Option<Either<UserProfile, UserError>> successOrFail});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -525,7 +525,7 @@ class _$SignInStateCopyWithImpl<$Res> implements $SignInStateCopyWith<$Res> {
|
|||||||
successOrFail: successOrFail == freezed
|
successOrFail: successOrFail == freezed
|
||||||
? _value.successOrFail
|
? _value.successOrFail
|
||||||
: successOrFail // ignore: cast_nullable_to_non_nullable
|
: successOrFail // ignore: cast_nullable_to_non_nullable
|
||||||
as Option<Either<UserDetail, UserError>>,
|
as Option<Either<UserProfile, UserError>>,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -543,7 +543,7 @@ abstract class _$SignInStateCopyWith<$Res>
|
|||||||
bool isSubmitting,
|
bool isSubmitting,
|
||||||
Option<String> passwordError,
|
Option<String> passwordError,
|
||||||
Option<String> emailError,
|
Option<String> emailError,
|
||||||
Option<Either<UserDetail, UserError>> successOrFail});
|
Option<Either<UserProfile, UserError>> successOrFail});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -589,7 +589,7 @@ class __$SignInStateCopyWithImpl<$Res> extends _$SignInStateCopyWithImpl<$Res>
|
|||||||
successOrFail: successOrFail == freezed
|
successOrFail: successOrFail == freezed
|
||||||
? _value.successOrFail
|
? _value.successOrFail
|
||||||
: successOrFail // ignore: cast_nullable_to_non_nullable
|
: successOrFail // ignore: cast_nullable_to_non_nullable
|
||||||
as Option<Either<UserDetail, UserError>>,
|
as Option<Either<UserProfile, UserError>>,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -616,7 +616,7 @@ class _$_SignInState implements _SignInState {
|
|||||||
@override
|
@override
|
||||||
final Option<String> emailError;
|
final Option<String> emailError;
|
||||||
@override
|
@override
|
||||||
final Option<Either<UserDetail, UserError>> successOrFail;
|
final Option<Either<UserProfile, UserError>> successOrFail;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -669,7 +669,7 @@ abstract class _SignInState implements SignInState {
|
|||||||
required bool isSubmitting,
|
required bool isSubmitting,
|
||||||
required Option<String> passwordError,
|
required Option<String> passwordError,
|
||||||
required Option<String> emailError,
|
required Option<String> emailError,
|
||||||
required Option<Either<UserDetail, UserError>> successOrFail}) =
|
required Option<Either<UserProfile, UserError>> successOrFail}) =
|
||||||
_$_SignInState;
|
_$_SignInState;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -683,7 +683,7 @@ abstract class _SignInState implements SignInState {
|
|||||||
@override
|
@override
|
||||||
Option<String> get emailError => throw _privateConstructorUsedError;
|
Option<String> get emailError => throw _privateConstructorUsedError;
|
||||||
@override
|
@override
|
||||||
Option<Either<UserDetail, UserError>> get successOrFail =>
|
Option<Either<UserProfile, UserError>> get successOrFail =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@override
|
@override
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
|
@ -3,15 +3,16 @@ import 'package:dartz/dartz.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
abstract class IAuth {
|
abstract class IAuth {
|
||||||
Future<Either<UserDetail, UserError>> signIn(String? email, String? password);
|
Future<Either<UserProfile, UserError>> signIn(
|
||||||
Future<Either<UserDetail, UserError>> signUp(
|
String? email, String? password);
|
||||||
|
Future<Either<UserProfile, UserError>> signUp(
|
||||||
String? name, String? password, String? email);
|
String? name, String? password, String? email);
|
||||||
|
|
||||||
Future<Either<Unit, UserError>> signOut();
|
Future<Either<Unit, UserError>> signOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class IAuthRouter {
|
abstract class IAuthRouter {
|
||||||
void showWorkspaceSelectScreen(BuildContext context, UserDetail user);
|
void showWorkspaceSelectScreen(BuildContext context, UserProfile user);
|
||||||
void showSignUpScreen(BuildContext context);
|
void showSignUpScreen(BuildContext context);
|
||||||
void showForgetPasswordScreen(BuildContext context);
|
void showForgetPasswordScreen(BuildContext context);
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,13 @@ class AuthImpl extends IAuth {
|
|||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Either<UserDetail, UserError>> signIn(
|
Future<Either<UserProfile, UserError>> signIn(
|
||||||
String? email, String? password) {
|
String? email, String? password) {
|
||||||
return repo.signIn(email: email, password: password);
|
return repo.signIn(email: email, password: password);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Either<UserDetail, UserError>> signUp(
|
Future<Either<UserProfile, UserError>> signUp(
|
||||||
String? name, String? password, String? email) {
|
String? name, String? password, String? email) {
|
||||||
return repo.signUp(name: name, password: password, email: email);
|
return repo.signUp(name: name, password: password, email: email);
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ class AuthRouterImpl extends IAuthRouter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void showWorkspaceSelectScreen(BuildContext context, UserDetail user) {
|
void showWorkspaceSelectScreen(BuildContext context, UserProfile user) {
|
||||||
Navigator.of(context).push(
|
Navigator.of(context).push(
|
||||||
PageRoutes.fade(
|
PageRoutes.fade(
|
||||||
() => WorkspaceSelectScreen(
|
() => WorkspaceSelectScreen(
|
||||||
|
@ -3,7 +3,7 @@ import 'package:flowy_sdk/dispatch/dispatch.dart';
|
|||||||
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
|
||||||
|
|
||||||
class AuthRepository {
|
class AuthRepository {
|
||||||
Future<Either<UserDetail, UserError>> signIn(
|
Future<Either<UserProfile, UserError>> signIn(
|
||||||
{required String? email, required String? password}) {
|
{required String? email, required String? password}) {
|
||||||
//
|
//
|
||||||
final request = SignInRequest.create()
|
final request = SignInRequest.create()
|
||||||
@ -13,7 +13,7 @@ class AuthRepository {
|
|||||||
return UserEventSignIn(request).send();
|
return UserEventSignIn(request).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Either<UserDetail, UserError>> signUp(
|
Future<Either<UserProfile, UserError>> signUp(
|
||||||
{required String? name,
|
{required String? name,
|
||||||
required String? password,
|
required String? password,
|
||||||
required String? email}) {
|
required String? email}) {
|
||||||
|
@ -6,7 +6,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/rounded_input_field.dart';
|
||||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user/user_detail.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
@ -34,7 +34,7 @@ class SignInScreen extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _handleSuccessOrFail(
|
void _handleSuccessOrFail(
|
||||||
Either<UserDetail, UserError> result, BuildContext context) {
|
Either<UserProfile, UserError> result, BuildContext context) {
|
||||||
result.fold(
|
result.fold(
|
||||||
(user) => router.showWorkspaceSelectScreen(context, user),
|
(user) => router.showWorkspaceSelectScreen(context, user),
|
||||||
(error) => _showErrorMessage(context, error.msg),
|
(error) => _showErrorMessage(context, error.msg),
|
||||||
|
@ -13,7 +13,7 @@ class WelcomeBloc extends Bloc<WelcomeEvent, WelcomeState> {
|
|||||||
Stream<WelcomeState> mapEventToState(WelcomeEvent event) async* {
|
Stream<WelcomeState> mapEventToState(WelcomeEvent event) async* {
|
||||||
yield* event.map(
|
yield* event.map(
|
||||||
getUser: (val) async* {
|
getUser: (val) async* {
|
||||||
final authState = await authImpl.currentUserDetail();
|
final authState = await authImpl.currentUserProfile();
|
||||||
yield state.copyWith(auth: authState);
|
yield state.copyWith(auth: authState);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -4,7 +4,8 @@ part 'auth_state.freezed.dart';
|
|||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
abstract class AuthState with _$AuthState {
|
abstract class AuthState with _$AuthState {
|
||||||
const factory AuthState.authenticated(UserDetail userDetail) = Authenticated;
|
const factory AuthState.authenticated(UserProfile userProfile) =
|
||||||
|
Authenticated;
|
||||||
const factory AuthState.unauthenticated(UserError error) = Unauthenticated;
|
const factory AuthState.unauthenticated(UserError error) = Unauthenticated;
|
||||||
const factory AuthState.initial() = _Initial;
|
const factory AuthState.initial() = _Initial;
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,9 @@ final _privateConstructorUsedError = UnsupportedError(
|
|||||||
class _$AuthStateTearOff {
|
class _$AuthStateTearOff {
|
||||||
const _$AuthStateTearOff();
|
const _$AuthStateTearOff();
|
||||||
|
|
||||||
Authenticated authenticated(UserDetail userDetail) {
|
Authenticated authenticated(UserProfile userProfile) {
|
||||||
return Authenticated(
|
return Authenticated(
|
||||||
userDetail,
|
userProfile,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,14 +40,14 @@ const $AuthState = _$AuthStateTearOff();
|
|||||||
mixin _$AuthState {
|
mixin _$AuthState {
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(UserDetail userDetail) authenticated,
|
required TResult Function(UserProfile userProfile) authenticated,
|
||||||
required TResult Function(UserError error) unauthenticated,
|
required TResult Function(UserError error) unauthenticated,
|
||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(UserDetail userDetail)? authenticated,
|
TResult Function(UserProfile userProfile)? authenticated,
|
||||||
TResult Function(UserError error)? unauthenticated,
|
TResult Function(UserError error)? unauthenticated,
|
||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
@ -90,7 +90,7 @@ abstract class $AuthenticatedCopyWith<$Res> {
|
|||||||
factory $AuthenticatedCopyWith(
|
factory $AuthenticatedCopyWith(
|
||||||
Authenticated value, $Res Function(Authenticated) then) =
|
Authenticated value, $Res Function(Authenticated) then) =
|
||||||
_$AuthenticatedCopyWithImpl<$Res>;
|
_$AuthenticatedCopyWithImpl<$Res>;
|
||||||
$Res call({UserDetail userDetail});
|
$Res call({UserProfile userProfile});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -105,13 +105,13 @@ class _$AuthenticatedCopyWithImpl<$Res> extends _$AuthStateCopyWithImpl<$Res>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
$Res call({
|
$Res call({
|
||||||
Object? userDetail = freezed,
|
Object? userProfile = freezed,
|
||||||
}) {
|
}) {
|
||||||
return _then(Authenticated(
|
return _then(Authenticated(
|
||||||
userDetail == freezed
|
userProfile == freezed
|
||||||
? _value.userDetail
|
? _value.userProfile
|
||||||
: userDetail // ignore: cast_nullable_to_non_nullable
|
: userProfile // ignore: cast_nullable_to_non_nullable
|
||||||
as UserDetail,
|
as UserProfile,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,28 +119,28 @@ class _$AuthenticatedCopyWithImpl<$Res> extends _$AuthStateCopyWithImpl<$Res>
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
|
|
||||||
class _$Authenticated implements Authenticated {
|
class _$Authenticated implements Authenticated {
|
||||||
const _$Authenticated(this.userDetail);
|
const _$Authenticated(this.userProfile);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final UserDetail userDetail;
|
final UserProfile userProfile;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'AuthState.authenticated(userDetail: $userDetail)';
|
return 'AuthState.authenticated(userProfile: $userProfile)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(dynamic other) {
|
bool operator ==(dynamic other) {
|
||||||
return identical(this, other) ||
|
return identical(this, other) ||
|
||||||
(other is Authenticated &&
|
(other is Authenticated &&
|
||||||
(identical(other.userDetail, userDetail) ||
|
(identical(other.userProfile, userProfile) ||
|
||||||
const DeepCollectionEquality()
|
const DeepCollectionEquality()
|
||||||
.equals(other.userDetail, userDetail)));
|
.equals(other.userProfile, userProfile)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode =>
|
int get hashCode =>
|
||||||
runtimeType.hashCode ^ const DeepCollectionEquality().hash(userDetail);
|
runtimeType.hashCode ^ const DeepCollectionEquality().hash(userProfile);
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
@ -150,23 +150,23 @@ class _$Authenticated implements Authenticated {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(UserDetail userDetail) authenticated,
|
required TResult Function(UserProfile userProfile) authenticated,
|
||||||
required TResult Function(UserError error) unauthenticated,
|
required TResult Function(UserError error) unauthenticated,
|
||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
}) {
|
}) {
|
||||||
return authenticated(userDetail);
|
return authenticated(userProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(UserDetail userDetail)? authenticated,
|
TResult Function(UserProfile userProfile)? authenticated,
|
||||||
TResult Function(UserError error)? unauthenticated,
|
TResult Function(UserError error)? unauthenticated,
|
||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (authenticated != null) {
|
if (authenticated != null) {
|
||||||
return authenticated(userDetail);
|
return authenticated(userProfile);
|
||||||
}
|
}
|
||||||
return orElse();
|
return orElse();
|
||||||
}
|
}
|
||||||
@ -197,9 +197,9 @@ class _$Authenticated implements Authenticated {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract class Authenticated implements AuthState {
|
abstract class Authenticated implements AuthState {
|
||||||
const factory Authenticated(UserDetail userDetail) = _$Authenticated;
|
const factory Authenticated(UserProfile userProfile) = _$Authenticated;
|
||||||
|
|
||||||
UserDetail get userDetail => throw _privateConstructorUsedError;
|
UserProfile get userProfile => throw _privateConstructorUsedError;
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
$AuthenticatedCopyWith<Authenticated> get copyWith =>
|
$AuthenticatedCopyWith<Authenticated> get copyWith =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@ -269,7 +269,7 @@ class _$Unauthenticated implements Unauthenticated {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(UserDetail userDetail) authenticated,
|
required TResult Function(UserProfile userProfile) authenticated,
|
||||||
required TResult Function(UserError error) unauthenticated,
|
required TResult Function(UserError error) unauthenticated,
|
||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
}) {
|
}) {
|
||||||
@ -279,7 +279,7 @@ class _$Unauthenticated implements Unauthenticated {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(UserDetail userDetail)? authenticated,
|
TResult Function(UserProfile userProfile)? authenticated,
|
||||||
TResult Function(UserError error)? unauthenticated,
|
TResult Function(UserError error)? unauthenticated,
|
||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
@ -361,7 +361,7 @@ class _$_Initial implements _Initial {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(UserDetail userDetail) authenticated,
|
required TResult Function(UserProfile userProfile) authenticated,
|
||||||
required TResult Function(UserError error) unauthenticated,
|
required TResult Function(UserError error) unauthenticated,
|
||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
}) {
|
}) {
|
||||||
@ -371,7 +371,7 @@ class _$_Initial implements _Initial {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(UserDetail userDetail)? authenticated,
|
TResult Function(UserProfile userProfile)? authenticated,
|
||||||
TResult Function(UserError error)? unauthenticated,
|
TResult Function(UserError error)? unauthenticated,
|
||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
|
@ -4,10 +4,10 @@ import 'package:flutter/widgets.dart';
|
|||||||
import 'auth_state.dart';
|
import 'auth_state.dart';
|
||||||
|
|
||||||
abstract class IWelcomeAuth {
|
abstract class IWelcomeAuth {
|
||||||
Future<AuthState> currentUserDetail();
|
Future<AuthState> currentUserProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class IWelcomeRoute {
|
abstract class IWelcomeRoute {
|
||||||
Widget pushSignInScreen();
|
Widget pushSignInScreen();
|
||||||
Future<void> pushHomeScreen(BuildContext context, UserDetail userDetail);
|
Future<void> pushHomeScreen(BuildContext context, UserProfile profile);
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,12 @@ export 'package:app_flowy/welcome/domain/i_welcome.dart';
|
|||||||
|
|
||||||
class WelcomeAuthImpl implements IWelcomeAuth {
|
class WelcomeAuthImpl implements IWelcomeAuth {
|
||||||
@override
|
@override
|
||||||
Future<AuthState> currentUserDetail() {
|
Future<AuthState> currentUserProfile() {
|
||||||
final result = UserEventGetStatus().send();
|
final result = UserEventGetUserProfile().send();
|
||||||
return result.then((result) {
|
return result.then((result) {
|
||||||
return result.fold(
|
return result.fold(
|
||||||
(userDetail) {
|
(UserProfile) {
|
||||||
return AuthState.authenticated(userDetail);
|
return AuthState.authenticated(UserProfile);
|
||||||
},
|
},
|
||||||
(userError) {
|
(userError) {
|
||||||
return AuthState.unauthenticated(userError);
|
return AuthState.unauthenticated(userError);
|
||||||
@ -35,7 +35,7 @@ class WelcomeAuthImpl implements IWelcomeAuth {
|
|||||||
|
|
||||||
class WelcomeRoute implements IWelcomeRoute {
|
class WelcomeRoute implements IWelcomeRoute {
|
||||||
@override
|
@override
|
||||||
Future<void> pushHomeScreen(BuildContext context, UserDetail user) async {
|
Future<void> pushHomeScreen(BuildContext context, UserProfile user) async {
|
||||||
final repo = UserRepo(user: user);
|
final repo = UserRepo(user: user);
|
||||||
return WorkspaceEventReadCurWorkspace().send().then(
|
return WorkspaceEventReadCurWorkspace().send().then(
|
||||||
(result) {
|
(result) {
|
||||||
|
@ -41,7 +41,7 @@ class WelcomeScreen extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _handleAuthenticated(BuildContext context, Authenticated result) {
|
void _handleAuthenticated(BuildContext context, Authenticated result) {
|
||||||
getIt<IWelcomeRoute>().pushHomeScreen(context, result.userDetail);
|
getIt<IWelcomeRoute>().pushHomeScreen(context, result.userProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleUnauthenticated(BuildContext context, Unauthenticated result) {
|
void _handleUnauthenticated(BuildContext context, Unauthenticated result) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import 'package:app_flowy/workspace/domain/i_user.dart';
|
import 'package:app_flowy/workspace/domain/i_user.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user/user_detail.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-workspace/workspace_create.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-workspace/workspace_create.pb.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
@ -47,12 +47,12 @@ class MenuUserEvent with _$MenuUserEvent {
|
|||||||
@freezed
|
@freezed
|
||||||
class MenuUserState with _$MenuUserState {
|
class MenuUserState with _$MenuUserState {
|
||||||
const factory MenuUserState({
|
const factory MenuUserState({
|
||||||
required UserDetail user,
|
required UserProfile user,
|
||||||
required Option<List<Workspace>> workspaces,
|
required Option<List<Workspace>> workspaces,
|
||||||
required Either<Unit, String> successOrFailure,
|
required Either<Unit, String> successOrFailure,
|
||||||
}) = _MenuUserState;
|
}) = _MenuUserState;
|
||||||
|
|
||||||
factory MenuUserState.initial(UserDetail user) => MenuUserState(
|
factory MenuUserState.initial(UserProfile user) => MenuUserState(
|
||||||
user: user,
|
user: user,
|
||||||
workspaces: none(),
|
workspaces: none(),
|
||||||
successOrFailure: left(unit),
|
successOrFailure: left(unit),
|
||||||
|
@ -249,7 +249,7 @@ class _$MenuUserStateTearOff {
|
|||||||
const _$MenuUserStateTearOff();
|
const _$MenuUserStateTearOff();
|
||||||
|
|
||||||
_MenuUserState call(
|
_MenuUserState call(
|
||||||
{required UserDetail user,
|
{required UserProfile user,
|
||||||
required Option<List<Workspace>> workspaces,
|
required Option<List<Workspace>> workspaces,
|
||||||
required Either<Unit, String> successOrFailure}) {
|
required Either<Unit, String> successOrFailure}) {
|
||||||
return _MenuUserState(
|
return _MenuUserState(
|
||||||
@ -265,7 +265,7 @@ const $MenuUserState = _$MenuUserStateTearOff();
|
|||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$MenuUserState {
|
mixin _$MenuUserState {
|
||||||
UserDetail get user => throw _privateConstructorUsedError;
|
UserProfile get user => throw _privateConstructorUsedError;
|
||||||
Option<List<Workspace>> get workspaces => throw _privateConstructorUsedError;
|
Option<List<Workspace>> get workspaces => throw _privateConstructorUsedError;
|
||||||
Either<Unit, String> get successOrFailure =>
|
Either<Unit, String> get successOrFailure =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@ -281,7 +281,7 @@ abstract class $MenuUserStateCopyWith<$Res> {
|
|||||||
MenuUserState value, $Res Function(MenuUserState) then) =
|
MenuUserState value, $Res Function(MenuUserState) then) =
|
||||||
_$MenuUserStateCopyWithImpl<$Res>;
|
_$MenuUserStateCopyWithImpl<$Res>;
|
||||||
$Res call(
|
$Res call(
|
||||||
{UserDetail user,
|
{UserProfile user,
|
||||||
Option<List<Workspace>> workspaces,
|
Option<List<Workspace>> workspaces,
|
||||||
Either<Unit, String> successOrFailure});
|
Either<Unit, String> successOrFailure});
|
||||||
}
|
}
|
||||||
@ -305,7 +305,7 @@ class _$MenuUserStateCopyWithImpl<$Res>
|
|||||||
user: user == freezed
|
user: user == freezed
|
||||||
? _value.user
|
? _value.user
|
||||||
: user // ignore: cast_nullable_to_non_nullable
|
: user // ignore: cast_nullable_to_non_nullable
|
||||||
as UserDetail,
|
as UserProfile,
|
||||||
workspaces: workspaces == freezed
|
workspaces: workspaces == freezed
|
||||||
? _value.workspaces
|
? _value.workspaces
|
||||||
: workspaces // ignore: cast_nullable_to_non_nullable
|
: workspaces // ignore: cast_nullable_to_non_nullable
|
||||||
@ -326,7 +326,7 @@ abstract class _$MenuUserStateCopyWith<$Res>
|
|||||||
__$MenuUserStateCopyWithImpl<$Res>;
|
__$MenuUserStateCopyWithImpl<$Res>;
|
||||||
@override
|
@override
|
||||||
$Res call(
|
$Res call(
|
||||||
{UserDetail user,
|
{UserProfile user,
|
||||||
Option<List<Workspace>> workspaces,
|
Option<List<Workspace>> workspaces,
|
||||||
Either<Unit, String> successOrFailure});
|
Either<Unit, String> successOrFailure});
|
||||||
}
|
}
|
||||||
@ -352,7 +352,7 @@ class __$MenuUserStateCopyWithImpl<$Res>
|
|||||||
user: user == freezed
|
user: user == freezed
|
||||||
? _value.user
|
? _value.user
|
||||||
: user // ignore: cast_nullable_to_non_nullable
|
: user // ignore: cast_nullable_to_non_nullable
|
||||||
as UserDetail,
|
as UserProfile,
|
||||||
workspaces: workspaces == freezed
|
workspaces: workspaces == freezed
|
||||||
? _value.workspaces
|
? _value.workspaces
|
||||||
: workspaces // ignore: cast_nullable_to_non_nullable
|
: workspaces // ignore: cast_nullable_to_non_nullable
|
||||||
@ -374,7 +374,7 @@ class _$_MenuUserState implements _MenuUserState {
|
|||||||
required this.successOrFailure});
|
required this.successOrFailure});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final UserDetail user;
|
final UserProfile user;
|
||||||
@override
|
@override
|
||||||
final Option<List<Workspace>> workspaces;
|
final Option<List<Workspace>> workspaces;
|
||||||
@override
|
@override
|
||||||
@ -414,12 +414,12 @@ class _$_MenuUserState implements _MenuUserState {
|
|||||||
|
|
||||||
abstract class _MenuUserState implements MenuUserState {
|
abstract class _MenuUserState implements MenuUserState {
|
||||||
const factory _MenuUserState(
|
const factory _MenuUserState(
|
||||||
{required UserDetail user,
|
{required UserProfile user,
|
||||||
required Option<List<Workspace>> workspaces,
|
required Option<List<Workspace>> workspaces,
|
||||||
required Either<Unit, String> successOrFailure}) = _$_MenuUserState;
|
required Either<Unit, String> successOrFailure}) = _$_MenuUserState;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
UserDetail get user => throw _privateConstructorUsedError;
|
UserProfile get user => throw _privateConstructorUsedError;
|
||||||
@override
|
@override
|
||||||
Option<List<Workspace>> get workspaces => throw _privateConstructorUsedError;
|
Option<List<Workspace>> get workspaces => throw _privateConstructorUsedError;
|
||||||
@override
|
@override
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user/user_detail.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-workspace/workspace_create.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-workspace/workspace_create.pb.dart';
|
||||||
|
|
||||||
export 'package:flowy_sdk/protobuf/flowy-workspace/workspace_create.pb.dart';
|
export 'package:flowy_sdk/protobuf/flowy-workspace/workspace_create.pb.dart';
|
||||||
export 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
|
export 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
|
||||||
export 'package:flowy_sdk/protobuf/flowy-user/user_detail.pb.dart';
|
export 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
|
||||||
|
|
||||||
typedef UserCreateWorkspaceCallback = void Function(
|
typedef UserCreateWorkspaceCallback = void Function(
|
||||||
Either<List<Workspace>, WorkspaceError> workspacesOrFailed);
|
Either<List<Workspace>, WorkspaceError> workspacesOrFailed);
|
||||||
@ -14,8 +14,8 @@ typedef UserDeleteWorkspaceCallback = void Function(
|
|||||||
Either<List<Workspace>, WorkspaceError> workspacesOrFailed);
|
Either<List<Workspace>, WorkspaceError> workspacesOrFailed);
|
||||||
|
|
||||||
abstract class IUser {
|
abstract class IUser {
|
||||||
UserDetail get user;
|
UserProfile get user;
|
||||||
Future<Either<UserDetail, UserError>> fetchUserDetail(String userId);
|
Future<Either<UserProfile, UserError>> fetchUserProfile(String userId);
|
||||||
Future<Either<List<Workspace>, WorkspaceError>> fetchWorkspaces();
|
Future<Either<List<Workspace>, WorkspaceError>> fetchWorkspaces();
|
||||||
Future<Either<Unit, WorkspaceError>> deleteWorkspace(String workspaceId);
|
Future<Either<Unit, WorkspaceError>> deleteWorkspace(String workspaceId);
|
||||||
Future<Either<Unit, UserError>> signOut();
|
Future<Either<Unit, UserError>> signOut();
|
||||||
|
@ -18,7 +18,7 @@ import 'package:app_flowy/workspace/infrastructure/repos/doc_repo.dart';
|
|||||||
import 'package:app_flowy/workspace/infrastructure/repos/view_repo.dart';
|
import 'package:app_flowy/workspace/infrastructure/repos/view_repo.dart';
|
||||||
import 'package:app_flowy/workspace/infrastructure/repos/workspace_repo.dart';
|
import 'package:app_flowy/workspace/infrastructure/repos/workspace_repo.dart';
|
||||||
import 'package:flowy_editor/flowy_editor.dart';
|
import 'package:flowy_editor/flowy_editor.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user/user_detail.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
|
||||||
import 'package:get_it/get_it.dart';
|
import 'package:get_it/get_it.dart';
|
||||||
|
|
||||||
@ -37,10 +37,10 @@ class HomeDepsResolver {
|
|||||||
(appId, _) => IAppWatchImpl(repo: AppWatchRepository(appId: appId)));
|
(appId, _) => IAppWatchImpl(repo: AppWatchRepository(appId: appId)));
|
||||||
|
|
||||||
//workspace
|
//workspace
|
||||||
getIt.registerFactoryParam<IWorkspace, UserDetail, String>(
|
getIt.registerFactoryParam<IWorkspace, UserProfile, String>(
|
||||||
(user, workspaceId) => IWorkspaceImpl(
|
(user, workspaceId) => IWorkspaceImpl(
|
||||||
repo: WorkspaceRepo(user: user, workspaceId: workspaceId)));
|
repo: WorkspaceRepo(user: user, workspaceId: workspaceId)));
|
||||||
getIt.registerFactoryParam<IWorkspaceWatch, UserDetail, String>(
|
getIt.registerFactoryParam<IWorkspaceWatch, UserProfile, String>(
|
||||||
(user, workspaceId) => IWorkspaceWatchImpl(
|
(user, workspaceId) => IWorkspaceWatchImpl(
|
||||||
repo: WorkspaceWatchRepo(user: user, workspaceId: workspaceId)));
|
repo: WorkspaceWatchRepo(user: user, workspaceId: workspaceId)));
|
||||||
|
|
||||||
@ -55,20 +55,20 @@ class HomeDepsResolver {
|
|||||||
(docId, _) => IDocImpl(repo: DocRepository(docId: docId)));
|
(docId, _) => IDocImpl(repo: DocRepository(docId: docId)));
|
||||||
|
|
||||||
// User
|
// User
|
||||||
getIt.registerFactoryParam<IUser, UserDetail, void>(
|
getIt.registerFactoryParam<IUser, UserProfile, void>(
|
||||||
(user, _) => IUserImpl(repo: UserRepo(user: user)));
|
(user, _) => IUserImpl(repo: UserRepo(user: user)));
|
||||||
getIt.registerFactoryParam<IUserWatch, UserDetail, void>(
|
getIt.registerFactoryParam<IUserWatch, UserProfile, void>(
|
||||||
(user, _) => IUserWatchImpl(repo: UserWatchRepo(user: user)));
|
(user, _) => IUserWatchImpl(repo: UserWatchRepo(user: user)));
|
||||||
|
|
||||||
//Menu Bloc
|
//Menu Bloc
|
||||||
getIt.registerFactoryParam<MenuBloc, UserDetail, String>(
|
getIt.registerFactoryParam<MenuBloc, UserProfile, String>(
|
||||||
(user, workspaceId) =>
|
(user, workspaceId) =>
|
||||||
MenuBloc(getIt<IWorkspace>(param1: user, param2: workspaceId)));
|
MenuBloc(getIt<IWorkspace>(param1: user, param2: workspaceId)));
|
||||||
getIt.registerFactoryParam<MenuWatchBloc, UserDetail, String>(
|
getIt.registerFactoryParam<MenuWatchBloc, UserProfile, String>(
|
||||||
(user, workspaceId) => MenuWatchBloc(
|
(user, workspaceId) => MenuWatchBloc(
|
||||||
getIt<IWorkspaceWatch>(param1: user, param2: workspaceId)));
|
getIt<IWorkspaceWatch>(param1: user, param2: workspaceId)));
|
||||||
|
|
||||||
getIt.registerFactoryParam<MenuUserBloc, UserDetail, void>(
|
getIt.registerFactoryParam<MenuUserBloc, UserProfile, void>(
|
||||||
(user, _) => MenuUserBloc(getIt<IUser>(param1: user)));
|
(user, _) => MenuUserBloc(getIt<IUser>(param1: user)));
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -17,8 +17,8 @@ class IUserImpl extends IUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Either<UserDetail, UserError>> fetchUserDetail(String userId) {
|
Future<Either<UserProfile, UserError>> fetchUserProfile(String userId) {
|
||||||
return repo.fetchUserDetail(userId: userId);
|
return repo.fetchUserProfile(userId: userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -27,7 +27,7 @@ class IUserImpl extends IUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
UserDetail get user => repo.user;
|
UserProfile get user => repo.user;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Either<List<Workspace>, WorkspaceError>> fetchWorkspaces() {
|
Future<Either<List<Workspace>, WorkspaceError>> fetchWorkspaces() {
|
||||||
|
@ -4,7 +4,7 @@ import 'package:dartz/dartz.dart';
|
|||||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-observable/subject.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-observable/subject.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user/user_detail.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-workspace/observable.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-workspace/observable.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-workspace/workspace_create.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-workspace/workspace_create.pb.dart';
|
||||||
@ -13,14 +13,14 @@ import 'package:flowy_sdk/rust_stream.dart';
|
|||||||
import 'package:app_flowy/workspace/domain/i_user.dart';
|
import 'package:app_flowy/workspace/domain/i_user.dart';
|
||||||
|
|
||||||
class UserRepo {
|
class UserRepo {
|
||||||
final UserDetail user;
|
final UserProfile user;
|
||||||
UserRepo({
|
UserRepo({
|
||||||
required this.user,
|
required this.user,
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<Either<UserDetail, UserError>> fetchUserDetail(
|
Future<Either<UserProfile, UserError>> fetchUserProfile(
|
||||||
{required String userId}) {
|
{required String userId}) {
|
||||||
return UserEventGetStatus().send();
|
return UserEventGetUserProfile().send();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Either<Unit, WorkspaceError>> deleteWorkspace(
|
Future<Either<Unit, WorkspaceError>> deleteWorkspace(
|
||||||
@ -73,7 +73,7 @@ class UserWatchRepo {
|
|||||||
UserDeleteWorkspaceCallback? _deleteWorkspace;
|
UserDeleteWorkspaceCallback? _deleteWorkspace;
|
||||||
late UserRepo _repo;
|
late UserRepo _repo;
|
||||||
UserWatchRepo({
|
UserWatchRepo({
|
||||||
required UserDetail user,
|
required UserProfile user,
|
||||||
}) {
|
}) {
|
||||||
_repo = UserRepo(user: user);
|
_repo = UserRepo(user: user);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import 'package:dartz/dartz.dart';
|
|||||||
import 'package:flowy_infra/flowy_logger.dart';
|
import 'package:flowy_infra/flowy_logger.dart';
|
||||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-observable/subject.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-observable/subject.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user/user_detail.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-workspace/app_create.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-workspace/app_create.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-workspace/observable.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-workspace/observable.pb.dart';
|
||||||
@ -15,7 +15,7 @@ import 'package:flowy_sdk/rust_stream.dart';
|
|||||||
import 'package:app_flowy/workspace/domain/i_workspace.dart';
|
import 'package:app_flowy/workspace/domain/i_workspace.dart';
|
||||||
|
|
||||||
class WorkspaceRepo {
|
class WorkspaceRepo {
|
||||||
UserDetail user;
|
UserProfile user;
|
||||||
String workspaceId;
|
String workspaceId;
|
||||||
WorkspaceRepo({
|
WorkspaceRepo({
|
||||||
required this.user,
|
required this.user,
|
||||||
@ -64,7 +64,7 @@ class WorkspaceWatchRepo {
|
|||||||
WorkspaceCreateAppCallback? _createApp;
|
WorkspaceCreateAppCallback? _createApp;
|
||||||
WorkspaceDeleteAppCallback? _deleteApp;
|
WorkspaceDeleteAppCallback? _deleteApp;
|
||||||
WorkspaceUpdatedCallback? _update;
|
WorkspaceUpdatedCallback? _update;
|
||||||
final UserDetail user;
|
final UserProfile user;
|
||||||
final String workspaceId;
|
final String workspaceId;
|
||||||
late WorkspaceRepo _repo;
|
late WorkspaceRepo _repo;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import 'home_layout.dart';
|
|||||||
|
|
||||||
class HomeScreen extends StatelessWidget {
|
class HomeScreen extends StatelessWidget {
|
||||||
static GlobalKey<ScaffoldState> scaffoldKey = GlobalKey();
|
static GlobalKey<ScaffoldState> scaffoldKey = GlobalKey();
|
||||||
final UserDetail user;
|
final UserProfile user;
|
||||||
final String workspaceId;
|
final String workspaceId;
|
||||||
const HomeScreen(this.user, this.workspaceId, {Key? key}) : super(key: key);
|
const HomeScreen(this.user, this.workspaceId, {Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import 'package:app_flowy/workspace/presentation/widgets/menu/menu_top_bar.dart'
|
|||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:flowy_infra/size.dart';
|
import 'package:flowy_infra/size.dart';
|
||||||
import 'package:flowy_infra_ui/widget/error_page.dart';
|
import 'package:flowy_infra_ui/widget/error_page.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user/user_detail.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-workspace/app_create.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-workspace/app_create.pb.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
@ -22,7 +22,7 @@ import 'menu_list.dart';
|
|||||||
class HomeMenu extends StatelessWidget {
|
class HomeMenu extends StatelessWidget {
|
||||||
final Function(HomeStackView?) pageContextChanged;
|
final Function(HomeStackView?) pageContextChanged;
|
||||||
final Function(bool) isCollapseChanged;
|
final Function(bool) isCollapseChanged;
|
||||||
final UserDetail user;
|
final UserProfile user;
|
||||||
final String workspaceId;
|
final String workspaceId;
|
||||||
|
|
||||||
const HomeMenu({
|
const HomeMenu({
|
||||||
@ -126,7 +126,7 @@ class MenuItemBuilder {
|
|||||||
|
|
||||||
MenuItemBuilder();
|
MenuItemBuilder();
|
||||||
|
|
||||||
MenuItemBuilder withUser(UserDetail user) {
|
MenuItemBuilder withUser(UserProfile user) {
|
||||||
items.add(MenuUser(user));
|
items.add(MenuUser(user));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,14 @@ import 'package:app_flowy/startup/startup.dart';
|
|||||||
import 'package:app_flowy/workspace/application/menu/menu_user_bloc.dart';
|
import 'package:app_flowy/workspace/application/menu/menu_user_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/widgets/menu/menu_list.dart';
|
import 'package:app_flowy/workspace/presentation/widgets/menu/menu_list.dart';
|
||||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user/user_detail.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/text.dart';
|
import 'package:flowy_infra_ui/style_widget/text.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
|
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
|
||||||
|
|
||||||
class MenuUser extends MenuItem {
|
class MenuUser extends MenuItem {
|
||||||
final UserDetail user;
|
final UserProfile user;
|
||||||
MenuUser(this.user, {Key? key}) : super(key: ValueKey(user.id));
|
MenuUser(this.user, {Key? key}) : super(key: ValueKey(user.id));
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -132,7 +132,7 @@ class WorkspaceItem extends StatelessWidget {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// class WorkspaceSelectScreen extends StatelessWidget {
|
// class WorkspaceSelectScreen extends StatelessWidget {
|
||||||
// final UserDetail user;
|
// final UserProfile user;
|
||||||
// const WorkspaceSelectScreen({
|
// const WorkspaceSelectScreen({
|
||||||
// Key? key,
|
// Key? key,
|
||||||
// required this.user,
|
// required this.user,
|
||||||
@ -206,7 +206,7 @@ class WorkspaceItem extends StatelessWidget {
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// class WorkspaceSelectScreen extends StatelessWidget {
|
// class WorkspaceSelectScreen extends StatelessWidget {
|
||||||
// final UserDetail user;
|
// final UserProfile user;
|
||||||
// const WorkspaceSelectScreen({
|
// const WorkspaceSelectScreen({
|
||||||
// Key? key,
|
// Key? key,
|
||||||
// required this.user,
|
// required this.user,
|
||||||
|
@ -1,369 +1,369 @@
|
|||||||
|
|
||||||
|
|
||||||
/// Auto gen code from rust ast, do not edit
|
/// Auto gen code from rust ast, do not edit
|
||||||
part of 'dispatch.dart';
|
part of 'dispatch.dart';
|
||||||
|
|
||||||
class WorkspaceEventCreateWorkspace {
|
class WorkspaceEventCreateWorkspace {
|
||||||
CreateWorkspaceRequest request;
|
CreateWorkspaceRequest request;
|
||||||
WorkspaceEventCreateWorkspace(this.request);
|
WorkspaceEventCreateWorkspace(this.request);
|
||||||
|
|
||||||
Future<Either<Workspace, WorkspaceError>> send() {
|
Future<Either<Workspace, WorkspaceError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = WorkspaceEvent.CreateWorkspace.toString()
|
..event = WorkspaceEvent.CreateWorkspace.toString()
|
||||||
..payload = requestToBytes(this.request);
|
..payload = requestToBytes(this.request);
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request)
|
||||||
.then((bytesResult) => bytesResult.fold(
|
.then((bytesResult) => bytesResult.fold(
|
||||||
(okBytes) => left(Workspace.fromBuffer(okBytes)),
|
(okBytes) => left(Workspace.fromBuffer(okBytes)),
|
||||||
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WorkspaceEventReadCurWorkspace {
|
class WorkspaceEventReadCurWorkspace {
|
||||||
WorkspaceEventReadCurWorkspace();
|
WorkspaceEventReadCurWorkspace();
|
||||||
|
|
||||||
Future<Either<Workspace, WorkspaceError>> send() {
|
Future<Either<Workspace, WorkspaceError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = WorkspaceEvent.ReadCurWorkspace.toString();
|
..event = WorkspaceEvent.ReadCurWorkspace.toString();
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||||
.then((bytesResult) => bytesResult.fold(
|
(okBytes) => left(Workspace.fromBuffer(okBytes)),
|
||||||
(okBytes) => left(Workspace.fromBuffer(okBytes)),
|
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
||||||
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
));
|
||||||
));
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class WorkspaceEventReadWorkspaces {
|
class WorkspaceEventReadWorkspaces {
|
||||||
QueryWorkspaceRequest request;
|
QueryWorkspaceRequest request;
|
||||||
WorkspaceEventReadWorkspaces(this.request);
|
WorkspaceEventReadWorkspaces(this.request);
|
||||||
|
|
||||||
Future<Either<RepeatedWorkspace, WorkspaceError>> send() {
|
Future<Either<RepeatedWorkspace, WorkspaceError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = WorkspaceEvent.ReadWorkspaces.toString()
|
..event = WorkspaceEvent.ReadWorkspaces.toString()
|
||||||
..payload = requestToBytes(this.request);
|
..payload = requestToBytes(this.request);
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request)
|
||||||
.then((bytesResult) => bytesResult.fold(
|
.then((bytesResult) => bytesResult.fold(
|
||||||
(okBytes) => left(RepeatedWorkspace.fromBuffer(okBytes)),
|
(okBytes) => left(RepeatedWorkspace.fromBuffer(okBytes)),
|
||||||
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WorkspaceEventDeleteWorkspace {
|
class WorkspaceEventDeleteWorkspace {
|
||||||
DeleteWorkspaceRequest request;
|
DeleteWorkspaceRequest request;
|
||||||
WorkspaceEventDeleteWorkspace(this.request);
|
WorkspaceEventDeleteWorkspace(this.request);
|
||||||
|
|
||||||
Future<Either<Unit, WorkspaceError>> send() {
|
Future<Either<Unit, WorkspaceError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = WorkspaceEvent.DeleteWorkspace.toString()
|
..event = WorkspaceEvent.DeleteWorkspace.toString()
|
||||||
..payload = requestToBytes(this.request);
|
..payload = requestToBytes(this.request);
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request)
|
||||||
.then((bytesResult) => bytesResult.fold(
|
.then((bytesResult) => bytesResult.fold(
|
||||||
(bytes) => left(unit),
|
(bytes) => left(unit),
|
||||||
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WorkspaceEventOpenWorkspace {
|
class WorkspaceEventOpenWorkspace {
|
||||||
QueryWorkspaceRequest request;
|
QueryWorkspaceRequest request;
|
||||||
WorkspaceEventOpenWorkspace(this.request);
|
WorkspaceEventOpenWorkspace(this.request);
|
||||||
|
|
||||||
Future<Either<Workspace, WorkspaceError>> send() {
|
Future<Either<Workspace, WorkspaceError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = WorkspaceEvent.OpenWorkspace.toString()
|
..event = WorkspaceEvent.OpenWorkspace.toString()
|
||||||
..payload = requestToBytes(this.request);
|
..payload = requestToBytes(this.request);
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request)
|
||||||
.then((bytesResult) => bytesResult.fold(
|
.then((bytesResult) => bytesResult.fold(
|
||||||
(okBytes) => left(Workspace.fromBuffer(okBytes)),
|
(okBytes) => left(Workspace.fromBuffer(okBytes)),
|
||||||
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WorkspaceEventCreateApp {
|
class WorkspaceEventCreateApp {
|
||||||
CreateAppRequest request;
|
CreateAppRequest request;
|
||||||
WorkspaceEventCreateApp(this.request);
|
WorkspaceEventCreateApp(this.request);
|
||||||
|
|
||||||
Future<Either<App, WorkspaceError>> send() {
|
Future<Either<App, WorkspaceError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = WorkspaceEvent.CreateApp.toString()
|
..event = WorkspaceEvent.CreateApp.toString()
|
||||||
..payload = requestToBytes(this.request);
|
..payload = requestToBytes(this.request);
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request)
|
||||||
.then((bytesResult) => bytesResult.fold(
|
.then((bytesResult) => bytesResult.fold(
|
||||||
(okBytes) => left(App.fromBuffer(okBytes)),
|
(okBytes) => left(App.fromBuffer(okBytes)),
|
||||||
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WorkspaceEventDeleteApp {
|
class WorkspaceEventDeleteApp {
|
||||||
DeleteAppRequest request;
|
DeleteAppRequest request;
|
||||||
WorkspaceEventDeleteApp(this.request);
|
WorkspaceEventDeleteApp(this.request);
|
||||||
|
|
||||||
Future<Either<Unit, WorkspaceError>> send() {
|
Future<Either<Unit, WorkspaceError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = WorkspaceEvent.DeleteApp.toString()
|
..event = WorkspaceEvent.DeleteApp.toString()
|
||||||
..payload = requestToBytes(this.request);
|
..payload = requestToBytes(this.request);
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request)
|
||||||
.then((bytesResult) => bytesResult.fold(
|
.then((bytesResult) => bytesResult.fold(
|
||||||
(bytes) => left(unit),
|
(bytes) => left(unit),
|
||||||
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WorkspaceEventReadApp {
|
class WorkspaceEventReadApp {
|
||||||
QueryAppRequest request;
|
QueryAppRequest request;
|
||||||
WorkspaceEventReadApp(this.request);
|
WorkspaceEventReadApp(this.request);
|
||||||
|
|
||||||
Future<Either<App, WorkspaceError>> send() {
|
Future<Either<App, WorkspaceError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = WorkspaceEvent.ReadApp.toString()
|
..event = WorkspaceEvent.ReadApp.toString()
|
||||||
..payload = requestToBytes(this.request);
|
..payload = requestToBytes(this.request);
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request)
|
||||||
.then((bytesResult) => bytesResult.fold(
|
.then((bytesResult) => bytesResult.fold(
|
||||||
(okBytes) => left(App.fromBuffer(okBytes)),
|
(okBytes) => left(App.fromBuffer(okBytes)),
|
||||||
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WorkspaceEventUpdateApp {
|
class WorkspaceEventUpdateApp {
|
||||||
UpdateAppRequest request;
|
UpdateAppRequest request;
|
||||||
WorkspaceEventUpdateApp(this.request);
|
WorkspaceEventUpdateApp(this.request);
|
||||||
|
|
||||||
Future<Either<Unit, WorkspaceError>> send() {
|
Future<Either<Unit, WorkspaceError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = WorkspaceEvent.UpdateApp.toString()
|
..event = WorkspaceEvent.UpdateApp.toString()
|
||||||
..payload = requestToBytes(this.request);
|
..payload = requestToBytes(this.request);
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request)
|
||||||
.then((bytesResult) => bytesResult.fold(
|
.then((bytesResult) => bytesResult.fold(
|
||||||
(bytes) => left(unit),
|
(bytes) => left(unit),
|
||||||
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WorkspaceEventCreateView {
|
class WorkspaceEventCreateView {
|
||||||
CreateViewRequest request;
|
CreateViewRequest request;
|
||||||
WorkspaceEventCreateView(this.request);
|
WorkspaceEventCreateView(this.request);
|
||||||
|
|
||||||
Future<Either<View, WorkspaceError>> send() {
|
Future<Either<View, WorkspaceError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = WorkspaceEvent.CreateView.toString()
|
..event = WorkspaceEvent.CreateView.toString()
|
||||||
..payload = requestToBytes(this.request);
|
..payload = requestToBytes(this.request);
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request)
|
||||||
.then((bytesResult) => bytesResult.fold(
|
.then((bytesResult) => bytesResult.fold(
|
||||||
(okBytes) => left(View.fromBuffer(okBytes)),
|
(okBytes) => left(View.fromBuffer(okBytes)),
|
||||||
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WorkspaceEventReadView {
|
class WorkspaceEventReadView {
|
||||||
QueryViewRequest request;
|
QueryViewRequest request;
|
||||||
WorkspaceEventReadView(this.request);
|
WorkspaceEventReadView(this.request);
|
||||||
|
|
||||||
Future<Either<View, WorkspaceError>> send() {
|
Future<Either<View, WorkspaceError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = WorkspaceEvent.ReadView.toString()
|
..event = WorkspaceEvent.ReadView.toString()
|
||||||
..payload = requestToBytes(this.request);
|
..payload = requestToBytes(this.request);
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request)
|
||||||
.then((bytesResult) => bytesResult.fold(
|
.then((bytesResult) => bytesResult.fold(
|
||||||
(okBytes) => left(View.fromBuffer(okBytes)),
|
(okBytes) => left(View.fromBuffer(okBytes)),
|
||||||
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WorkspaceEventUpdateView {
|
class WorkspaceEventUpdateView {
|
||||||
UpdateViewRequest request;
|
UpdateViewRequest request;
|
||||||
WorkspaceEventUpdateView(this.request);
|
WorkspaceEventUpdateView(this.request);
|
||||||
|
|
||||||
Future<Either<Unit, WorkspaceError>> send() {
|
Future<Either<Unit, WorkspaceError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = WorkspaceEvent.UpdateView.toString()
|
..event = WorkspaceEvent.UpdateView.toString()
|
||||||
..payload = requestToBytes(this.request);
|
..payload = requestToBytes(this.request);
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request)
|
||||||
.then((bytesResult) => bytesResult.fold(
|
.then((bytesResult) => bytesResult.fold(
|
||||||
(bytes) => left(unit),
|
(bytes) => left(unit),
|
||||||
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WorkspaceEventDeleteView {
|
class WorkspaceEventDeleteView {
|
||||||
DeleteViewRequest request;
|
DeleteViewRequest request;
|
||||||
WorkspaceEventDeleteView(this.request);
|
WorkspaceEventDeleteView(this.request);
|
||||||
|
|
||||||
Future<Either<Unit, WorkspaceError>> send() {
|
Future<Either<Unit, WorkspaceError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = WorkspaceEvent.DeleteView.toString()
|
..event = WorkspaceEvent.DeleteView.toString()
|
||||||
..payload = requestToBytes(this.request);
|
..payload = requestToBytes(this.request);
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request)
|
||||||
.then((bytesResult) => bytesResult.fold(
|
.then((bytesResult) => bytesResult.fold(
|
||||||
(bytes) => left(unit),
|
(bytes) => left(unit),
|
||||||
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class EditorEventCreateDoc {
|
class EditorEventCreateDoc {
|
||||||
CreateDocRequest request;
|
CreateDocRequest request;
|
||||||
EditorEventCreateDoc(this.request);
|
EditorEventCreateDoc(this.request);
|
||||||
|
|
||||||
Future<Either<DocInfo, DocError>> send() {
|
Future<Either<DocInfo, DocError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = EditorEvent.CreateDoc.toString()
|
..event = EditorEvent.CreateDoc.toString()
|
||||||
..payload = requestToBytes(this.request);
|
..payload = requestToBytes(this.request);
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request)
|
||||||
.then((bytesResult) => bytesResult.fold(
|
.then((bytesResult) => bytesResult.fold(
|
||||||
(okBytes) => left(DocInfo.fromBuffer(okBytes)),
|
(okBytes) => left(DocInfo.fromBuffer(okBytes)),
|
||||||
(errBytes) => right(DocError.fromBuffer(errBytes)),
|
(errBytes) => right(DocError.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class EditorEventUpdateDoc {
|
class EditorEventUpdateDoc {
|
||||||
UpdateDocRequest request;
|
UpdateDocRequest request;
|
||||||
EditorEventUpdateDoc(this.request);
|
EditorEventUpdateDoc(this.request);
|
||||||
|
|
||||||
Future<Either<Unit, DocError>> send() {
|
Future<Either<Unit, DocError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = EditorEvent.UpdateDoc.toString()
|
..event = EditorEvent.UpdateDoc.toString()
|
||||||
..payload = requestToBytes(this.request);
|
..payload = requestToBytes(this.request);
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request)
|
||||||
.then((bytesResult) => bytesResult.fold(
|
.then((bytesResult) => bytesResult.fold(
|
||||||
(bytes) => left(unit),
|
(bytes) => left(unit),
|
||||||
(errBytes) => right(DocError.fromBuffer(errBytes)),
|
(errBytes) => right(DocError.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class EditorEventReadDocInfo {
|
class EditorEventReadDocInfo {
|
||||||
QueryDocRequest request;
|
QueryDocRequest request;
|
||||||
EditorEventReadDocInfo(this.request);
|
EditorEventReadDocInfo(this.request);
|
||||||
|
|
||||||
Future<Either<DocInfo, DocError>> send() {
|
Future<Either<DocInfo, DocError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = EditorEvent.ReadDocInfo.toString()
|
..event = EditorEvent.ReadDocInfo.toString()
|
||||||
..payload = requestToBytes(this.request);
|
..payload = requestToBytes(this.request);
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request)
|
||||||
.then((bytesResult) => bytesResult.fold(
|
.then((bytesResult) => bytesResult.fold(
|
||||||
(okBytes) => left(DocInfo.fromBuffer(okBytes)),
|
(okBytes) => left(DocInfo.fromBuffer(okBytes)),
|
||||||
(errBytes) => right(DocError.fromBuffer(errBytes)),
|
(errBytes) => right(DocError.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class EditorEventReadDocData {
|
class EditorEventReadDocData {
|
||||||
QueryDocDataRequest request;
|
QueryDocDataRequest request;
|
||||||
EditorEventReadDocData(this.request);
|
EditorEventReadDocData(this.request);
|
||||||
|
|
||||||
Future<Either<DocData, DocError>> send() {
|
Future<Either<DocData, DocError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = EditorEvent.ReadDocData.toString()
|
..event = EditorEvent.ReadDocData.toString()
|
||||||
..payload = requestToBytes(this.request);
|
..payload = requestToBytes(this.request);
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request)
|
||||||
.then((bytesResult) => bytesResult.fold(
|
.then((bytesResult) => bytesResult.fold(
|
||||||
(okBytes) => left(DocData.fromBuffer(okBytes)),
|
(okBytes) => left(DocData.fromBuffer(okBytes)),
|
||||||
(errBytes) => right(DocError.fromBuffer(errBytes)),
|
(errBytes) => right(DocError.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UserEventGetStatus {
|
class UserEventGetUserProfile {
|
||||||
UserEventGetStatus();
|
UserEventGetUserProfile();
|
||||||
|
|
||||||
Future<Either<UserDetail, UserError>> send() {
|
Future<Either<UserProfile, UserError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = UserEvent.GetUserProfile.toString();
|
..event = UserEvent.GetUserProfile.toString();
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||||
.then((bytesResult) => bytesResult.fold(
|
(okBytes) => left(UserProfile.fromBuffer(okBytes)),
|
||||||
(okBytes) => left(UserDetail.fromBuffer(okBytes)),
|
(errBytes) => right(UserError.fromBuffer(errBytes)),
|
||||||
(errBytes) => right(UserError.fromBuffer(errBytes)),
|
));
|
||||||
));
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class UserEventSignIn {
|
class UserEventSignIn {
|
||||||
SignInRequest request;
|
SignInRequest request;
|
||||||
UserEventSignIn(this.request);
|
UserEventSignIn(this.request);
|
||||||
|
|
||||||
Future<Either<UserDetail, UserError>> send() {
|
Future<Either<UserProfile, UserError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = UserEvent.SignIn.toString()
|
..event = UserEvent.SignIn.toString()
|
||||||
..payload = requestToBytes(this.request);
|
..payload = requestToBytes(this.request);
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request)
|
||||||
.then((bytesResult) => bytesResult.fold(
|
.then((bytesResult) => bytesResult.fold(
|
||||||
(okBytes) => left(UserDetail.fromBuffer(okBytes)),
|
(okBytes) => left(UserProfile.fromBuffer(okBytes)),
|
||||||
(errBytes) => right(UserError.fromBuffer(errBytes)),
|
(errBytes) => right(UserError.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UserEventSignUp {
|
class UserEventSignUp {
|
||||||
SignUpRequest request;
|
SignUpRequest request;
|
||||||
UserEventSignUp(this.request);
|
UserEventSignUp(this.request);
|
||||||
|
|
||||||
Future<Either<UserDetail, UserError>> send() {
|
Future<Either<UserProfile, UserError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = UserEvent.SignUp.toString()
|
..event = UserEvent.SignUp.toString()
|
||||||
..payload = requestToBytes(this.request);
|
..payload = requestToBytes(this.request);
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request)
|
||||||
.then((bytesResult) => bytesResult.fold(
|
.then((bytesResult) => bytesResult.fold(
|
||||||
(okBytes) => left(UserDetail.fromBuffer(okBytes)),
|
(okBytes) => left(UserProfile.fromBuffer(okBytes)),
|
||||||
(errBytes) => right(UserError.fromBuffer(errBytes)),
|
(errBytes) => right(UserError.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UserEventSignOut {
|
class UserEventSignOut {
|
||||||
UserEventSignOut();
|
UserEventSignOut();
|
||||||
|
|
||||||
Future<Either<Unit, UserError>> send() {
|
Future<Either<Unit, UserError>> send() {
|
||||||
final request = FFIRequest.create()..event = UserEvent.SignOut.toString();
|
final request = FFIRequest.create()
|
||||||
|
..event = UserEvent.SignOut.toString();
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||||
.then((bytesResult) => bytesResult.fold(
|
(bytes) => left(unit),
|
||||||
(bytes) => left(unit),
|
(errBytes) => right(UserError.fromBuffer(errBytes)),
|
||||||
(errBytes) => right(UserError.fromBuffer(errBytes)),
|
));
|
||||||
));
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class UserEventUpdateUser {
|
class UserEventUpdateUser {
|
||||||
UpdateUserRequest request;
|
UpdateUserRequest request;
|
||||||
UserEventUpdateUser(this.request);
|
UserEventUpdateUser(this.request);
|
||||||
|
|
||||||
Future<Either<Unit, UserError>> send() {
|
Future<Either<Unit, UserError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = UserEvent.UpdateUser.toString()
|
..event = UserEvent.UpdateUser.toString()
|
||||||
..payload = requestToBytes(this.request);
|
..payload = requestToBytes(this.request);
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request)
|
||||||
.then((bytesResult) => bytesResult.fold(
|
.then((bytesResult) => bytesResult.fold(
|
||||||
(bytes) => left(unit),
|
(bytes) => left(unit),
|
||||||
(errBytes) => right(UserError.fromBuffer(errBytes)),
|
(errBytes) => right(UserError.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Auto-generated, do not edit
|
// Auto-generated, do not edit
|
||||||
export './user_table.pb.dart';
|
export './user_table.pb.dart';
|
||||||
export './errors.pb.dart';
|
export './errors.pb.dart';
|
||||||
export './user_detail.pb.dart';
|
export './user_profile.pb.dart';
|
||||||
export './event.pb.dart';
|
export './event.pb.dart';
|
||||||
export './auth.pb.dart';
|
export './auth.pb.dart';
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
///
|
///
|
||||||
// Generated code. Do not modify.
|
// Generated code. Do not modify.
|
||||||
// source: user_detail.proto
|
// source: user_profile.proto
|
||||||
//
|
//
|
||||||
// @dart = 2.12
|
// @dart = 2.12
|
||||||
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
|
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
|
||||||
@ -9,7 +9,7 @@ import 'dart:core' as $core;
|
|||||||
|
|
||||||
import 'package:protobuf/protobuf.dart' as $pb;
|
import 'package:protobuf/protobuf.dart' as $pb;
|
||||||
|
|
||||||
export 'user_detail.pbenum.dart';
|
export 'user_profile.pbenum.dart';
|
||||||
|
|
||||||
class UserToken extends $pb.GeneratedMessage {
|
class UserToken extends $pb.GeneratedMessage {
|
||||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UserToken', createEmptyInstance: create)
|
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UserToken', createEmptyInstance: create)
|
||||||
@ -58,16 +58,16 @@ class UserToken extends $pb.GeneratedMessage {
|
|||||||
void clearToken() => clearField(1);
|
void clearToken() => clearField(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
class UserDetail extends $pb.GeneratedMessage {
|
class UserProfile extends $pb.GeneratedMessage {
|
||||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UserDetail', createEmptyInstance: create)
|
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UserProfile', createEmptyInstance: create)
|
||||||
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'id')
|
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'id')
|
||||||
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'email')
|
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'email')
|
||||||
..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name')
|
..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name')
|
||||||
..hasRequiredFields = false
|
..hasRequiredFields = false
|
||||||
;
|
;
|
||||||
|
|
||||||
UserDetail._() : super();
|
UserProfile._() : super();
|
||||||
factory UserDetail({
|
factory UserProfile({
|
||||||
$core.String? id,
|
$core.String? id,
|
||||||
$core.String? email,
|
$core.String? email,
|
||||||
$core.String? name,
|
$core.String? name,
|
||||||
@ -84,26 +84,26 @@ class UserDetail extends $pb.GeneratedMessage {
|
|||||||
}
|
}
|
||||||
return _result;
|
return _result;
|
||||||
}
|
}
|
||||||
factory UserDetail.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
|
factory UserProfile.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
|
||||||
factory UserDetail.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
|
factory UserProfile.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
|
||||||
@$core.Deprecated(
|
@$core.Deprecated(
|
||||||
'Using this can add significant overhead to your binary. '
|
'Using this can add significant overhead to your binary. '
|
||||||
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
|
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
|
||||||
'Will be removed in next major version')
|
'Will be removed in next major version')
|
||||||
UserDetail clone() => UserDetail()..mergeFromMessage(this);
|
UserProfile clone() => UserProfile()..mergeFromMessage(this);
|
||||||
@$core.Deprecated(
|
@$core.Deprecated(
|
||||||
'Using this can add significant overhead to your binary. '
|
'Using this can add significant overhead to your binary. '
|
||||||
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
|
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
|
||||||
'Will be removed in next major version')
|
'Will be removed in next major version')
|
||||||
UserDetail copyWith(void Function(UserDetail) updates) => super.copyWith((message) => updates(message as UserDetail)) as UserDetail; // ignore: deprecated_member_use
|
UserProfile copyWith(void Function(UserProfile) updates) => super.copyWith((message) => updates(message as UserProfile)) as UserProfile; // ignore: deprecated_member_use
|
||||||
$pb.BuilderInfo get info_ => _i;
|
$pb.BuilderInfo get info_ => _i;
|
||||||
@$core.pragma('dart2js:noInline')
|
@$core.pragma('dart2js:noInline')
|
||||||
static UserDetail create() => UserDetail._();
|
static UserProfile create() => UserProfile._();
|
||||||
UserDetail createEmptyInstance() => create();
|
UserProfile createEmptyInstance() => create();
|
||||||
static $pb.PbList<UserDetail> createRepeated() => $pb.PbList<UserDetail>();
|
static $pb.PbList<UserProfile> createRepeated() => $pb.PbList<UserProfile>();
|
||||||
@$core.pragma('dart2js:noInline')
|
@$core.pragma('dart2js:noInline')
|
||||||
static UserDetail getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<UserDetail>(create);
|
static UserProfile getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<UserProfile>(create);
|
||||||
static UserDetail? _defaultInstance;
|
static UserProfile? _defaultInstance;
|
||||||
|
|
||||||
@$pb.TagNumber(1)
|
@$pb.TagNumber(1)
|
||||||
$core.String get id => $_getSZ(0);
|
$core.String get id => $_getSZ(0);
|
@ -1,6 +1,6 @@
|
|||||||
///
|
///
|
||||||
// Generated code. Do not modify.
|
// Generated code. Do not modify.
|
||||||
// source: user_detail.proto
|
// source: user_profile.proto
|
||||||
//
|
//
|
||||||
// @dart = 2.12
|
// @dart = 2.12
|
||||||
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
|
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
|
@ -1,6 +1,6 @@
|
|||||||
///
|
///
|
||||||
// Generated code. Do not modify.
|
// Generated code. Do not modify.
|
||||||
// source: user_detail.proto
|
// source: user_profile.proto
|
||||||
//
|
//
|
||||||
// @dart = 2.12
|
// @dart = 2.12
|
||||||
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
|
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
|
||||||
@ -30,9 +30,9 @@ const UserToken$json = const {
|
|||||||
|
|
||||||
/// Descriptor for `UserToken`. Decode as a `google.protobuf.DescriptorProto`.
|
/// Descriptor for `UserToken`. Decode as a `google.protobuf.DescriptorProto`.
|
||||||
final $typed_data.Uint8List userTokenDescriptor = $convert.base64Decode('CglVc2VyVG9rZW4SFAoFdG9rZW4YASABKAlSBXRva2Vu');
|
final $typed_data.Uint8List userTokenDescriptor = $convert.base64Decode('CglVc2VyVG9rZW4SFAoFdG9rZW4YASABKAlSBXRva2Vu');
|
||||||
@$core.Deprecated('Use userDetailDescriptor instead')
|
@$core.Deprecated('Use userProfileDescriptor instead')
|
||||||
const UserDetail$json = const {
|
const UserProfile$json = const {
|
||||||
'1': 'UserDetail',
|
'1': 'UserProfile',
|
||||||
'2': const [
|
'2': const [
|
||||||
const {'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'},
|
const {'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'},
|
||||||
const {'1': 'email', '3': 2, '4': 1, '5': 9, '10': 'email'},
|
const {'1': 'email', '3': 2, '4': 1, '5': 9, '10': 'email'},
|
||||||
@ -40,8 +40,8 @@ const UserDetail$json = const {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Descriptor for `UserDetail`. Decode as a `google.protobuf.DescriptorProto`.
|
/// Descriptor for `UserProfile`. Decode as a `google.protobuf.DescriptorProto`.
|
||||||
final $typed_data.Uint8List userDetailDescriptor = $convert.base64Decode('CgpVc2VyRGV0YWlsEg4KAmlkGAEgASgJUgJpZBIUCgVlbWFpbBgCIAEoCVIFZW1haWwSEgoEbmFtZRgDIAEoCVIEbmFtZQ==');
|
final $typed_data.Uint8List userProfileDescriptor = $convert.base64Decode('CgtVc2VyUHJvZmlsZRIOCgJpZBgBIAEoCVICaWQSFAoFZW1haWwYAiABKAlSBWVtYWlsEhIKBG5hbWUYAyABKAlSBG5hbWU=');
|
||||||
@$core.Deprecated('Use updateUserRequestDescriptor instead')
|
@$core.Deprecated('Use updateUserRequestDescriptor instead')
|
||||||
const UpdateUserRequest$json = const {
|
const UpdateUserRequest$json = const {
|
||||||
'1': 'UpdateUserRequest',
|
'1': 'UpdateUserRequest',
|
@ -1,9 +1,9 @@
|
|||||||
///
|
///
|
||||||
// Generated code. Do not modify.
|
// Generated code. Do not modify.
|
||||||
// source: user_detail.proto
|
// source: user_profile.proto
|
||||||
//
|
//
|
||||||
// @dart = 2.12
|
// @dart = 2.12
|
||||||
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
|
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
|
||||||
|
|
||||||
export 'user_detail.pb.dart';
|
export 'user_profile.pb.dart';
|
||||||
|
|
@ -85,8 +85,8 @@ fn user_scope() -> Scope {
|
|||||||
.route(web::delete().to(user::sign_out_handler))
|
.route(web::delete().to(user::sign_out_handler))
|
||||||
)
|
)
|
||||||
.service(web::resource("/user")
|
.service(web::resource("/user")
|
||||||
.route(web::patch().to(user::set_user_detail_handler))
|
.route(web::patch().to(user::set_user_profile_handler))
|
||||||
.route(web::get().to(user::get_user_detail_handler))
|
.route(web::get().to(user::get_user_profile_handler))
|
||||||
)
|
)
|
||||||
.service(web::resource("/register")
|
.service(web::resource("/register")
|
||||||
.route(web::post().to(user::register_handler))
|
.route(web::post().to(user::register_handler))
|
||||||
|
@ -21,7 +21,7 @@ use flowy_user::{
|
|||||||
SignUpParams,
|
SignUpParams,
|
||||||
SignUpResponse,
|
SignUpResponse,
|
||||||
UpdateUserParams,
|
UpdateUserParams,
|
||||||
UserDetail,
|
UserProfile,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use sqlx::{PgPool, Postgres};
|
use sqlx::{PgPool, Postgres};
|
||||||
@ -99,7 +99,7 @@ pub async fn register_user(
|
|||||||
FlowyResponse::success().pb(response_data)
|
FlowyResponse::success().pb(response_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn get_user_details(
|
pub(crate) async fn get_user_profile(
|
||||||
pool: &PgPool,
|
pool: &PgPool,
|
||||||
logged_user: LoggedUser,
|
logged_user: LoggedUser,
|
||||||
) -> Result<FlowyResponse, ServerError> {
|
) -> Result<FlowyResponse, ServerError> {
|
||||||
@ -124,14 +124,14 @@ pub(crate) async fn get_user_details(
|
|||||||
// update the user active time
|
// update the user active time
|
||||||
let _ = AUTHORIZED_USERS.store_auth(logged_user, true)?;
|
let _ = AUTHORIZED_USERS.store_auth(logged_user, true)?;
|
||||||
|
|
||||||
let mut user_detail = UserDetail::default();
|
let mut user_profile = UserProfile::default();
|
||||||
user_detail.set_id(user_table.id.to_string());
|
user_profile.set_id(user_table.id.to_string());
|
||||||
user_detail.set_email(user_table.email);
|
user_profile.set_email(user_table.email);
|
||||||
user_detail.set_name(user_table.name);
|
user_profile.set_name(user_table.name);
|
||||||
FlowyResponse::success().pb(user_detail)
|
FlowyResponse::success().pb(user_profile)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn set_user_detail(
|
pub(crate) async fn set_user_profile(
|
||||||
pool: &PgPool,
|
pool: &PgPool,
|
||||||
logged_user: LoggedUser,
|
logged_user: LoggedUser,
|
||||||
params: UpdateUserParams,
|
params: UpdateUserParams,
|
||||||
|
@ -6,9 +6,9 @@ use actix_web::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::user_service::{
|
use crate::user_service::{
|
||||||
get_user_details,
|
get_user_profile,
|
||||||
register_user,
|
register_user,
|
||||||
set_user_detail,
|
set_user_profile,
|
||||||
sign_in,
|
sign_in,
|
||||||
sign_out,
|
sign_out,
|
||||||
LoggedUser,
|
LoggedUser,
|
||||||
@ -40,21 +40,21 @@ pub async fn sign_out_handler(
|
|||||||
Ok(response.into())
|
Ok(response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_user_detail_handler(
|
pub async fn get_user_profile_handler(
|
||||||
logged_user: LoggedUser,
|
logged_user: LoggedUser,
|
||||||
pool: Data<PgPool>,
|
pool: Data<PgPool>,
|
||||||
) -> Result<HttpResponse, ServerError> {
|
) -> Result<HttpResponse, ServerError> {
|
||||||
let response = get_user_details(pool.get_ref(), logged_user).await?;
|
let response = get_user_profile(pool.get_ref(), logged_user).await?;
|
||||||
Ok(response.into())
|
Ok(response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn set_user_detail_handler(
|
pub async fn set_user_profile_handler(
|
||||||
logged_user: LoggedUser,
|
logged_user: LoggedUser,
|
||||||
pool: Data<PgPool>,
|
pool: Data<PgPool>,
|
||||||
payload: Payload,
|
payload: Payload,
|
||||||
) -> Result<HttpResponse, ServerError> {
|
) -> Result<HttpResponse, ServerError> {
|
||||||
let params: UpdateUserParams = parse_from_payload(payload).await?;
|
let params: UpdateUserParams = parse_from_payload(payload).await?;
|
||||||
let response = set_user_detail(pool.get_ref(), logged_user, params).await?;
|
let response = set_user_profile(pool.get_ref(), logged_user, params).await?;
|
||||||
Ok(response.into())
|
Ok(response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,14 +56,14 @@ async fn user_sign_out() {
|
|||||||
app.sign_out(&token).await;
|
app.sign_out(&token).await;
|
||||||
|
|
||||||
// user_detail will be empty because use was sign out.
|
// user_detail will be empty because use was sign out.
|
||||||
app.get_user_detail(&token).await;
|
app.get_user_profile(&token).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn user_get_detail() {
|
async fn user_get_detail() {
|
||||||
let app = spawn_app().await;
|
let app = spawn_app().await;
|
||||||
let sign_up_resp = sign_up_user(&app).await;
|
let sign_up_resp = sign_up_user(&app).await;
|
||||||
log::info!("{:?}", app.get_user_detail(&sign_up_resp.token).await);
|
log::info!("{:?}", app.get_user_profile(&sign_up_resp.token).await);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -74,7 +74,7 @@ async fn user_update_password() {
|
|||||||
let sign_up_resp = register_user(&app, email, password).await;
|
let sign_up_resp = register_user(&app, email, password).await;
|
||||||
|
|
||||||
let params = UpdateUserParams::new(&sign_up_resp.user_id).password("Hello123!");
|
let params = UpdateUserParams::new(&sign_up_resp.user_id).password("Hello123!");
|
||||||
app.update_user_detail(&sign_up_resp.token, params)
|
app.update_user_profile(&sign_up_resp.token, params)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@ -97,11 +97,11 @@ async fn user_update_name() {
|
|||||||
let sign_up_resp = sign_up_user(&app).await;
|
let sign_up_resp = sign_up_user(&app).await;
|
||||||
let name = "tom".to_string();
|
let name = "tom".to_string();
|
||||||
let params = UpdateUserParams::new(&sign_up_resp.user_id).name(&name);
|
let params = UpdateUserParams::new(&sign_up_resp.user_id).name(&name);
|
||||||
app.update_user_detail(&sign_up_resp.token, params)
|
app.update_user_profile(&sign_up_resp.token, params)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let user = app.get_user_detail(&sign_up_resp.token).await;
|
let user = app.get_user_profile(&sign_up_resp.token).await;
|
||||||
assert_eq!(user.name, name);
|
assert_eq!(user.name, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,11 +111,11 @@ async fn user_update_email() {
|
|||||||
let sign_up_resp = sign_up_user(&app).await;
|
let sign_up_resp = sign_up_user(&app).await;
|
||||||
let email = "123@gmail.com".to_string();
|
let email = "123@gmail.com".to_string();
|
||||||
let params = UpdateUserParams::new(&sign_up_resp.user_id).email(&email);
|
let params = UpdateUserParams::new(&sign_up_resp.user_id).email(&email);
|
||||||
app.update_user_detail(&sign_up_resp.token, params)
|
app.update_user_profile(&sign_up_resp.token, params)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let user = app.get_user_detail(&sign_up_resp.token).await;
|
let user = app.get_user_profile(&sign_up_resp.token).await;
|
||||||
assert_eq!(user.email, email);
|
assert_eq!(user.email, email);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,19 +31,19 @@ impl TestApp {
|
|||||||
let _ = user_sign_out_request(token, &url).await.unwrap();
|
let _ = user_sign_out_request(token, &url).await.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_user_detail(&self, token: &str) -> UserDetail {
|
pub async fn get_user_profile(&self, token: &str) -> UserProfile {
|
||||||
let url = format!("{}/api/user", self.address);
|
let url = format!("{}/api/user", self.address);
|
||||||
let user_detail = get_user_detail_request(token, &url).await.unwrap();
|
let user_profile = get_user_profile_request(token, &url).await.unwrap();
|
||||||
user_detail
|
user_profile
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_user_detail(
|
pub async fn update_user_profile(
|
||||||
&self,
|
&self,
|
||||||
token: &str,
|
token: &str,
|
||||||
params: UpdateUserParams,
|
params: UpdateUserParams,
|
||||||
) -> Result<(), UserError> {
|
) -> Result<(), UserError> {
|
||||||
let url = format!("{}/api/user", self.address);
|
let url = format!("{}/api/user", self.address);
|
||||||
update_user_detail_request(token, params, &url).await
|
update_user_profile_request(token, params, &url).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_workspace(&self, params: CreateWorkspaceParams, token: &str) -> Workspace {
|
pub async fn create_workspace(&self, params: CreateWorkspaceParams, token: &str) -> Workspace {
|
||||||
|
@ -66,7 +66,7 @@ pub fn category_from_str(type_str: &str) -> TypeCategory {
|
|||||||
| "SignUpParams"
|
| "SignUpParams"
|
||||||
| "SignUpResponse"
|
| "SignUpResponse"
|
||||||
| "UserToken"
|
| "UserToken"
|
||||||
| "UserDetail"
|
| "UserProfile"
|
||||||
| "UpdateUserRequest"
|
| "UpdateUserRequest"
|
||||||
| "UpdateUserParams"
|
| "UpdateUserParams"
|
||||||
| "UserError"
|
| "UserError"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use flowy_dispatch::prelude::{EventDispatch, EventResponse, FromBytes, ModuleRequest, StatusCode, ToBytes};
|
use flowy_dispatch::prelude::{EventDispatch, EventResponse, FromBytes, ModuleRequest, StatusCode, ToBytes};
|
||||||
use flowy_user::entities::UserDetail;
|
use flowy_user::entities::UserProfile;
|
||||||
use std::{
|
use std::{
|
||||||
fmt::{Debug, Display},
|
fmt::{Debug, Display},
|
||||||
hash::Hash,
|
hash::Hash,
|
||||||
@ -26,13 +26,13 @@ impl WorkspaceTest {
|
|||||||
pub type UserTest = Builder<UserError>;
|
pub type UserTest = Builder<UserError>;
|
||||||
impl UserTest {
|
impl UserTest {
|
||||||
pub fn new(sdk: FlowyTestSDK) -> Self { Builder::test(TestContext::new(sdk)) }
|
pub fn new(sdk: FlowyTestSDK) -> Self { Builder::test(TestContext::new(sdk)) }
|
||||||
pub fn user_detail(&self) -> &Option<UserDetail> { &self.user_detail }
|
pub fn user_profile(&self) -> &Option<UserProfile> { &self.user_profile }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Builder<E> {
|
pub struct Builder<E> {
|
||||||
context: TestContext,
|
context: TestContext,
|
||||||
user_detail: Option<UserDetail>,
|
user_profile: Option<UserProfile>,
|
||||||
err_phantom: PhantomData<E>,
|
err_phantom: PhantomData<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ where
|
|||||||
pub(crate) fn test(context: TestContext) -> Self {
|
pub(crate) fn test(context: TestContext) -> Self {
|
||||||
Self {
|
Self {
|
||||||
context,
|
context,
|
||||||
user_detail: None,
|
user_profile: None,
|
||||||
err_phantom: PhantomData,
|
err_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ use flowy_dispatch::prelude::{EventDispatch, ModuleRequest, ToBytes};
|
|||||||
use flowy_infra::{kv::KV, uuid};
|
use flowy_infra::{kv::KV, uuid};
|
||||||
|
|
||||||
use flowy_user::{
|
use flowy_user::{
|
||||||
entities::{SignInRequest, SignUpRequest, UserDetail},
|
entities::{SignInRequest, SignUpRequest, UserProfile},
|
||||||
errors::{ErrorBuilder, ErrorCode, UserError},
|
errors::{ErrorBuilder, ErrorCode, UserError},
|
||||||
event::UserEvent::{SignIn, SignOut, SignUp},
|
event::UserEvent::{SignIn, SignOut, SignUp},
|
||||||
};
|
};
|
||||||
@ -76,7 +76,7 @@ pub(crate) fn create_default_workspace_if_need(dispatch: Arc<EventDispatch>, use
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct SignUpContext {
|
pub struct SignUpContext {
|
||||||
pub user_detail: UserDetail,
|
pub user_profile: UserProfile,
|
||||||
pub password: String,
|
pub password: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,17 +91,17 @@ pub fn sign_up(dispatch: Arc<EventDispatch>) -> SignUpContext {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let request = ModuleRequest::new(SignUp).payload(payload);
|
let request = ModuleRequest::new(SignUp).payload(payload);
|
||||||
let user_detail = EventDispatch::sync_send(dispatch.clone(), request)
|
let user_profile = EventDispatch::sync_send(dispatch.clone(), request)
|
||||||
.parse::<UserDetail, UserError>()
|
.parse::<UserProfile, UserError>()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let _ = create_default_workspace_if_need(dispatch.clone(), &user_detail.id);
|
let _ = create_default_workspace_if_need(dispatch.clone(), &user_profile.id);
|
||||||
SignUpContext { user_detail, password }
|
SignUpContext { user_profile, password }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn sign_in(dispatch: Arc<EventDispatch>) -> UserDetail {
|
fn sign_in(dispatch: Arc<EventDispatch>) -> UserProfile {
|
||||||
let payload = SignInRequest {
|
let payload = SignInRequest {
|
||||||
email: login_email(),
|
email: login_email(),
|
||||||
password: login_password(),
|
password: login_password(),
|
||||||
@ -110,12 +110,12 @@ fn sign_in(dispatch: Arc<EventDispatch>) -> UserDetail {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let request = ModuleRequest::new(SignIn).payload(payload);
|
let request = ModuleRequest::new(SignIn).payload(payload);
|
||||||
let user_detail = EventDispatch::sync_send(dispatch, request)
|
let user_profile = EventDispatch::sync_send(dispatch, request)
|
||||||
.parse::<UserDetail, UserError>()
|
.parse::<UserProfile, UserError>()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
user_detail
|
user_profile
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
@ -3,7 +3,7 @@ mod helper;
|
|||||||
|
|
||||||
use crate::helper::*;
|
use crate::helper::*;
|
||||||
use flowy_sdk::FlowySDK;
|
use flowy_sdk::FlowySDK;
|
||||||
use flowy_user::entities::UserDetail;
|
use flowy_user::entities::UserProfile;
|
||||||
|
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
pub use crate::{builder::*, helper::*, *};
|
pub use crate::{builder::*, helper::*, *};
|
||||||
@ -15,7 +15,7 @@ pub type FlowyTestSDK = FlowySDK;
|
|||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct FlowyEnv {
|
pub struct FlowyEnv {
|
||||||
pub sdk: FlowyTestSDK,
|
pub sdk: FlowyTestSDK,
|
||||||
pub user: UserDetail,
|
pub user: UserProfile,
|
||||||
pub password: String,
|
pub password: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ impl FlowyEnv {
|
|||||||
let result = sign_up(sdk.dispatch());
|
let result = sign_up(sdk.dispatch());
|
||||||
let env = Self {
|
let env = Self {
|
||||||
sdk,
|
sdk,
|
||||||
user: result.user_detail,
|
user: result.user_profile,
|
||||||
password: result.password,
|
password: result.password,
|
||||||
};
|
};
|
||||||
env
|
env
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
pub use auth::*;
|
pub use auth::*;
|
||||||
pub use user_detail::*;
|
pub use user_profile::*;
|
||||||
pub mod parser;
|
pub mod parser;
|
||||||
|
|
||||||
pub mod auth;
|
pub mod auth;
|
||||||
mod user_detail;
|
mod user_profile;
|
||||||
|
@ -18,7 +18,7 @@ impl std::default::Default for UserStatus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ProtoBuf, Default, Debug, PartialEq, Eq, Clone)]
|
#[derive(ProtoBuf, Default, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct UserDetail {
|
pub struct UserProfile {
|
||||||
#[pb(index = 1)]
|
#[pb(index = 1)]
|
||||||
pub id: String,
|
pub id: String,
|
||||||
|
|
||||||
@ -36,9 +36,9 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
impl std::convert::From<UserTable> for UserDetail {
|
impl std::convert::From<UserTable> for UserProfile {
|
||||||
fn from(user: UserTable) -> Self {
|
fn from(user: UserTable) -> Self {
|
||||||
UserDetail {
|
UserProfile {
|
||||||
id: user.id,
|
id: user.id,
|
||||||
email: user.email,
|
email: user.email,
|
||||||
name: user.name,
|
name: user.name,
|
@ -4,13 +4,13 @@ use strum_macros::Display;
|
|||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
|
||||||
#[event_err = "UserError"]
|
#[event_err = "UserError"]
|
||||||
pub enum UserEvent {
|
pub enum UserEvent {
|
||||||
#[event(output = "UserDetail")]
|
#[event(output = "UserProfile")]
|
||||||
GetUserProfile = 0,
|
GetUserProfile = 0,
|
||||||
|
|
||||||
#[event(input = "SignInRequest", output = "UserDetail")]
|
#[event(input = "SignInRequest", output = "UserProfile")]
|
||||||
SignIn = 1,
|
SignIn = 1,
|
||||||
|
|
||||||
#[event(input = "SignUpRequest", output = "UserDetail")]
|
#[event(input = "SignUpRequest", output = "UserProfile")]
|
||||||
SignUp = 2,
|
SignUp = 2,
|
||||||
|
|
||||||
#[event(passthrough)]
|
#[event(passthrough)]
|
||||||
|
@ -4,10 +4,10 @@ use std::{convert::TryInto, sync::Arc};
|
|||||||
|
|
||||||
// tracing instrument 👉🏻 https://docs.rs/tracing/0.1.26/tracing/attr.instrument.html
|
// tracing instrument 👉🏻 https://docs.rs/tracing/0.1.26/tracing/attr.instrument.html
|
||||||
#[tracing::instrument(name = "sign_in", skip(data, session), fields(email = %data.email))]
|
#[tracing::instrument(name = "sign_in", skip(data, session), fields(email = %data.email))]
|
||||||
pub async fn sign_in(data: Data<SignInRequest>, session: Unit<Arc<UserSession>>) -> DataResult<UserDetail, UserError> {
|
pub async fn sign_in(data: Data<SignInRequest>, session: Unit<Arc<UserSession>>) -> DataResult<UserProfile, UserError> {
|
||||||
let params: SignInParams = data.into_inner().try_into()?;
|
let params: SignInParams = data.into_inner().try_into()?;
|
||||||
let user_detail = session.sign_in(params).await?;
|
let user_profile = session.sign_in(params).await?;
|
||||||
data_result(user_detail)
|
data_result(user_profile)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(
|
#[tracing::instrument(
|
||||||
@ -18,9 +18,9 @@ pub async fn sign_in(data: Data<SignInRequest>, session: Unit<Arc<UserSession>>)
|
|||||||
name = %data.name,
|
name = %data.name,
|
||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
pub async fn sign_up(data: Data<SignUpRequest>, session: Unit<Arc<UserSession>>) -> DataResult<UserDetail, UserError> {
|
pub async fn sign_up(data: Data<SignUpRequest>, session: Unit<Arc<UserSession>>) -> DataResult<UserProfile, UserError> {
|
||||||
let params: SignUpParams = data.into_inner().try_into()?;
|
let params: SignUpParams = data.into_inner().try_into()?;
|
||||||
let user_detail = session.sign_up(params).await?;
|
let user_profile = session.sign_up(params).await?;
|
||||||
|
|
||||||
data_result(user_detail)
|
data_result(user_profile)
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@ use flowy_dispatch::prelude::*;
|
|||||||
use std::{convert::TryInto, sync::Arc};
|
use std::{convert::TryInto, sync::Arc};
|
||||||
|
|
||||||
#[tracing::instrument(name = "get_user_status", skip(session))]
|
#[tracing::instrument(name = "get_user_status", skip(session))]
|
||||||
pub async fn user_profile_handler(session: Unit<Arc<UserSession>>) -> DataResult<UserDetail, UserError> {
|
pub async fn user_profile_handler(session: Unit<Arc<UserSession>>) -> DataResult<UserProfile, UserError> {
|
||||||
let user_detail = session.user_detail().await?;
|
let user_profile = session.user_profile().await?;
|
||||||
data_result(user_detail)
|
data_result(user_profile)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(name = "sign_out", skip(session))]
|
#[tracing::instrument(name = "sign_out", skip(session))]
|
||||||
|
@ -6,8 +6,8 @@ pub use user_table::*;
|
|||||||
mod errors;
|
mod errors;
|
||||||
pub use errors::*;
|
pub use errors::*;
|
||||||
|
|
||||||
mod user_detail;
|
mod user_profile;
|
||||||
pub use user_detail::*;
|
pub use user_profile::*;
|
||||||
|
|
||||||
mod event;
|
mod event;
|
||||||
pub use event::*;
|
pub use event::*;
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#![allow(trivial_casts)]
|
#![allow(trivial_casts)]
|
||||||
#![allow(unused_imports)]
|
#![allow(unused_imports)]
|
||||||
#![allow(unused_results)]
|
#![allow(unused_results)]
|
||||||
//! Generated file from `user_detail.proto`
|
//! Generated file from `user_profile.proto`
|
||||||
|
|
||||||
/// Generated files are compatible only with the same version
|
/// Generated files are compatible only with the same version
|
||||||
/// of protobuf runtime.
|
/// of protobuf runtime.
|
||||||
@ -183,7 +183,7 @@ impl ::protobuf::reflect::ProtobufValue for UserToken {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq,Clone,Default)]
|
#[derive(PartialEq,Clone,Default)]
|
||||||
pub struct UserDetail {
|
pub struct UserProfile {
|
||||||
// message fields
|
// message fields
|
||||||
pub id: ::std::string::String,
|
pub id: ::std::string::String,
|
||||||
pub email: ::std::string::String,
|
pub email: ::std::string::String,
|
||||||
@ -193,14 +193,14 @@ pub struct UserDetail {
|
|||||||
pub cached_size: ::protobuf::CachedSize,
|
pub cached_size: ::protobuf::CachedSize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::std::default::Default for &'a UserDetail {
|
impl<'a> ::std::default::Default for &'a UserProfile {
|
||||||
fn default() -> &'a UserDetail {
|
fn default() -> &'a UserProfile {
|
||||||
<UserDetail as ::protobuf::Message>::default_instance()
|
<UserProfile as ::protobuf::Message>::default_instance()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UserDetail {
|
impl UserProfile {
|
||||||
pub fn new() -> UserDetail {
|
pub fn new() -> UserProfile {
|
||||||
::std::default::Default::default()
|
::std::default::Default::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ impl UserDetail {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::protobuf::Message for UserDetail {
|
impl ::protobuf::Message for UserProfile {
|
||||||
fn is_initialized(&self) -> bool {
|
fn is_initialized(&self) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
@ -367,8 +367,8 @@ impl ::protobuf::Message for UserDetail {
|
|||||||
Self::descriptor_static()
|
Self::descriptor_static()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new() -> UserDetail {
|
fn new() -> UserProfile {
|
||||||
UserDetail::new()
|
UserProfile::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
|
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
|
||||||
@ -377,34 +377,34 @@ impl ::protobuf::Message for UserDetail {
|
|||||||
let mut fields = ::std::vec::Vec::new();
|
let mut fields = ::std::vec::Vec::new();
|
||||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||||
"id",
|
"id",
|
||||||
|m: &UserDetail| { &m.id },
|
|m: &UserProfile| { &m.id },
|
||||||
|m: &mut UserDetail| { &mut m.id },
|
|m: &mut UserProfile| { &mut m.id },
|
||||||
));
|
));
|
||||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||||
"email",
|
"email",
|
||||||
|m: &UserDetail| { &m.email },
|
|m: &UserProfile| { &m.email },
|
||||||
|m: &mut UserDetail| { &mut m.email },
|
|m: &mut UserProfile| { &mut m.email },
|
||||||
));
|
));
|
||||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||||
"name",
|
"name",
|
||||||
|m: &UserDetail| { &m.name },
|
|m: &UserProfile| { &m.name },
|
||||||
|m: &mut UserDetail| { &mut m.name },
|
|m: &mut UserProfile| { &mut m.name },
|
||||||
));
|
));
|
||||||
::protobuf::reflect::MessageDescriptor::new_pb_name::<UserDetail>(
|
::protobuf::reflect::MessageDescriptor::new_pb_name::<UserProfile>(
|
||||||
"UserDetail",
|
"UserProfile",
|
||||||
fields,
|
fields,
|
||||||
file_descriptor_proto()
|
file_descriptor_proto()
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_instance() -> &'static UserDetail {
|
fn default_instance() -> &'static UserProfile {
|
||||||
static instance: ::protobuf::rt::LazyV2<UserDetail> = ::protobuf::rt::LazyV2::INIT;
|
static instance: ::protobuf::rt::LazyV2<UserProfile> = ::protobuf::rt::LazyV2::INIT;
|
||||||
instance.get(UserDetail::new)
|
instance.get(UserProfile::new)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::protobuf::Clear for UserDetail {
|
impl ::protobuf::Clear for UserProfile {
|
||||||
fn clear(&mut self) {
|
fn clear(&mut self) {
|
||||||
self.id.clear();
|
self.id.clear();
|
||||||
self.email.clear();
|
self.email.clear();
|
||||||
@ -413,13 +413,13 @@ impl ::protobuf::Clear for UserDetail {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::fmt::Debug for UserDetail {
|
impl ::std::fmt::Debug for UserProfile {
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||||
::protobuf::text_format::fmt(self, f)
|
::protobuf::text_format::fmt(self, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::protobuf::reflect::ProtobufValue for UserDetail {
|
impl ::protobuf::reflect::ProtobufValue for UserProfile {
|
||||||
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
|
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
|
||||||
::protobuf::reflect::ReflectValueRef::Message(self)
|
::protobuf::reflect::ReflectValueRef::Message(self)
|
||||||
}
|
}
|
||||||
@ -1285,10 +1285,10 @@ impl ::protobuf::reflect::ProtobufValue for UserStatus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static file_descriptor_proto_data: &'static [u8] = b"\
|
static file_descriptor_proto_data: &'static [u8] = b"\
|
||||||
\n\x11user_detail.proto\"!\n\tUserToken\x12\x14\n\x05token\x18\x01\x20\
|
\n\x12user_profile.proto\"!\n\tUserToken\x12\x14\n\x05token\x18\x01\x20\
|
||||||
\x01(\tR\x05token\"F\n\nUserDetail\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\
|
\x01(\tR\x05token\"G\n\x0bUserProfile\x12\x0e\n\x02id\x18\x01\x20\x01(\t\
|
||||||
\x02id\x12\x14\n\x05email\x18\x02\x20\x01(\tR\x05email\x12\x12\n\x04name\
|
R\x02id\x12\x14\n\x05email\x18\x02\x20\x01(\tR\x05email\x12\x12\n\x04nam\
|
||||||
\x18\x03\x20\x01(\tR\x04name\"\xa1\x01\n\x11UpdateUserRequest\x12\x0e\n\
|
e\x18\x03\x20\x01(\tR\x04name\"\xa1\x01\n\x11UpdateUserRequest\x12\x0e\n\
|
||||||
\x02id\x18\x01\x20\x01(\tR\x02id\x12\x14\n\x04name\x18\x02\x20\x01(\tH\0\
|
\x02id\x18\x01\x20\x01(\tR\x02id\x12\x14\n\x04name\x18\x02\x20\x01(\tH\0\
|
||||||
R\x04name\x12\x16\n\x05email\x18\x03\x20\x01(\tH\x01R\x05email\x12\x1c\n\
|
R\x04name\x12\x16\n\x05email\x18\x03\x20\x01(\tH\x01R\x05email\x12\x1c\n\
|
||||||
\x08password\x18\x04\x20\x01(\tH\x02R\x08passwordB\r\n\x0bone_of_nameB\
|
\x08password\x18\x04\x20\x01(\tH\x02R\x08passwordB\r\n\x0bone_of_nameB\
|
||||||
@ -1298,60 +1298,60 @@ static file_descriptor_proto_data: &'static [u8] = b"\
|
|||||||
\x05email\x12\x1c\n\x08password\x18\x04\x20\x01(\tH\x02R\x08passwordB\r\
|
\x05email\x12\x1c\n\x08password\x18\x04\x20\x01(\tH\x02R\x08passwordB\r\
|
||||||
\n\x0bone_of_nameB\x0e\n\x0cone_of_emailB\x11\n\x0fone_of_password*1\n\n\
|
\n\x0bone_of_nameB\x0e\n\x0cone_of_emailB\x11\n\x0fone_of_password*1\n\n\
|
||||||
UserStatus\x12\x0b\n\x07Unknown\x10\0\x12\t\n\x05Login\x10\x01\x12\x0b\n\
|
UserStatus\x12\x0b\n\x07Unknown\x10\0\x12\t\n\x05Login\x10\x01\x12\x0b\n\
|
||||||
\x07Expired\x10\x02J\xbb\x08\n\x06\x12\x04\0\0\x1a\x01\n\x08\n\x01\x0c\
|
\x07Expired\x10\x02J\xbb\x08\n\x06\x12\x04\0\0\x19\x01\n\x08\n\x01\x0c\
|
||||||
\x12\x03\0\0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x04\x01\n\n\n\x03\x04\0\
|
\x12\x03\0\0\x12\n\n\n\x02\x04\0\x12\x04\x01\0\x03\x01\n\n\n\x03\x04\0\
|
||||||
\x01\x12\x03\x02\x08\x11\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x15\n\
|
\x01\x12\x03\x01\x08\x11\n\x0b\n\x04\x04\0\x02\0\x12\x03\x02\x04\x15\n\
|
||||||
\x0c\n\x05\x04\0\x02\0\x05\x12\x03\x03\x04\n\n\x0c\n\x05\x04\0\x02\0\x01\
|
\x0c\n\x05\x04\0\x02\0\x05\x12\x03\x02\x04\n\n\x0c\n\x05\x04\0\x02\0\x01\
|
||||||
\x12\x03\x03\x0b\x10\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x13\x14\n\n\
|
\x12\x03\x02\x0b\x10\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x02\x13\x14\n\n\
|
||||||
\n\x02\x04\x01\x12\x04\x05\0\t\x01\n\n\n\x03\x04\x01\x01\x12\x03\x05\x08\
|
\n\x02\x04\x01\x12\x04\x04\0\x08\x01\n\n\n\x03\x04\x01\x01\x12\x03\x04\
|
||||||
\x12\n\x0b\n\x04\x04\x01\x02\0\x12\x03\x06\x04\x12\n\x0c\n\x05\x04\x01\
|
\x08\x13\n\x0b\n\x04\x04\x01\x02\0\x12\x03\x05\x04\x12\n\x0c\n\x05\x04\
|
||||||
\x02\0\x05\x12\x03\x06\x04\n\n\x0c\n\x05\x04\x01\x02\0\x01\x12\x03\x06\
|
\x01\x02\0\x05\x12\x03\x05\x04\n\n\x0c\n\x05\x04\x01\x02\0\x01\x12\x03\
|
||||||
\x0b\r\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03\x06\x10\x11\n\x0b\n\x04\x04\
|
\x05\x0b\r\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03\x05\x10\x11\n\x0b\n\x04\
|
||||||
\x01\x02\x01\x12\x03\x07\x04\x15\n\x0c\n\x05\x04\x01\x02\x01\x05\x12\x03\
|
\x04\x01\x02\x01\x12\x03\x06\x04\x15\n\x0c\n\x05\x04\x01\x02\x01\x05\x12\
|
||||||
\x07\x04\n\n\x0c\n\x05\x04\x01\x02\x01\x01\x12\x03\x07\x0b\x10\n\x0c\n\
|
\x03\x06\x04\n\n\x0c\n\x05\x04\x01\x02\x01\x01\x12\x03\x06\x0b\x10\n\x0c\
|
||||||
\x05\x04\x01\x02\x01\x03\x12\x03\x07\x13\x14\n\x0b\n\x04\x04\x01\x02\x02\
|
\n\x05\x04\x01\x02\x01\x03\x12\x03\x06\x13\x14\n\x0b\n\x04\x04\x01\x02\
|
||||||
\x12\x03\x08\x04\x14\n\x0c\n\x05\x04\x01\x02\x02\x05\x12\x03\x08\x04\n\n\
|
\x02\x12\x03\x07\x04\x14\n\x0c\n\x05\x04\x01\x02\x02\x05\x12\x03\x07\x04\
|
||||||
\x0c\n\x05\x04\x01\x02\x02\x01\x12\x03\x08\x0b\x0f\n\x0c\n\x05\x04\x01\
|
\n\n\x0c\n\x05\x04\x01\x02\x02\x01\x12\x03\x07\x0b\x0f\n\x0c\n\x05\x04\
|
||||||
\x02\x02\x03\x12\x03\x08\x12\x13\n\n\n\x02\x04\x02\x12\x04\n\0\x0f\x01\n\
|
\x01\x02\x02\x03\x12\x03\x07\x12\x13\n\n\n\x02\x04\x02\x12\x04\t\0\x0e\
|
||||||
\n\n\x03\x04\x02\x01\x12\x03\n\x08\x19\n\x0b\n\x04\x04\x02\x02\0\x12\x03\
|
\x01\n\n\n\x03\x04\x02\x01\x12\x03\t\x08\x19\n\x0b\n\x04\x04\x02\x02\0\
|
||||||
\x0b\x04\x12\n\x0c\n\x05\x04\x02\x02\0\x05\x12\x03\x0b\x04\n\n\x0c\n\x05\
|
\x12\x03\n\x04\x12\n\x0c\n\x05\x04\x02\x02\0\x05\x12\x03\n\x04\n\n\x0c\n\
|
||||||
\x04\x02\x02\0\x01\x12\x03\x0b\x0b\r\n\x0c\n\x05\x04\x02\x02\0\x03\x12\
|
\x05\x04\x02\x02\0\x01\x12\x03\n\x0b\r\n\x0c\n\x05\x04\x02\x02\0\x03\x12\
|
||||||
\x03\x0b\x10\x11\n\x0b\n\x04\x04\x02\x08\0\x12\x03\x0c\x04*\n\x0c\n\x05\
|
\x03\n\x10\x11\n\x0b\n\x04\x04\x02\x08\0\x12\x03\x0b\x04*\n\x0c\n\x05\
|
||||||
\x04\x02\x08\0\x01\x12\x03\x0c\n\x15\n\x0b\n\x04\x04\x02\x02\x01\x12\x03\
|
\x04\x02\x08\0\x01\x12\x03\x0b\n\x15\n\x0b\n\x04\x04\x02\x02\x01\x12\x03\
|
||||||
\x0c\x18(\n\x0c\n\x05\x04\x02\x02\x01\x05\x12\x03\x0c\x18\x1e\n\x0c\n\
|
\x0b\x18(\n\x0c\n\x05\x04\x02\x02\x01\x05\x12\x03\x0b\x18\x1e\n\x0c\n\
|
||||||
\x05\x04\x02\x02\x01\x01\x12\x03\x0c\x1f#\n\x0c\n\x05\x04\x02\x02\x01\
|
\x05\x04\x02\x02\x01\x01\x12\x03\x0b\x1f#\n\x0c\n\x05\x04\x02\x02\x01\
|
||||||
\x03\x12\x03\x0c&'\n\x0b\n\x04\x04\x02\x08\x01\x12\x03\r\x04,\n\x0c\n\
|
\x03\x12\x03\x0b&'\n\x0b\n\x04\x04\x02\x08\x01\x12\x03\x0c\x04,\n\x0c\n\
|
||||||
\x05\x04\x02\x08\x01\x01\x12\x03\r\n\x16\n\x0b\n\x04\x04\x02\x02\x02\x12\
|
\x05\x04\x02\x08\x01\x01\x12\x03\x0c\n\x16\n\x0b\n\x04\x04\x02\x02\x02\
|
||||||
\x03\r\x19*\n\x0c\n\x05\x04\x02\x02\x02\x05\x12\x03\r\x19\x1f\n\x0c\n\
|
\x12\x03\x0c\x19*\n\x0c\n\x05\x04\x02\x02\x02\x05\x12\x03\x0c\x19\x1f\n\
|
||||||
\x05\x04\x02\x02\x02\x01\x12\x03\r\x20%\n\x0c\n\x05\x04\x02\x02\x02\x03\
|
\x0c\n\x05\x04\x02\x02\x02\x01\x12\x03\x0c\x20%\n\x0c\n\x05\x04\x02\x02\
|
||||||
\x12\x03\r()\n\x0b\n\x04\x04\x02\x08\x02\x12\x03\x0e\x042\n\x0c\n\x05\
|
\x02\x03\x12\x03\x0c()\n\x0b\n\x04\x04\x02\x08\x02\x12\x03\r\x042\n\x0c\
|
||||||
\x04\x02\x08\x02\x01\x12\x03\x0e\n\x19\n\x0b\n\x04\x04\x02\x02\x03\x12\
|
\n\x05\x04\x02\x08\x02\x01\x12\x03\r\n\x19\n\x0b\n\x04\x04\x02\x02\x03\
|
||||||
\x03\x0e\x1c0\n\x0c\n\x05\x04\x02\x02\x03\x05\x12\x03\x0e\x1c\"\n\x0c\n\
|
\x12\x03\r\x1c0\n\x0c\n\x05\x04\x02\x02\x03\x05\x12\x03\r\x1c\"\n\x0c\n\
|
||||||
\x05\x04\x02\x02\x03\x01\x12\x03\x0e#+\n\x0c\n\x05\x04\x02\x02\x03\x03\
|
\x05\x04\x02\x02\x03\x01\x12\x03\r#+\n\x0c\n\x05\x04\x02\x02\x03\x03\x12\
|
||||||
\x12\x03\x0e./\n\n\n\x02\x04\x03\x12\x04\x10\0\x15\x01\n\n\n\x03\x04\x03\
|
\x03\r./\n\n\n\x02\x04\x03\x12\x04\x0f\0\x14\x01\n\n\n\x03\x04\x03\x01\
|
||||||
\x01\x12\x03\x10\x08\x18\n\x0b\n\x04\x04\x03\x02\0\x12\x03\x11\x04\x12\n\
|
\x12\x03\x0f\x08\x18\n\x0b\n\x04\x04\x03\x02\0\x12\x03\x10\x04\x12\n\x0c\
|
||||||
\x0c\n\x05\x04\x03\x02\0\x05\x12\x03\x11\x04\n\n\x0c\n\x05\x04\x03\x02\0\
|
\n\x05\x04\x03\x02\0\x05\x12\x03\x10\x04\n\n\x0c\n\x05\x04\x03\x02\0\x01\
|
||||||
\x01\x12\x03\x11\x0b\r\n\x0c\n\x05\x04\x03\x02\0\x03\x12\x03\x11\x10\x11\
|
\x12\x03\x10\x0b\r\n\x0c\n\x05\x04\x03\x02\0\x03\x12\x03\x10\x10\x11\n\
|
||||||
\n\x0b\n\x04\x04\x03\x08\0\x12\x03\x12\x04*\n\x0c\n\x05\x04\x03\x08\0\
|
\x0b\n\x04\x04\x03\x08\0\x12\x03\x11\x04*\n\x0c\n\x05\x04\x03\x08\0\x01\
|
||||||
\x01\x12\x03\x12\n\x15\n\x0b\n\x04\x04\x03\x02\x01\x12\x03\x12\x18(\n\
|
\x12\x03\x11\n\x15\n\x0b\n\x04\x04\x03\x02\x01\x12\x03\x11\x18(\n\x0c\n\
|
||||||
\x0c\n\x05\x04\x03\x02\x01\x05\x12\x03\x12\x18\x1e\n\x0c\n\x05\x04\x03\
|
\x05\x04\x03\x02\x01\x05\x12\x03\x11\x18\x1e\n\x0c\n\x05\x04\x03\x02\x01\
|
||||||
\x02\x01\x01\x12\x03\x12\x1f#\n\x0c\n\x05\x04\x03\x02\x01\x03\x12\x03\
|
\x01\x12\x03\x11\x1f#\n\x0c\n\x05\x04\x03\x02\x01\x03\x12\x03\x11&'\n\
|
||||||
\x12&'\n\x0b\n\x04\x04\x03\x08\x01\x12\x03\x13\x04,\n\x0c\n\x05\x04\x03\
|
\x0b\n\x04\x04\x03\x08\x01\x12\x03\x12\x04,\n\x0c\n\x05\x04\x03\x08\x01\
|
||||||
\x08\x01\x01\x12\x03\x13\n\x16\n\x0b\n\x04\x04\x03\x02\x02\x12\x03\x13\
|
\x01\x12\x03\x12\n\x16\n\x0b\n\x04\x04\x03\x02\x02\x12\x03\x12\x19*\n\
|
||||||
\x19*\n\x0c\n\x05\x04\x03\x02\x02\x05\x12\x03\x13\x19\x1f\n\x0c\n\x05\
|
\x0c\n\x05\x04\x03\x02\x02\x05\x12\x03\x12\x19\x1f\n\x0c\n\x05\x04\x03\
|
||||||
\x04\x03\x02\x02\x01\x12\x03\x13\x20%\n\x0c\n\x05\x04\x03\x02\x02\x03\
|
\x02\x02\x01\x12\x03\x12\x20%\n\x0c\n\x05\x04\x03\x02\x02\x03\x12\x03\
|
||||||
\x12\x03\x13()\n\x0b\n\x04\x04\x03\x08\x02\x12\x03\x14\x042\n\x0c\n\x05\
|
\x12()\n\x0b\n\x04\x04\x03\x08\x02\x12\x03\x13\x042\n\x0c\n\x05\x04\x03\
|
||||||
\x04\x03\x08\x02\x01\x12\x03\x14\n\x19\n\x0b\n\x04\x04\x03\x02\x03\x12\
|
\x08\x02\x01\x12\x03\x13\n\x19\n\x0b\n\x04\x04\x03\x02\x03\x12\x03\x13\
|
||||||
\x03\x14\x1c0\n\x0c\n\x05\x04\x03\x02\x03\x05\x12\x03\x14\x1c\"\n\x0c\n\
|
\x1c0\n\x0c\n\x05\x04\x03\x02\x03\x05\x12\x03\x13\x1c\"\n\x0c\n\x05\x04\
|
||||||
\x05\x04\x03\x02\x03\x01\x12\x03\x14#+\n\x0c\n\x05\x04\x03\x02\x03\x03\
|
\x03\x02\x03\x01\x12\x03\x13#+\n\x0c\n\x05\x04\x03\x02\x03\x03\x12\x03\
|
||||||
\x12\x03\x14./\n\n\n\x02\x05\0\x12\x04\x16\0\x1a\x01\n\n\n\x03\x05\0\x01\
|
\x13./\n\n\n\x02\x05\0\x12\x04\x15\0\x19\x01\n\n\n\x03\x05\0\x01\x12\x03\
|
||||||
\x12\x03\x16\x05\x0f\n\x0b\n\x04\x05\0\x02\0\x12\x03\x17\x04\x10\n\x0c\n\
|
\x15\x05\x0f\n\x0b\n\x04\x05\0\x02\0\x12\x03\x16\x04\x10\n\x0c\n\x05\x05\
|
||||||
\x05\x05\0\x02\0\x01\x12\x03\x17\x04\x0b\n\x0c\n\x05\x05\0\x02\0\x02\x12\
|
\0\x02\0\x01\x12\x03\x16\x04\x0b\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x16\
|
||||||
\x03\x17\x0e\x0f\n\x0b\n\x04\x05\0\x02\x01\x12\x03\x18\x04\x0e\n\x0c\n\
|
\x0e\x0f\n\x0b\n\x04\x05\0\x02\x01\x12\x03\x17\x04\x0e\n\x0c\n\x05\x05\0\
|
||||||
\x05\x05\0\x02\x01\x01\x12\x03\x18\x04\t\n\x0c\n\x05\x05\0\x02\x01\x02\
|
\x02\x01\x01\x12\x03\x17\x04\t\n\x0c\n\x05\x05\0\x02\x01\x02\x12\x03\x17\
|
||||||
\x12\x03\x18\x0c\r\n\x0b\n\x04\x05\0\x02\x02\x12\x03\x19\x04\x10\n\x0c\n\
|
\x0c\r\n\x0b\n\x04\x05\0\x02\x02\x12\x03\x18\x04\x10\n\x0c\n\x05\x05\0\
|
||||||
\x05\x05\0\x02\x02\x01\x12\x03\x19\x04\x0b\n\x0c\n\x05\x05\0\x02\x02\x02\
|
\x02\x02\x01\x12\x03\x18\x04\x0b\n\x0c\n\x05\x05\0\x02\x02\x02\x12\x03\
|
||||||
\x12\x03\x19\x0e\x0fb\x06proto3\
|
\x18\x0e\x0fb\x06proto3\
|
||||||
";
|
";
|
||||||
|
|
||||||
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
|
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
|
@ -1,9 +1,8 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
|
||||||
message UserToken {
|
message UserToken {
|
||||||
string token = 1;
|
string token = 1;
|
||||||
}
|
}
|
||||||
message UserDetail {
|
message UserProfile {
|
||||||
string id = 1;
|
string id = 1;
|
||||||
string email = 2;
|
string email = 2;
|
||||||
string name = 3;
|
string name = 3;
|
@ -6,7 +6,7 @@ pub use server_api_mock::*;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
pub(crate) type Server = Arc<dyn UserServerAPI + Send + Sync>;
|
pub(crate) type Server = Arc<dyn UserServerAPI + Send + Sync>;
|
||||||
use crate::{
|
use crate::{
|
||||||
entities::{SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserParams, UserDetail},
|
entities::{SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserParams, UserProfile},
|
||||||
errors::UserError,
|
errors::UserError,
|
||||||
};
|
};
|
||||||
use flowy_infra::future::ResultFuture;
|
use flowy_infra::future::ResultFuture;
|
||||||
@ -16,7 +16,7 @@ pub trait UserServerAPI {
|
|||||||
fn sign_in(&self, params: SignInParams) -> ResultFuture<SignInResponse, UserError>;
|
fn sign_in(&self, params: SignInParams) -> ResultFuture<SignInResponse, UserError>;
|
||||||
fn sign_out(&self, token: &str) -> ResultFuture<(), UserError>;
|
fn sign_out(&self, token: &str) -> ResultFuture<(), UserError>;
|
||||||
fn update_user(&self, token: &str, params: UpdateUserParams) -> ResultFuture<(), UserError>;
|
fn update_user(&self, token: &str, params: UpdateUserParams) -> ResultFuture<(), UserError>;
|
||||||
fn get_user_detail(&self, token: &str) -> ResultFuture<UserDetail, UserError>;
|
fn get_user(&self, token: &str) -> ResultFuture<UserProfile, UserError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn construct_user_server() -> Arc<dyn UserServerAPI + Send + Sync> {
|
pub(crate) fn construct_user_server() -> Arc<dyn UserServerAPI + Send + Sync> {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
entities::{SignInParams, SignInResponse, SignUpParams, SignUpResponse, UserDetail},
|
entities::{SignInParams, SignInResponse, SignUpParams, SignUpResponse, UserProfile},
|
||||||
errors::UserError,
|
errors::UserError,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -31,12 +31,12 @@ impl UserServerAPI for UserServer {
|
|||||||
|
|
||||||
fn update_user(&self, token: &str, params: UpdateUserParams) -> ResultFuture<(), UserError> {
|
fn update_user(&self, token: &str, params: UpdateUserParams) -> ResultFuture<(), UserError> {
|
||||||
let token = token.to_owned();
|
let token = token.to_owned();
|
||||||
ResultFuture::new(async move { update_user_detail_request(&token, params, USER_PROFILE_URL.as_ref()).await })
|
ResultFuture::new(async move { update_user_profile_request(&token, params, USER_PROFILE_URL.as_ref()).await })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_user_detail(&self, token: &str) -> ResultFuture<UserDetail, UserError> {
|
fn get_user(&self, token: &str) -> ResultFuture<UserProfile, UserError> {
|
||||||
let token = token.to_owned();
|
let token = token.to_owned();
|
||||||
ResultFuture::new(async move { get_user_detail_request(&token, USER_PROFILE_URL.as_ref()).await })
|
ResultFuture::new(async move { get_user_profile_request(&token, USER_PROFILE_URL.as_ref()).await })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,17 +68,17 @@ pub async fn user_sign_out_request(token: &str, url: &str) -> Result<(), UserErr
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_user_detail_request(token: &str, url: &str) -> Result<UserDetail, UserError> {
|
pub async fn get_user_profile_request(token: &str, url: &str) -> Result<UserProfile, UserError> {
|
||||||
let user_detail = HttpRequestBuilder::get(&url.to_owned())
|
let user_profile = HttpRequestBuilder::get(&url.to_owned())
|
||||||
.header(HEADER_TOKEN, token)
|
.header(HEADER_TOKEN, token)
|
||||||
.send()
|
.send()
|
||||||
.await?
|
.await?
|
||||||
.response()
|
.response()
|
||||||
.await?;
|
.await?;
|
||||||
Ok(user_detail)
|
Ok(user_profile)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_user_detail_request(token: &str, params: UpdateUserParams, url: &str) -> Result<(), UserError> {
|
pub async fn update_user_profile_request(token: &str, params: UpdateUserParams, url: &str) -> Result<(), UserError> {
|
||||||
let _ = HttpRequestBuilder::patch(&url.to_owned())
|
let _ = HttpRequestBuilder::patch(&url.to_owned())
|
||||||
.header(HEADER_TOKEN, token)
|
.header(HEADER_TOKEN, token)
|
||||||
.protobuf(params)?
|
.protobuf(params)?
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
entities::{SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserParams, UserDetail},
|
entities::{SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserParams, UserProfile},
|
||||||
errors::{ErrorBuilder, ErrorCode, UserError},
|
errors::{ErrorBuilder, ErrorCode, UserError},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ impl UserServerAPI for UserServerMock {
|
|||||||
|
|
||||||
fn update_user(&self, _token: &str, _params: UpdateUserParams) -> ResultFuture<(), UserError> { ResultFuture::new(async { Ok(()) }) }
|
fn update_user(&self, _token: &str, _params: UpdateUserParams) -> ResultFuture<(), UserError> { ResultFuture::new(async { Ok(()) }) }
|
||||||
|
|
||||||
fn get_user_detail(&self, _token: &str) -> ResultFuture<UserDetail, UserError> {
|
fn get_user(&self, _token: &str) -> ResultFuture<UserProfile, UserError> {
|
||||||
ResultFuture::new(async { Err(ErrorBuilder::new(ErrorCode::Unknown).msg("mock data, ignore this error").build()) })
|
ResultFuture::new(async { Err(ErrorBuilder::new(ErrorCode::Unknown).msg("mock data, ignore this error").build()) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
entities::{SignInParams, SignUpParams, UpdateUserParams, UserDetail},
|
entities::{SignInParams, SignUpParams, UpdateUserParams, UserProfile},
|
||||||
errors::{ErrorBuilder, ErrorCode, UserError},
|
errors::{ErrorBuilder, ErrorCode, UserError},
|
||||||
services::user::{construct_user_server, database::UserDB},
|
services::user::{construct_user_server, database::UserDB},
|
||||||
sql_tables::{UserTable, UserTableChangeset},
|
sql_tables::{UserTable, UserTableChangeset},
|
||||||
@ -69,29 +69,29 @@ impl UserSession {
|
|||||||
self.database.get_pool(&user_id)
|
self.database.get_pool(&user_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn sign_in(&self, params: SignInParams) -> Result<UserDetail, UserError> {
|
pub async fn sign_in(&self, params: SignInParams) -> Result<UserProfile, UserError> {
|
||||||
if self.is_login(¶ms.email) {
|
if self.is_login(¶ms.email) {
|
||||||
self.user_detail().await
|
self.user_profile().await
|
||||||
} else {
|
} else {
|
||||||
let resp = self.server.sign_in(params).await?;
|
let resp = self.server.sign_in(params).await?;
|
||||||
let session = Session::new(&resp.uid, &resp.token, &resp.email);
|
let session = Session::new(&resp.uid, &resp.token, &resp.email);
|
||||||
let _ = self.set_session(Some(session))?;
|
let _ = self.set_session(Some(session))?;
|
||||||
let user_table = self.save_user(resp.into()).await?;
|
let user_table = self.save_user(resp.into()).await?;
|
||||||
let user_detail = UserDetail::from(user_table);
|
let user_profile = UserProfile::from(user_table);
|
||||||
Ok(user_detail)
|
Ok(user_profile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn sign_up(&self, params: SignUpParams) -> Result<UserDetail, UserError> {
|
pub async fn sign_up(&self, params: SignUpParams) -> Result<UserProfile, UserError> {
|
||||||
if self.is_login(¶ms.email) {
|
if self.is_login(¶ms.email) {
|
||||||
self.user_detail().await
|
self.user_profile().await
|
||||||
} else {
|
} else {
|
||||||
let resp = self.server.sign_up(params).await?;
|
let resp = self.server.sign_up(params).await?;
|
||||||
let session = Session::new(&resp.user_id, &resp.token, &resp.email);
|
let session = Session::new(&resp.user_id, &resp.token, &resp.email);
|
||||||
let _ = self.set_session(Some(session))?;
|
let _ = self.set_session(Some(session))?;
|
||||||
let user_table = self.save_user(resp.into()).await?;
|
let user_table = self.save_user(resp.into()).await?;
|
||||||
let user_detail = UserDetail::from(user_table);
|
let user_profile = UserProfile::from(user_table);
|
||||||
Ok(user_detail)
|
Ok(user_profile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,15 +127,15 @@ impl UserSession {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn user_detail(&self) -> Result<UserDetail, UserError> {
|
pub async fn user_profile(&self) -> Result<UserProfile, UserError> {
|
||||||
let session = self.get_session()?;
|
let session = self.get_session()?;
|
||||||
let token = session.token;
|
let token = session.token;
|
||||||
let server = self.server.clone();
|
let server = self.server.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
match server.get_user_detail(&token).await {
|
match server.get_user(&token).await {
|
||||||
Ok(user_detail) => {
|
Ok(profile) => {
|
||||||
//
|
//
|
||||||
log::info!("{:?}", user_detail);
|
log::info!("{:?}", profile);
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
//
|
//
|
||||||
@ -149,7 +149,7 @@ impl UserSession {
|
|||||||
.filter(user_table::id.eq(&session.user_id))
|
.filter(user_table::id.eq(&session.user_id))
|
||||||
.first::<UserTable>(&*(self.get_db_connection()?))?;
|
.first::<UserTable>(&*(self.get_db_connection()?))?;
|
||||||
|
|
||||||
Ok(UserDetail::from(user))
|
Ok(UserProfile::from(user))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn user_dir(&self) -> Result<String, UserError> {
|
pub fn user_dir(&self) -> Result<String, UserError> {
|
||||||
|
@ -50,7 +50,7 @@ fn sign_in_success() {
|
|||||||
.event(SignIn)
|
.event(SignIn)
|
||||||
.request(request)
|
.request(request)
|
||||||
.sync_send()
|
.sync_send()
|
||||||
.parse::<UserDetail>();
|
.parse::<UserProfile>();
|
||||||
dbg!(&response);
|
dbg!(&response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ use serial_test::*;
|
|||||||
fn user_profile_get_failed() {
|
fn user_profile_get_failed() {
|
||||||
let sdk = init_test_sdk();
|
let sdk = init_test_sdk();
|
||||||
let result = UserTest::new(sdk).event(GetUserProfile).assert_error().sync_send();
|
let result = UserTest::new(sdk).event(GetUserProfile).assert_error().sync_send();
|
||||||
assert!(result.user_detail().is_none())
|
assert!(result.user_profile().is_none())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -19,7 +19,7 @@ fn user_profile_get() {
|
|||||||
let user = UserTest::new(env.sdk.clone())
|
let user = UserTest::new(env.sdk.clone())
|
||||||
.event(GetUserProfile)
|
.event(GetUserProfile)
|
||||||
.sync_send()
|
.sync_send()
|
||||||
.parse::<UserDetail>();
|
.parse::<UserProfile>();
|
||||||
assert_eq!(env.user, user);
|
assert_eq!(env.user, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,13 +31,13 @@ fn user_update_with_name() {
|
|||||||
let request = UpdateUserRequest::new(&env.user.id).name(&new_name);
|
let request = UpdateUserRequest::new(&env.user.id).name(&new_name);
|
||||||
let _ = UserTest::new(env.sdk()).event(UpdateUser).request(request).sync_send();
|
let _ = UserTest::new(env.sdk()).event(UpdateUser).request(request).sync_send();
|
||||||
|
|
||||||
let user_detail = UserTest::new(env.sdk())
|
let user_profile = UserTest::new(env.sdk())
|
||||||
.event(GetUserProfile)
|
.event(GetUserProfile)
|
||||||
.assert_error()
|
.assert_error()
|
||||||
.sync_send()
|
.sync_send()
|
||||||
.parse::<UserDetail>();
|
.parse::<UserProfile>();
|
||||||
|
|
||||||
assert_eq!(user_detail.name, new_name,);
|
assert_eq!(user_profile.name, new_name,);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -47,13 +47,13 @@ fn user_update_with_email() {
|
|||||||
let new_email = format!("{}@gmai.com", uuid());
|
let new_email = format!("{}@gmai.com", uuid());
|
||||||
let request = UpdateUserRequest::new(&env.user.id).email(&new_email);
|
let request = UpdateUserRequest::new(&env.user.id).email(&new_email);
|
||||||
let _ = UserTest::new(env.sdk()).event(UpdateUser).request(request).sync_send();
|
let _ = UserTest::new(env.sdk()).event(UpdateUser).request(request).sync_send();
|
||||||
let user_detail = UserTest::new(env.sdk())
|
let user_profile = UserTest::new(env.sdk())
|
||||||
.event(GetUserProfile)
|
.event(GetUserProfile)
|
||||||
.assert_error()
|
.assert_error()
|
||||||
.sync_send()
|
.sync_send()
|
||||||
.parse::<UserDetail>();
|
.parse::<UserProfile>();
|
||||||
|
|
||||||
assert_eq!(user_detail.email, new_email,);
|
assert_eq!(user_profile.email, new_email,);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user