config doc bloc

This commit is contained in:
appflowy 2021-07-24 18:55:13 +08:00
parent 0ec02c1ac0
commit b0df64138f
33 changed files with 676 additions and 133 deletions

View File

@ -38,8 +38,9 @@ class RustSDKInitTask extends LaunchTask {
class ApplicationBlocObserver extends BlocObserver {
@override
// ignore: unnecessary_overrides
void onTransition(Bloc bloc, Transition transition) {
Log.debug(transition);
// Log.debug(transition);
super.onTransition(bloc, transition);
}

View File

@ -1,8 +1,8 @@
import 'package:app_flowy/workspace/application/edit_pannel/edit_pannel_bloc.dart';
import 'package:app_flowy/workspace/application/home_bloc.dart';
import 'package:app_flowy/workspace/application/watcher/home_watcher_bloc.dart';
import 'package:app_flowy/welcome/application/welcome_bloc.dart';
import 'package:app_flowy/welcome/infrastructure/i_welcome_impl.dart';
import 'package:app_flowy/workspace/application/home/home_bloc.dart';
import 'package:app_flowy/workspace/application/home/home_watcher_bloc.dart';
import 'package:get_it/get_it.dart';
class WelcomeDepsResolver {

View File

@ -0,0 +1,39 @@
import 'package:app_flowy/workspace/domain/i_doc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:dartz/dartz.dart';
part 'doc_bloc.freezed.dart';
class DocBloc extends Bloc<DocEvent, DocState> {
final IDoc iDocImpl;
DocBloc(this.iDocImpl) : super(DocState.initial());
@override
Stream<DocState> mapEventToState(DocEvent event) async* {
yield* event.map(
initial: (e) async* {},
save: (Save value) async* {},
close: (Close value) async* {},
);
}
}
@freezed
abstract class DocEvent with _$DocEvent {
const factory DocEvent.initial() = Initial;
const factory DocEvent.save(String jsonStr) = Save;
const factory DocEvent.close() = Close;
}
@freezed
abstract class DocState implements _$DocState {
const factory DocState({
required bool isSaving,
}) = _DocState;
factory DocState.initial() => const DocState(
isSaving: false,
);
}

View File

@ -0,0 +1,498 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides
part of 'doc_bloc.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
class _$DocEventTearOff {
const _$DocEventTearOff();
Initial initial() {
return const Initial();
}
Save save(String jsonStr) {
return Save(
jsonStr,
);
}
Close close() {
return const Close();
}
}
/// @nodoc
const $DocEvent = _$DocEventTearOff();
/// @nodoc
mixin _$DocEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() initial,
required TResult Function(String jsonStr) save,
required TResult Function() close,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? initial,
TResult Function(String jsonStr)? save,
TResult Function()? close,
required TResult orElse(),
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(Initial value) initial,
required TResult Function(Save value) save,
required TResult Function(Close value) close,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(Initial value)? initial,
TResult Function(Save value)? save,
TResult Function(Close value)? close,
required TResult orElse(),
}) =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $DocEventCopyWith<$Res> {
factory $DocEventCopyWith(DocEvent value, $Res Function(DocEvent) then) =
_$DocEventCopyWithImpl<$Res>;
}
/// @nodoc
class _$DocEventCopyWithImpl<$Res> implements $DocEventCopyWith<$Res> {
_$DocEventCopyWithImpl(this._value, this._then);
final DocEvent _value;
// ignore: unused_field
final $Res Function(DocEvent) _then;
}
/// @nodoc
abstract class $InitialCopyWith<$Res> {
factory $InitialCopyWith(Initial value, $Res Function(Initial) then) =
_$InitialCopyWithImpl<$Res>;
}
/// @nodoc
class _$InitialCopyWithImpl<$Res> extends _$DocEventCopyWithImpl<$Res>
implements $InitialCopyWith<$Res> {
_$InitialCopyWithImpl(Initial _value, $Res Function(Initial) _then)
: super(_value, (v) => _then(v as Initial));
@override
Initial get _value => super._value as Initial;
}
/// @nodoc
class _$Initial implements Initial {
const _$Initial();
@override
String toString() {
return 'DocEvent.initial()';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) || (other is Initial);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() initial,
required TResult Function(String jsonStr) save,
required TResult Function() close,
}) {
return initial();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? initial,
TResult Function(String jsonStr)? save,
TResult Function()? close,
required TResult orElse(),
}) {
if (initial != null) {
return initial();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(Initial value) initial,
required TResult Function(Save value) save,
required TResult Function(Close value) close,
}) {
return initial(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(Initial value)? initial,
TResult Function(Save value)? save,
TResult Function(Close value)? close,
required TResult orElse(),
}) {
if (initial != null) {
return initial(this);
}
return orElse();
}
}
abstract class Initial implements DocEvent {
const factory Initial() = _$Initial;
}
/// @nodoc
abstract class $SaveCopyWith<$Res> {
factory $SaveCopyWith(Save value, $Res Function(Save) then) =
_$SaveCopyWithImpl<$Res>;
$Res call({String jsonStr});
}
/// @nodoc
class _$SaveCopyWithImpl<$Res> extends _$DocEventCopyWithImpl<$Res>
implements $SaveCopyWith<$Res> {
_$SaveCopyWithImpl(Save _value, $Res Function(Save) _then)
: super(_value, (v) => _then(v as Save));
@override
Save get _value => super._value as Save;
@override
$Res call({
Object? jsonStr = freezed,
}) {
return _then(Save(
jsonStr == freezed
? _value.jsonStr
: jsonStr // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
class _$Save implements Save {
const _$Save(this.jsonStr);
@override
final String jsonStr;
@override
String toString() {
return 'DocEvent.save(jsonStr: $jsonStr)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is Save &&
(identical(other.jsonStr, jsonStr) ||
const DeepCollectionEquality().equals(other.jsonStr, jsonStr)));
}
@override
int get hashCode =>
runtimeType.hashCode ^ const DeepCollectionEquality().hash(jsonStr);
@JsonKey(ignore: true)
@override
$SaveCopyWith<Save> get copyWith =>
_$SaveCopyWithImpl<Save>(this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() initial,
required TResult Function(String jsonStr) save,
required TResult Function() close,
}) {
return save(jsonStr);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? initial,
TResult Function(String jsonStr)? save,
TResult Function()? close,
required TResult orElse(),
}) {
if (save != null) {
return save(jsonStr);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(Initial value) initial,
required TResult Function(Save value) save,
required TResult Function(Close value) close,
}) {
return save(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(Initial value)? initial,
TResult Function(Save value)? save,
TResult Function(Close value)? close,
required TResult orElse(),
}) {
if (save != null) {
return save(this);
}
return orElse();
}
}
abstract class Save implements DocEvent {
const factory Save(String jsonStr) = _$Save;
String get jsonStr => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$SaveCopyWith<Save> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $CloseCopyWith<$Res> {
factory $CloseCopyWith(Close value, $Res Function(Close) then) =
_$CloseCopyWithImpl<$Res>;
}
/// @nodoc
class _$CloseCopyWithImpl<$Res> extends _$DocEventCopyWithImpl<$Res>
implements $CloseCopyWith<$Res> {
_$CloseCopyWithImpl(Close _value, $Res Function(Close) _then)
: super(_value, (v) => _then(v as Close));
@override
Close get _value => super._value as Close;
}
/// @nodoc
class _$Close implements Close {
const _$Close();
@override
String toString() {
return 'DocEvent.close()';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) || (other is Close);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() initial,
required TResult Function(String jsonStr) save,
required TResult Function() close,
}) {
return close();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? initial,
TResult Function(String jsonStr)? save,
TResult Function()? close,
required TResult orElse(),
}) {
if (close != null) {
return close();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(Initial value) initial,
required TResult Function(Save value) save,
required TResult Function(Close value) close,
}) {
return close(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(Initial value)? initial,
TResult Function(Save value)? save,
TResult Function(Close value)? close,
required TResult orElse(),
}) {
if (close != null) {
return close(this);
}
return orElse();
}
}
abstract class Close implements DocEvent {
const factory Close() = _$Close;
}
/// @nodoc
class _$DocStateTearOff {
const _$DocStateTearOff();
_DocState call({required bool isSaving}) {
return _DocState(
isSaving: isSaving,
);
}
}
/// @nodoc
const $DocState = _$DocStateTearOff();
/// @nodoc
mixin _$DocState {
bool get isSaving => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$DocStateCopyWith<DocState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $DocStateCopyWith<$Res> {
factory $DocStateCopyWith(DocState value, $Res Function(DocState) then) =
_$DocStateCopyWithImpl<$Res>;
$Res call({bool isSaving});
}
/// @nodoc
class _$DocStateCopyWithImpl<$Res> implements $DocStateCopyWith<$Res> {
_$DocStateCopyWithImpl(this._value, this._then);
final DocState _value;
// ignore: unused_field
final $Res Function(DocState) _then;
@override
$Res call({
Object? isSaving = freezed,
}) {
return _then(_value.copyWith(
isSaving: isSaving == freezed
? _value.isSaving
: isSaving // ignore: cast_nullable_to_non_nullable
as bool,
));
}
}
/// @nodoc
abstract class _$DocStateCopyWith<$Res> implements $DocStateCopyWith<$Res> {
factory _$DocStateCopyWith(_DocState value, $Res Function(_DocState) then) =
__$DocStateCopyWithImpl<$Res>;
@override
$Res call({bool isSaving});
}
/// @nodoc
class __$DocStateCopyWithImpl<$Res> extends _$DocStateCopyWithImpl<$Res>
implements _$DocStateCopyWith<$Res> {
__$DocStateCopyWithImpl(_DocState _value, $Res Function(_DocState) _then)
: super(_value, (v) => _then(v as _DocState));
@override
_DocState get _value => super._value as _DocState;
@override
$Res call({
Object? isSaving = freezed,
}) {
return _then(_DocState(
isSaving: isSaving == freezed
? _value.isSaving
: isSaving // ignore: cast_nullable_to_non_nullable
as bool,
));
}
}
/// @nodoc
class _$_DocState implements _DocState {
const _$_DocState({required this.isSaving});
@override
final bool isSaving;
@override
String toString() {
return 'DocState(isSaving: $isSaving)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other is _DocState &&
(identical(other.isSaving, isSaving) ||
const DeepCollectionEquality()
.equals(other.isSaving, isSaving)));
}
@override
int get hashCode =>
runtimeType.hashCode ^ const DeepCollectionEquality().hash(isSaving);
@JsonKey(ignore: true)
@override
_$DocStateCopyWith<_DocState> get copyWith =>
__$DocStateCopyWithImpl<_DocState>(this, _$identity);
}
abstract class _DocState implements DocState {
const factory _DocState({required bool isSaving}) = _$_DocState;
@override
bool get isSaving => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$DocStateCopyWith<_DocState> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,10 +1,7 @@
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
// ignore: import_of_legacy_library_into_null_safe
import 'package:flutter_bloc/flutter_bloc.dart';
part 'home_watcher_event.dart';
part 'home_watcher_state.dart';
part 'home_watcher_bloc.freezed.dart';
class HomeWatcherBloc extends Bloc<HomeWatcherEvent, HomeWatcherState> {
@ -17,3 +14,15 @@ class HomeWatcherBloc extends Bloc<HomeWatcherEvent, HomeWatcherState> {
yield state;
}
}
@freezed
abstract class HomeWatcherEvent with _$HomeWatcherEvent {
const factory HomeWatcherEvent.started(String workspaceId) = _Started;
const factory HomeWatcherEvent.stop(String workspaceId) = _Stop;
}
@freezed
abstract class HomeWatcherState with _$HomeWatcherState {
const factory HomeWatcherState.initial() = _Initial;
const factory HomeWatcherState.loading() = _Loading;
}

View File

@ -1,7 +0,0 @@
part of 'home_watcher_bloc.dart';
@freezed
abstract class HomeWatcherEvent with _$HomeWatcherEvent {
const factory HomeWatcherEvent.started(String workspaceId) = _Started;
const factory HomeWatcherEvent.stop(String workspaceId) = _Stop;
}

View File

@ -1,7 +0,0 @@
part of 'home_watcher_bloc.dart';
@freezed
abstract class HomeWatcherState with _$HomeWatcherState {
const factory HomeWatcherState.initial() = _Initial;
const factory HomeWatcherState.loading() = _Loading;
}

View File

@ -1,5 +1,6 @@
import 'package:app_flowy/workspace/application/app/app_bloc.dart';
import 'package:app_flowy/workspace/application/app/app_watch_bloc.dart';
import 'package:app_flowy/workspace/application/doc/doc_bloc.dart';
import 'package:app_flowy/workspace/application/menu/menu_bloc.dart';
import 'package:app_flowy/workspace/application/menu/menu_watch.dart';
import 'package:app_flowy/workspace/application/view/doc_watch_bloc.dart';
@ -62,6 +63,9 @@ class HomeDepsResolver {
getIt.registerFactoryParam<DocWatchBloc, String, void>(
(docId, _) => DocWatchBloc(iDocImpl: getIt<IDoc>(param1: docId)));
getIt.registerFactoryParam<DocBloc, String, void>(
(docId, _) => DocBloc(getIt<IDoc>(param1: docId)));
// getIt.registerFactoryParam<ViewBloc, String, void>(
// (viewId, _) => ViewBloc(iViewImpl: getIt<IView>(param1: viewId)));
}

View File

@ -30,7 +30,8 @@ class IDocImpl extends IDoc {
@override
Future<Either<Unit, EditorError>> updateDoc(
{String? name, String? desc, String? text}) {
return repo.updateDoc(name: name, desc: desc, text: text);
final json = jsonEncode(text ?? "");
return repo.updateDoc(name: name, desc: desc, text: json);
}
Future<Either<Document, EditorError>> _loadDocument(String path) {

View File

@ -1,28 +1,35 @@
import 'dart:io';
import 'package:app_flowy/startup/startup.dart';
import 'package:app_flowy/workspace/application/doc/doc_bloc.dart';
import 'package:app_flowy/workspace/domain/i_doc.dart';
import 'package:flowy_editor/flowy_editor.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class EditorWdiget extends StatelessWidget {
final FocusNode _focusNode = FocusNode();
late EditorController controller;
final Doc doc;
EditorWdiget({Key? key, required this.doc}) : super(key: key);
@override
Widget build(BuildContext context) {
final controller = EditorController(
EditorWdiget({Key? key, required this.doc}) : super(key: key) {
controller = EditorController(
document: doc.data,
selection: const TextSelection.collapsed(offset: 0),
);
}
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_renderEditor(controller),
_renderToolbar(controller),
],
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => getIt<DocBloc>(param1: doc.info.id),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_renderEditor(controller),
_renderToolbar(controller),
],
),
);
}
@ -51,4 +58,8 @@ class EditorWdiget extends StatelessWidget {
Future<String> _onImageSelection(File file) {
throw UnimplementedError();
}
void save() {
final deltaJson = controller.document.toDelta().toJson();
}
}

