Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
config doc bloc
appflowyb0df64138fe0
diff --git a/app_flowy/lib/startup/tasks/rust_sdk_init_task.dart b/app_flowy/lib/startup/tasks/rust_sdk_init_task.dartindex 4f57190761..c5067b2cc9 100644--- a/app_flowy/lib/startup/tasks/rust_sdk_init_task.dart+++ b/app_flowy/lib/startup/tasks/rust_sdk_init_task.dart@@ -38,8 +38,9 @@ class RustSDKInitTask extends LaunchTask {class ApplicationBlocObserver extends BlocObserver {@override+ // ignore: unnecessary_overridesvoid onTransition(Bloc bloc, Transition transition) {- Log.debug(transition);+ // Log.debug(transition);super.onTransition(bloc, transition);}diff --git a/app_flowy/lib/welcome/infrastructure/deps_resolver.dart b/app_flowy/lib/welcome/infrastructure/deps_resolver.dartindex 070301e799..18024e9038 100644--- a/app_flowy/lib/welcome/infrastructure/deps_resolver.dart+++ b/app_flowy/lib/welcome/infrastructure/deps_resolver.dart@@ -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 {diff --git a/app_flowy/lib/workspace/application/doc/doc_bloc.dart b/app_flowy/lib/workspace/application/doc/doc_bloc.dartnew file mode 100644index 0000000000..27f3b0f5a0--- /dev/null+++ b/app_flowy/lib/workspace/application/doc/doc_bloc.dart@@ -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,+ );+}diff --git a/app_flowy/lib/workspace/application/doc/doc_bloc.freezed.dart b/app_flowy/lib/workspace/application/doc/doc_bloc.freezed.dartnew file mode 100644index 0000000000..1e74f06c09--- /dev/null+++ b/app_flowy/lib/workspace/application/doc/doc_bloc.freezed.dart@@ -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;+}diff --git a/app_flowy/lib/workspace/application/home_bloc.dart b/app_flowy/lib/workspace/application/home/home_bloc.dartsimilarity index 100%rename from app_flowy/lib/workspace/application/home_bloc.dartrename to app_flowy/lib/workspace/application/home/home_bloc.dartdiff --git a/app_flowy/lib/workspace/application/home_bloc.freezed.dart b/app_flowy/lib/workspace/application/home/home_bloc.freezed.dartsimilarity index 100%rename from app_flowy/lib/workspace/application/home_bloc.freezed.dartrename to app_flowy/lib/workspace/application/home/home_bloc.freezed.dartdiff --git a/app_flowy/lib/workspace/application/watcher/home_watcher_bloc.dart b/app_flowy/lib/workspace/application/home/home_watcher_bloc.dartsimilarity index 53%rename from app_flowy/lib/workspace/application/watcher/home_watcher_bloc.dartrename to app_flowy/lib/workspace/application/home/home_watcher_bloc.dartindex afb787e980..d6d86c59de 100644--- a/app_flowy/lib/workspace/application/watcher/home_watcher_bloc.dart+++ b/app_flowy/lib/workspace/application/home/home_watcher_bloc.dart@@ -1,10 +1,7 @@import 'package:flutter/material.dart';import 'package:freezed_annotation/freezed_annotation.dart';-// ignore: import_of_legacy_library_into_null_safeimport '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;+}diff --git a/app_flowy/lib/workspace/application/watcher/home_watcher_bloc.freezed.dart b/app_flowy/lib/workspace/application/home/home_watcher_bloc.freezed.dartsimilarity index 100%rename from app_flowy/lib/workspace/application/watcher/home_watcher_bloc.freezed.dartrename to app_flowy/lib/workspace/application/home/home_watcher_bloc.freezed.dartdiff --git a/app_flowy/lib/workspace/application/watcher/home_watcher_event.dart b/app_flowy/lib/workspace/application/watcher/home_watcher_event.dartdeleted file mode 100644index 0bae7a735c..0000000000--- a/app_flowy/lib/workspace/application/watcher/home_watcher_event.dart+++ /dev/null@@ -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;-}diff --git a/app_flowy/lib/workspace/application/watcher/home_watcher_state.dart b/app_flowy/lib/workspace/application/watcher/home_watcher_state.dartdeleted file mode 100644index 5081f94af0..0000000000--- a/app_flowy/lib/workspace/application/watcher/home_watcher_state.dart+++ /dev/null@@ -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;-}diff --git a/app_flowy/lib/workspace/infrastructure/deps_resolver.dart b/app_flowy/lib/workspace/infrastructure/deps_resolver.dartindex 134033f8de..a01ec4ea24 100644--- a/app_flowy/lib/workspace/infrastructure/deps_resolver.dart+++ b/app_flowy/lib/workspace/infrastructure/deps_resolver.dart@@ -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)));}diff --git a/app_flowy/lib/workspace/infrastructure/i_doc_impl.dart b/app_flowy/lib/workspace/infrastructure/i_doc_impl.dartindex 11fe1bd86e..2669f03ae0 100644--- a/app_flowy/lib/workspace/infrastructure/i_doc_impl.dart+++ b/app_flowy/lib/workspace/infrastructure/i_doc_impl.dart@@ -30,7 +30,8 @@ class IDocImpl extends IDoc {@overrideFuture<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) {diff --git a/app_flowy/lib/workspace/presentation/doc/editor_widget.dart b/app_flowy/lib/workspace/presentation/doc/editor_widget.dartindex 51eb04fce3..6cfb809063 100644--- a/app_flowy/lib/workspace/presentation/doc/editor_widget.dart+++ b/app_flowy/lib/workspace/presentation/doc/editor_widget.dart@@ -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();+ }}diff --git a/app_flowy/lib/workspace/presentation/home/home_layout.dart b/app_flowy/lib/workspace/presentation/home/home_layout.dartindex c16adb3b0d..5b72593c9b 100644--- a/app_flowy/lib/workspace/presentation/home/home_layout.dart+++ b/app_flowy/lib/workspace/presentation/home/home_layout.dart@@ -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';diff --git a/app_flowy/lib/workspace/presentation/home/home_screen.dart b/app_flowy/lib/workspace/presentation/home/home_screen.dartindex 36adc49748..39dfc4e90a 100644--- a/app_flowy/lib/workspace/presentation/home/home_screen.dart+++ b/app_flowy/lib/workspace/presentation/home/home_screen.dart@@ -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';diff --git a/app_flowy/lib/workspace/presentation/view/view_widget.dart b/app_flowy/lib/workspace/presentation/view/view_widget.dartindex 3ecd19c194..5e70770038 100644--- a/app_flowy/lib/workspace/presentation/view/view_widget.dart+++ b/app_flowy/lib/workspace/presentation/view/view_widget.dart@@ -11,12 +11,7 @@ class ViewWidget extends StatelessWidget {@overrideWidget build(BuildContext context) {- return InkWell(- onTap: _openView(context),- child: Container(- height: 30,- child: buildContent(),- ));+ return InkWell(onTap: _openView(context), child: buildContent());}Row buildContent() {diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbenum.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbenum.dartindex 42ddf173b1..791039fce8 100644--- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbenum.dart+++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbenum.dart@@ -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,diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbjson.dartindex 3bf44c6ee6..9625ae9cff 100644--- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbjson.dart+++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbjson.dart@@ -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',diff --git a/rust-lib/flowy-database/src/macros.rs b/rust-lib/flowy-database/src/macros.rsindex 08ca0e85b8..456d1f2699 100644--- a/rust-lib/flowy-database/src/macros.rs+++ b/rust-lib/flowy-database/src/macros.rs@@ -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);};}diff --git a/rust-lib/flowy-dispatch/src/data.rs b/rust-lib/flowy-dispatch/src/data.rsindex 0aaa94d41c..6539a52769 100644--- a/rust-lib/flowy-dispatch/src/data.rs+++ b/rust-lib/flowy-dispatch/src/data.rs@@ -36,7 +36,7 @@ wherePayload::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 @@ wherematch 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()},}diff --git a/rust-lib/flowy-dispatch/src/errors/errors.rs b/rust-lib/flowy-dispatch/src/errors/errors.rsindex 344807b6b2..ae7b1e6ff9 100644--- a/rust-lib/flowy-dispatch/src/errors/errors.rs+++ b/rust-lib/flowy-dispatch/src/errors/errors.rs@@ -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 @@ whereT: 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()}}diff --git a/rust-lib/flowy-dispatch/src/response/builder.rs b/rust-lib/flowy-dispatch/src/response/builder.rsindex abfe55184a..2d56db4205 100644--- a/rust-lib/flowy-dispatch/src/response/builder.rs+++ b/rust-lib/flowy-dispatch/src/response/builder.rs@@ -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,}}diff --git a/rust-lib/flowy-dispatch/src/response/response.rs b/rust-lib/flowy-dispatch/src/response/response.rsindex f0ed7c3fb6..593a3b4d3a 100644--- a/rust-lib/flowy-dispatch/src/response/response.rs+++ b/rust-lib/flowy-dispatch/src/response/response.rs@@ -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(())}diff --git a/rust-lib/flowy-editor/src/handlers/doc_handler.rs b/rust-lib/flowy-editor/src/handlers/doc_handler.rsindex ca8900e0ca..13ea1d641c 100644--- a/rust-lib/flowy-editor/src/handlers/doc_handler.rs+++ b/rust-lib/flowy-editor/src/handlers/doc_handler.rs@@ -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().awaitdiff --git a/rust-lib/flowy-sdk/src/deps_resolve/workspace_deps_impl.rs b/rust-lib/flowy-sdk/src/deps_resolve/workspace_deps_impl.rsindex 8b65b80782..67666078c7 100644--- a/rust-lib/flowy-sdk/src/deps_resolve/workspace_deps_impl.rs+++ b/rust-lib/flowy-sdk/src/deps_resolve/workspace_deps_impl.rs@@ -28,8 +28,7 @@ impl WorkspaceUser for WorkspaceUserImpl {ErrorBuilder::new(WorkspaceErrorCode::UserInternalError).error(e).build()- });-+ })?;Ok(())}),}diff --git a/rust-lib/flowy-sdk/src/flowy_server.rs b/rust-lib/flowy-sdk/src/flowy_server.rsindex 9fc7f577d7..3e3a2de9c8 100644--- a/rust-lib/flowy-sdk/src/flowy_server.rs+++ b/rust-lib/flowy-sdk/src/flowy_server.rs@@ -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)diff --git a/rust-lib/flowy-user/Cargo.toml b/rust-lib/flowy-user/Cargo.tomlindex db0be3480b..0d3d1d5199 100644--- a/rust-lib/flowy-user/Cargo.toml+++ b/rust-lib/flowy-user/Cargo.toml@@ -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"diff --git a/rust-lib/flowy-user/src/errors.rs b/rust-lib/flowy-user/src/errors.rsindex 454cbf8ec3..a1ff441cc3 100644--- a/rust-lib/flowy-user/src/errors.rs+++ b/rust-lib/flowy-user/src/errors.rs@@ -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()}diff --git a/rust-lib/flowy-user/src/handlers/auth_handler.rs b/rust-lib/flowy-user/src/handlers/auth_handler.rsindex f716e3233c..97073f4096 100644--- a/rust-lib/flowy-user/src/handlers/auth_handler.rs+++ b/rust-lib/flowy-user/src/handlers/auth_handler.rs@@ -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>>,diff --git a/rust-lib/flowy-user/src/protobuf/model/errors.rs b/rust-lib/flowy-user/src/protobuf/model/errors.rsindex 07209a5631..657a1837a7 100644--- a/rust-lib/flowy-user/src/protobuf/model/errors.rs+++ b/rust-lib/flowy-user/src/protobuf/model/errors.rs@@ -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;diff --git a/rust-lib/flowy-user/src/protobuf/proto/errors.proto b/rust-lib/flowy-user/src/protobuf/proto/errors.protoindex dfccb02b99..881ae87c12 100644--- a/rust-lib/flowy-user/src/protobuf/proto/errors.proto+++ b/rust-lib/flowy-user/src/protobuf/proto/errors.proto@@ -11,6 +11,7 @@ enum UserErrorCode {UserDatabaseReadLocked = 3;UserDatabaseDidNotMatch = 4;UserDatabaseInternalError = 5;+ SqlInternalError = 6;UserNotLoginYet = 10;ReadCurrentIdFailed = 11;WriteCurrentIdFailed = 12;diff --git a/rust-lib/flowy-user/src/services/user_session/user_session.rs b/rust-lib/flowy-user/src/services/user_session/user_session.rsindex 92dc040098..b1715214d4 100644--- a/rust-lib/flowy-user/src/services/user_session/user_session.rs+++ b/rust-lib/flowy-user/src/services/user_session/user_session.rs@@ -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)}diff --git a/rust-lib/flowy-workspace/src/services/workspace_controller.rs b/rust-lib/flowy-workspace/src/services/workspace_controller.rsindex 13564a173f..d98a9dfec7 100644--- a/rust-lib/flowy-workspace/src/services/workspace_controller.rs+++ b/rust-lib/flowy-workspace/src/services/workspace_controller.rs@@ -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)}