View File

@ -1,4 +1,4 @@
import 'package:app_flowy/workspace/application/home_bloc.dart';
import 'package:app_flowy/workspace/application/home/home_bloc.dart';
import 'package:flowy_infra/size.dart';
import 'package:flowy_infra/time/duration.dart';
import 'package:flutter/material.dart';

View File

@ -1,5 +1,5 @@
import 'package:app_flowy/workspace/application/home_bloc.dart';
import 'package:app_flowy/workspace/application/watcher/home_watcher_bloc.dart';
import 'package:app_flowy/workspace/application/home/home_bloc.dart';
import 'package:app_flowy/workspace/application/home/home_watcher_bloc.dart';
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
import 'package:app_flowy/workspace/presentation/widgets/prelude.dart';
import 'package:app_flowy/startup/startup.dart';

View File

@ -11,12 +11,7 @@ class ViewWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return InkWell(
onTap: _openView(context),
child: Container(
height: 30,
child: buildContent(),
));
return InkWell(onTap: _openView(context), child: buildContent());
}
Row buildContent() {

View File

@ -16,6 +16,7 @@ class UserErrorCode extends $pb.ProtobufEnum {
static const UserErrorCode UserDatabaseReadLocked = UserErrorCode._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserDatabaseReadLocked');
static const UserErrorCode UserDatabaseDidNotMatch = UserErrorCode._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserDatabaseDidNotMatch');
static const UserErrorCode UserDatabaseInternalError = UserErrorCode._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserDatabaseInternalError');
static const UserErrorCode SqlInternalError = UserErrorCode._(6, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SqlInternalError');
static const UserErrorCode UserNotLoginYet = UserErrorCode._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserNotLoginYet');
static const UserErrorCode ReadCurrentIdFailed = UserErrorCode._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ReadCurrentIdFailed');
static const UserErrorCode WriteCurrentIdFailed = UserErrorCode._(12, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WriteCurrentIdFailed');
@ -34,6 +35,7 @@ class UserErrorCode extends $pb.ProtobufEnum {
UserDatabaseReadLocked,
UserDatabaseDidNotMatch,
UserDatabaseInternalError,
SqlInternalError,
UserNotLoginYet,
ReadCurrentIdFailed,
WriteCurrentIdFailed,

View File

@ -18,6 +18,7 @@ const UserErrorCode$json = const {
const {'1': 'UserDatabaseReadLocked', '2': 3},
const {'1': 'UserDatabaseDidNotMatch', '2': 4},
const {'1': 'UserDatabaseInternalError', '2': 5},
const {'1': 'SqlInternalError', '2': 6},
const {'1': 'UserNotLoginYet', '2': 10},
const {'1': 'ReadCurrentIdFailed', '2': 11},
const {'1': 'WriteCurrentIdFailed', '2': 12},
@ -32,7 +33,7 @@ const UserErrorCode$json = const {
};
/// Descriptor for `UserErrorCode`. Decode as a `google.protobuf.EnumDescriptorProto`.
final $typed_data.Uint8List userErrorCodeDescriptor = $convert.base64Decode('Cg1Vc2VyRXJyb3JDb2RlEgsKB1Vua25vd24QABIaChZVc2VyRGF0YWJhc2VJbml0RmFpbGVkEAESGwoXVXNlckRhdGFiYXNlV3JpdGVMb2NrZWQQAhIaChZVc2VyRGF0YWJhc2VSZWFkTG9ja2VkEAMSGwoXVXNlckRhdGFiYXNlRGlkTm90TWF0Y2gQBBIdChlVc2VyRGF0YWJhc2VJbnRlcm5hbEVycm9yEAUSEwoPVXNlck5vdExvZ2luWWV0EAoSFwoTUmVhZEN1cnJlbnRJZEZhaWxlZBALEhgKFFdyaXRlQ3VycmVudElkRmFpbGVkEAwSEAoMRW1haWxJbnZhbGlkEBQSEwoPUGFzc3dvcmRJbnZhbGlkEBUSEwoPVXNlck5hbWVJbnZhbGlkEBYSGAoUVXNlcldvcmtzcGFjZUludmFsaWQQFxIRCg1Vc2VySWRJbnZhbGlkEBgSIAocQ3JlYXRlRGVmYXVsdFdvcmtzcGFjZUZhaWxlZBAZEiAKHERlZmF1bHRXb3Jrc3BhY2VBbHJlYWR5RXhpc3QQGg==');
final $typed_data.Uint8List userErrorCodeDescriptor = $convert.base64Decode('Cg1Vc2VyRXJyb3JDb2RlEgsKB1Vua25vd24QABIaChZVc2VyRGF0YWJhc2VJbml0RmFpbGVkEAESGwoXVXNlckRhdGFiYXNlV3JpdGVMb2NrZWQQAhIaChZVc2VyRGF0YWJhc2VSZWFkTG9ja2VkEAMSGwoXVXNlckRhdGFiYXNlRGlkTm90TWF0Y2gQBBIdChlVc2VyRGF0YWJhc2VJbnRlcm5hbEVycm9yEAUSFAoQU3FsSW50ZXJuYWxFcnJvchAGEhMKD1VzZXJOb3RMb2dpbllldBAKEhcKE1JlYWRDdXJyZW50SWRGYWlsZWQQCxIYChRXcml0ZUN1cnJlbnRJZEZhaWxlZBAMEhAKDEVtYWlsSW52YWxpZBAUEhMKD1Bhc3N3b3JkSW52YWxpZBAVEhMKD1VzZXJOYW1lSW52YWxpZBAWEhgKFFVzZXJXb3Jrc3BhY2VJbnZhbGlkEBcSEQoNVXNlcklkSW52YWxpZBAYEiAKHENyZWF0ZURlZmF1bHRXb3Jrc3BhY2VGYWlsZWQQGRIgChxEZWZhdWx0V29ya3NwYWNlQWxyZWFkeUV4aXN0EBo=');
@$core.Deprecated('Use userErrorDescriptor instead')
const UserError$json = const {
'1': 'UserError',

View File

@ -10,6 +10,6 @@ macro_rules! diesel_update_table {
let affected_row = diesel::update(filter)
.set($changeset)
.execute(&*$connection)?;
debug_assert_eq!(affected_row, 1);
// debug_assert_eq!(affected_row, 1);
};
}

View File

@ -36,7 +36,7 @@ where
Payload::None => ready(Err(unexpected_none_payload(req))),
Payload::Bytes(bytes) => match T::parse_from_bytes(bytes) {
Ok(data) => ready(Ok(Data(data))),
Err(e) => ready(Err(InternalError::new(format!("{:?}", e)).into())),
Err(e) => ready(Err(InternalError::new(format!("{}", e)).into())),
},
}
}
@ -50,7 +50,7 @@ where
match self.into_inner().into_bytes() {
Ok(bytes) => ResponseBuilder::Ok().data(bytes.to_vec()).build(),
Err(e) => {
let system_err: DispatchError = InternalError::new(format!("{:?}", e)).into();
let system_err: DispatchError = InternalError::new(format!("{}", e)).into();
system_err.into()
},
}

View File

@ -1,4 +1,5 @@
use crate::{
byte_trait::FromBytes,
request::EventRequest,
response::{EventResponse, ResponseBuilder, StatusCode},
};
@ -8,7 +9,7 @@ use std::{fmt, option::NoneError};
use tokio::sync::mpsc::error::SendError;
pub trait Error: fmt::Debug + DynClone + Send + Sync {
fn as_response(&self) -> EventResponse { EventResponse::new(StatusCode::Err) }
fn as_response(&self) -> EventResponse;
}
dyn_clone::clone_trait_object!(Error);
@ -66,6 +67,13 @@ impl From<String> for DispatchError {
fn from(s: String) -> Self { InternalError { inner: s }.into() }
}
impl FromBytes for DispatchError {
fn parse_from_bytes(bytes: &Vec<u8>) -> Result<Self, String> {
let s = String::from_utf8(bytes.to_vec()).unwrap();
Ok(InternalError { inner: s }.into())
}
}
impl From<DispatchError> for EventResponse {
fn from(err: DispatchError) -> Self { err.inner_error().as_response() }
}
@ -98,12 +106,8 @@ where
T: fmt::Debug + fmt::Display + 'static + Clone + Send + Sync,
{
fn as_response(&self) -> EventResponse {
let error = InternalError {
inner: format!("{}", self.inner),
}
.into();
ResponseBuilder::Err().error(error).build()
let error = format!("{}", self.inner).into_bytes();
ResponseBuilder::Err().data(error).build()
}
}

View File

@ -14,7 +14,6 @@ macro_rules! static_response {
pub struct ResponseBuilder<T = Payload> {
pub payload: T,
pub status: StatusCode,
pub error: Option<DispatchError>,
}
impl ResponseBuilder {
@ -22,7 +21,6 @@ impl ResponseBuilder {
ResponseBuilder {
payload: Payload::None,
status,
error: None,
}
}
@ -31,16 +29,10 @@ impl ResponseBuilder {
self
}
pub fn error(mut self, error: DispatchError) -> Self {
self.error = Some(error);
self
}
pub fn build(self) -> EventResponse {
EventResponse {
payload: self.payload,
status_code: self.status,
error: self.error,
}
}

View File

@ -20,7 +20,6 @@ pub struct EventResponse {
#[derivative(Debug = "ignore")]
pub payload: Payload,
pub status_code: StatusCode,
pub error: Option<DispatchError>,
}
impl EventResponse {
@ -28,7 +27,6 @@ impl EventResponse {
EventResponse {
payload: Payload::None,
status_code,
error: None,
}
}
@ -59,10 +57,6 @@ impl std::fmt::Display for EventResponse {
Payload::Bytes(b) => f.write_fmt(format_args!("Data: {} bytes", b.len()))?,
Payload::None => f.write_fmt(format_args!("Data: Empty"))?,
}
match &self.error {
Some(e) => f.write_fmt(format_args!("Error: {:?}", e))?,
None => {},
}
Ok(())
}

View File

@ -14,7 +14,7 @@ pub async fn create_doc(
manager: Unit<RwLock<FileManager>>,
) -> ResponseResult<DocInfo, EditorError> {
let params: CreateDocParams = data.into_inner().try_into()?;
let dir = manager.read().await.user.user_doc_dir()?;CreateDocRequest
let dir = manager.read().await.user.user_doc_dir()?;
let path = manager
.write()
.await

View File

@ -28,8 +28,7 @@ impl WorkspaceUser for WorkspaceUserImpl {
ErrorBuilder::new(WorkspaceErrorCode::UserInternalError)
.error(e)
.build()
});
})?;
Ok(())
}),
}

View File

@ -1,4 +1,10 @@
use flowy_dispatch::prelude::{DispatchFuture, EventDispatch, ModuleRequest, ToBytes};
use flowy_dispatch::prelude::{
DispatchError,
DispatchFuture,
EventDispatch,
ModuleRequest,
ToBytes,
};
use flowy_user::{
entities::{SignInParams, SignUpParams, UserDetail},
errors::{ErrorBuilder, UserError, UserErrorCode},
@ -67,7 +73,7 @@ impl UserServer for FlowyServerMocker {
fut: Box::pin(async move {
let result = EventDispatch::async_send(request)
.await
.parse::<Workspace, WorkspaceError>()
.parse::<Workspace, DispatchError>()
.map_err(|e| {
ErrorBuilder::new(UserErrorCode::CreateDefaultWorkspaceFailed)
.error(e)

View File

@ -31,6 +31,7 @@ thread-id = "3.3.0"
once_cell = "1.7.2"
parking_lot = "0.11"
[dev-dependencies]
quickcheck = "0.9.2"
quickcheck_macros = "0.9.1"

View File

@ -36,6 +36,9 @@ pub enum UserErrorCode {
#[display(fmt = "Database internal error")]
UserDatabaseInternalError = 5,
#[display(fmt = "Sql internal error")]
SqlInternalError = 6,
#[display(fmt = "User not login yet")]
UserNotLoginYet = 10,
#[display(fmt = "Get current id read lock failed")]
@ -71,7 +74,8 @@ impl std::convert::From<flowy_database::result::Error> for UserError {
.build()
}
}
// use diesel::result::{Error, DatabaseErrorKind};
// use flowy_sqlite::ErrorKind;
impl std::convert::From<flowy_sqlite::Error> for UserError {
fn from(error: flowy_sqlite::Error) -> Self {
// match error.kind() {
@ -87,7 +91,6 @@ impl std::convert::From<flowy_sqlite::Error> for UserError {
// }
// _ => {}
// }
//
// },
// Error::NotFound => {},
// Error::QueryBuilderError(_) => {},
@ -103,7 +106,7 @@ impl std::convert::From<flowy_sqlite::Error> for UserError {
// ErrorKind::__Nonexhaustive { .. } => {},
// }
ErrorBuilder::new(UserErrorCode::UserDatabaseInternalError)
ErrorBuilder::new(UserErrorCode::SqlInternalError)
.error(error)
.build()
}

View File

@ -3,13 +3,7 @@ use flowy_dispatch::prelude::*;
use std::{convert::TryInto, sync::Arc};
// tracing instrument 👉🏻 https://docs.rs/tracing/0.1.26/tracing/attr.instrument.html
#[tracing::instrument(
name = "user_sign_in",
skip(data, session),
fields(
email = %data.email,
)
)]
#[tracing::instrument(name = "user_sign_in", skip(data, session), fields(email = %data.email))]
pub async fn user_sign_in_handler(
data: Data<SignInRequest>,
session: Unit<Arc<UserSession>>,

View File

@ -221,6 +221,7 @@ pub enum UserErrorCode {
UserDatabaseReadLocked = 3,
UserDatabaseDidNotMatch = 4,
UserDatabaseInternalError = 5,
SqlInternalError = 6,
UserNotLoginYet = 10,
ReadCurrentIdFailed = 11,
WriteCurrentIdFailed = 12,
@ -246,6 +247,7 @@ impl ::protobuf::ProtobufEnum for UserErrorCode {
3 => ::std::option::Option::Some(UserErrorCode::UserDatabaseReadLocked),
4 => ::std::option::Option::Some(UserErrorCode::UserDatabaseDidNotMatch),
5 => ::std::option::Option::Some(UserErrorCode::UserDatabaseInternalError),
6 => ::std::option::Option::Some(UserErrorCode::SqlInternalError),
10 => ::std::option::Option::Some(UserErrorCode::UserNotLoginYet),
11 => ::std::option::Option::Some(UserErrorCode::ReadCurrentIdFailed),
12 => ::std::option::Option::Some(UserErrorCode::WriteCurrentIdFailed),
@ -268,6 +270,7 @@ impl ::protobuf::ProtobufEnum for UserErrorCode {
UserErrorCode::UserDatabaseReadLocked,
UserErrorCode::UserDatabaseDidNotMatch,
UserErrorCode::UserDatabaseInternalError,
UserErrorCode::SqlInternalError,
UserErrorCode::UserNotLoginYet,
UserErrorCode::ReadCurrentIdFailed,
UserErrorCode::WriteCurrentIdFailed,
@ -308,57 +311,59 @@ impl ::protobuf::reflect::ProtobufValue for UserErrorCode {
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x0cerrors.proto\"A\n\tUserError\x12\"\n\x04code\x18\x01\x20\x01(\x0e2\
\x0e.UserErrorCodeR\x04code\x12\x10\n\x03msg\x18\x02\x20\x01(\tR\x03msg*\
\xa2\x03\n\rUserErrorCode\x12\x0b\n\x07Unknown\x10\0\x12\x1a\n\x16UserDa\
\xb8\x03\n\rUserErrorCode\x12\x0b\n\x07Unknown\x10\0\x12\x1a\n\x16UserDa\
tabaseInitFailed\x10\x01\x12\x1b\n\x17UserDatabaseWriteLocked\x10\x02\
\x12\x1a\n\x16UserDatabaseReadLocked\x10\x03\x12\x1b\n\x17UserDatabaseDi\
dNotMatch\x10\x04\x12\x1d\n\x19UserDatabaseInternalError\x10\x05\x12\x13\
\n\x0fUserNotLoginYet\x10\n\x12\x17\n\x13ReadCurrentIdFailed\x10\x0b\x12\
\x18\n\x14WriteCurrentIdFailed\x10\x0c\x12\x10\n\x0cEmailInvalid\x10\x14\
\x12\x13\n\x0fPasswordInvalid\x10\x15\x12\x13\n\x0fUserNameInvalid\x10\
\x16\x12\x18\n\x14UserWorkspaceInvalid\x10\x17\x12\x11\n\rUserIdInvalid\
\x10\x18\x12\x20\n\x1cCreateDefaultWorkspaceFailed\x10\x19\x12\x20\n\x1c\
DefaultWorkspaceAlreadyExist\x10\x1aJ\xc0\x06\n\x06\x12\x04\0\0\x17\x01\
\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x05\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\x1b\n\x0c\n\x05\x04\0\x02\0\x06\x12\x03\x03\x04\x11\n\x0c\n\x05\
\x04\0\x02\0\x01\x12\x03\x03\x12\x16\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\
\x03\x19\x1a\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x04\x04\x13\n\x0c\n\x05\
\x04\0\x02\x01\x05\x12\x03\x04\x04\n\n\x0c\n\x05\x04\0\x02\x01\x01\x12\
\x03\x04\x0b\x0e\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x04\x11\x12\n\n\n\
\x02\x05\0\x12\x04\x06\0\x17\x01\n\n\n\x03\x05\0\x01\x12\x03\x06\x05\x12\
\n\x0b\n\x04\x05\0\x02\0\x12\x03\x07\x04\x10\n\x0c\n\x05\x05\0\x02\0\x01\
\x12\x03\x07\x04\x0b\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x07\x0e\x0f\n\
\x0b\n\x04\x05\0\x02\x01\x12\x03\x08\x04\x1f\n\x0c\n\x05\x05\0\x02\x01\
\x01\x12\x03\x08\x04\x1a\n\x0c\n\x05\x05\0\x02\x01\x02\x12\x03\x08\x1d\
\x1e\n\x0b\n\x04\x05\0\x02\x02\x12\x03\t\x04\x20\n\x0c\n\x05\x05\0\x02\
\x02\x01\x12\x03\t\x04\x1b\n\x0c\n\x05\x05\0\x02\x02\x02\x12\x03\t\x1e\
\x1f\n\x0b\n\x04\x05\0\x02\x03\x12\x03\n\x04\x1f\n\x0c\n\x05\x05\0\x02\
\x03\x01\x12\x03\n\x04\x1a\n\x0c\n\x05\x05\0\x02\x03\x02\x12\x03\n\x1d\
\x1e\n\x0b\n\x04\x05\0\x02\x04\x12\x03\x0b\x04\x20\n\x0c\n\x05\x05\0\x02\
\x04\x01\x12\x03\x0b\x04\x1b\n\x0c\n\x05\x05\0\x02\x04\x02\x12\x03\x0b\
\x1e\x1f\n\x0b\n\x04\x05\0\x02\x05\x12\x03\x0c\x04\"\n\x0c\n\x05\x05\0\
\x02\x05\x01\x12\x03\x0c\x04\x1d\n\x0c\n\x05\x05\0\x02\x05\x02\x12\x03\
\x0c\x20!\n\x0b\n\x04\x05\0\x02\x06\x12\x03\r\x04\x19\n\x0c\n\x05\x05\0\
\x02\x06\x01\x12\x03\r\x04\x13\n\x0c\n\x05\x05\0\x02\x06\x02\x12\x03\r\
\x16\x18\n\x0b\n\x04\x05\0\x02\x07\x12\x03\x0e\x04\x1d\n\x0c\n\x05\x05\0\
\x02\x07\x01\x12\x03\x0e\x04\x17\n\x0c\n\x05\x05\0\x02\x07\x02\x12\x03\
\x0e\x1a\x1c\n\x0b\n\x04\x05\0\x02\x08\x12\x03\x0f\x04\x1e\n\x0c\n\x05\
\x05\0\x02\x08\x01\x12\x03\x0f\x04\x18\n\x0c\n\x05\x05\0\x02\x08\x02\x12\
\x03\x0f\x1b\x1d\n\x0b\n\x04\x05\0\x02\t\x12\x03\x10\x04\x16\n\x0c\n\x05\
\x05\0\x02\t\x01\x12\x03\x10\x04\x10\n\x0c\n\x05\x05\0\x02\t\x02\x12\x03\
\x10\x13\x15\n\x0b\n\x04\x05\0\x02\n\x12\x03\x11\x04\x19\n\x0c\n\x05\x05\
\0\x02\n\x01\x12\x03\x11\x04\x13\n\x0c\n\x05\x05\0\x02\n\x02\x12\x03\x11\
\x16\x18\n\x0b\n\x04\x05\0\x02\x0b\x12\x03\x12\x04\x19\n\x0c\n\x05\x05\0\
\x02\x0b\x01\x12\x03\x12\x04\x13\n\x0c\n\x05\x05\0\x02\x0b\x02\x12\x03\
\x12\x16\x18\n\x0b\n\x04\x05\0\x02\x0c\x12\x03\x13\x04\x1e\n\x0c\n\x05\
\x05\0\x02\x0c\x01\x12\x03\x13\x04\x18\n\x0c\n\x05\x05\0\x02\x0c\x02\x12\
\x03\x13\x1b\x1d\n\x0b\n\x04\x05\0\x02\r\x12\x03\x14\x04\x17\n\x0c\n\x05\
\x05\0\x02\r\x01\x12\x03\x14\x04\x11\n\x0c\n\x05\x05\0\x02\r\x02\x12\x03\
\x14\x14\x16\n\x0b\n\x04\x05\0\x02\x0e\x12\x03\x15\x04&\n\x0c\n\x05\x05\
\0\x02\x0e\x01\x12\x03\x15\x04\x20\n\x0c\n\x05\x05\0\x02\x0e\x02\x12\x03\
\x15#%\n\x0b\n\x04\x05\0\x02\x0f\x12\x03\x16\x04&\n\x0c\n\x05\x05\0\x02\
\x0f\x01\x12\x03\x16\x04\x20\n\x0c\n\x05\x05\0\x02\x0f\x02\x12\x03\x16#%\
b\x06proto3\
dNotMatch\x10\x04\x12\x1d\n\x19UserDatabaseInternalError\x10\x05\x12\x14\
\n\x10SqlInternalError\x10\x06\x12\x13\n\x0fUserNotLoginYet\x10\n\x12\
\x17\n\x13ReadCurrentIdFailed\x10\x0b\x12\x18\n\x14WriteCurrentIdFailed\
\x10\x0c\x12\x10\n\x0cEmailInvalid\x10\x14\x12\x13\n\x0fPasswordInvalid\
\x10\x15\x12\x13\n\x0fUserNameInvalid\x10\x16\x12\x18\n\x14UserWorkspace\
Invalid\x10\x17\x12\x11\n\rUserIdInvalid\x10\x18\x12\x20\n\x1cCreateDefa\
ultWorkspaceFailed\x10\x19\x12\x20\n\x1cDefaultWorkspaceAlreadyExist\x10\
\x1aJ\xe9\x06\n\x06\x12\x04\0\0\x18\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\
\n\n\n\x02\x04\0\x12\x04\x02\0\x05\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\x1b\n\x0c\n\x05\x04\0\
\x02\0\x06\x12\x03\x03\x04\x11\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\
\x12\x16\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x19\x1a\n\x0b\n\x04\x04\
\0\x02\x01\x12\x03\x04\x04\x13\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x04\
\x04\n\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04\x0b\x0e\n\x0c\n\x05\x04\
\0\x02\x01\x03\x12\x03\x04\x11\x12\n\n\n\x02\x05\0\x12\x04\x06\0\x18\x01\
\n\n\n\x03\x05\0\x01\x12\x03\x06\x05\x12\n\x0b\n\x04\x05\0\x02\0\x12\x03\
\x07\x04\x10\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x07\x04\x0b\n\x0c\n\x05\
\x05\0\x02\0\x02\x12\x03\x07\x0e\x0f\n\x0b\n\x04\x05\0\x02\x01\x12\x03\
\x08\x04\x1f\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x08\x04\x1a\n\x0c\n\
\x05\x05\0\x02\x01\x02\x12\x03\x08\x1d\x1e\n\x0b\n\x04\x05\0\x02\x02\x12\
\x03\t\x04\x20\n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\t\x04\x1b\n\x0c\n\
\x05\x05\0\x02\x02\x02\x12\x03\t\x1e\x1f\n\x0b\n\x04\x05\0\x02\x03\x12\
\x03\n\x04\x1f\n\x0c\n\x05\x05\0\x02\x03\x01\x12\x03\n\x04\x1a\n\x0c\n\
\x05\x05\0\x02\x03\x02\x12\x03\n\x1d\x1e\n\x0b\n\x04\x05\0\x02\x04\x12\
\x03\x0b\x04\x20\n\x0c\n\x05\x05\0\x02\x04\x01\x12\x03\x0b\x04\x1b\n\x0c\
\n\x05\x05\0\x02\x04\x02\x12\x03\x0b\x1e\x1f\n\x0b\n\x04\x05\0\x02\x05\
\x12\x03\x0c\x04\"\n\x0c\n\x05\x05\0\x02\x05\x01\x12\x03\x0c\x04\x1d\n\
\x0c\n\x05\x05\0\x02\x05\x02\x12\x03\x0c\x20!\n\x0b\n\x04\x05\0\x02\x06\
\x12\x03\r\x04\x19\n\x0c\n\x05\x05\0\x02\x06\x01\x12\x03\r\x04\x14\n\x0c\
\n\x05\x05\0\x02\x06\x02\x12\x03\r\x17\x18\n\x0b\n\x04\x05\0\x02\x07\x12\
\x03\x0e\x04\x19\n\x0c\n\x05\x05\0\x02\x07\x01\x12\x03\x0e\x04\x13\n\x0c\
\n\x05\x05\0\x02\x07\x02\x12\x03\x0e\x16\x18\n\x0b\n\x04\x05\0\x02\x08\
\x12\x03\x0f\x04\x1d\n\x0c\n\x05\x05\0\x02\x08\x01\x12\x03\x0f\x04\x17\n\
\x0c\n\x05\x05\0\x02\x08\x02\x12\x03\x0f\x1a\x1c\n\x0b\n\x04\x05\0\x02\t\
\x12\x03\x10\x04\x1e\n\x0c\n\x05\x05\0\x02\t\x01\x12\x03\x10\x04\x18\n\
\x0c\n\x05\x05\0\x02\t\x02\x12\x03\x10\x1b\x1d\n\x0b\n\x04\x05\0\x02\n\
\x12\x03\x11\x04\x16\n\x0c\n\x05\x05\0\x02\n\x01\x12\x03\x11\x04\x10\n\
\x0c\n\x05\x05\0\x02\n\x02\x12\x03\x11\x13\x15\n\x0b\n\x04\x05\0\x02\x0b\
\x12\x03\x12\x04\x19\n\x0c\n\x05\x05\0\x02\x0b\x01\x12\x03\x12\x04\x13\n\
\x0c\n\x05\x05\0\x02\x0b\x02\x12\x03\x12\x16\x18\n\x0b\n\x04\x05\0\x02\
\x0c\x12\x03\x13\x04\x19\n\x0c\n\x05\x05\0\x02\x0c\x01\x12\x03\x13\x04\
\x13\n\x0c\n\x05\x05\0\x02\x0c\x02\x12\x03\x13\x16\x18\n\x0b\n\x04\x05\0\
\x02\r\x12\x03\x14\x04\x1e\n\x0c\n\x05\x05\0\x02\r\x01\x12\x03\x14\x04\
\x18\n\x0c\n\x05\x05\0\x02\r\x02\x12\x03\x14\x1b\x1d\n\x0b\n\x04\x05\0\
\x02\x0e\x12\x03\x15\x04\x17\n\x0c\n\x05\x05\0\x02\x0e\x01\x12\x03\x15\
\x04\x11\n\x0c\n\x05\x05\0\x02\x0e\x02\x12\x03\x15\x14\x16\n\x0b\n\x04\
\x05\0\x02\x0f\x12\x03\x16\x04&\n\x0c\n\x05\x05\0\x02\x0f\x01\x12\x03\
\x16\x04\x20\n\x0c\n\x05\x05\0\x02\x0f\x02\x12\x03\x16#%\n\x0b\n\x04\x05\
\0\x02\x10\x12\x03\x17\x04&\n\x0c\n\x05\x05\0\x02\x10\x01\x12\x03\x17\
\x04\x20\n\x0c\n\x05\x05\0\x02\x10\x02\x12\x03\x17#%b\x06proto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;

View File

@ -11,6 +11,7 @@ enum UserErrorCode {
UserDatabaseReadLocked = 3;
UserDatabaseDidNotMatch = 4;
UserDatabaseInternalError = 5;
SqlInternalError = 6;
UserNotLoginYet = 10;
ReadCurrentIdFailed = 11;
WriteCurrentIdFailed = 12;

View File

@ -110,7 +110,6 @@ impl UserSession {
let changeset = UserTableChangeset::new(params);
let conn = self.get_db_connection()?;
diesel_update_table!(user_table, changeset, conn);
let user_detail = self.user_detail()?;
Ok(user_detail)
}

View File

@ -36,8 +36,6 @@ impl WorkspaceController {
let workspace_table = WorkspaceTable::new(params);
let detail: Workspace = workspace_table.clone().into();
let _ = self.sql.create_workspace(workspace_table)?;
// let _ = self.user.set_cur_workspace_id(&detail.id).await?;
Ok(detail)
}