mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
Merge pull request #588 from AppFlowy-IO/refactor/folder_data_model
refactor: move entities from flowy-folder-data-model to flowy-folder crate
This commit is contained in:
commit
d25e89ea08
@ -4,7 +4,7 @@ import 'package:app_flowy/plugin/plugin.dart';
|
||||
import 'package:app_flowy/startup/startup.dart';
|
||||
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
||||
import 'package:flowy_infra/notifier.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
export "./src/sandbox.dart";
|
||||
|
@ -13,8 +13,8 @@ import 'package:app_flowy/user/application/prelude.dart';
|
||||
import 'package:app_flowy/user/presentation/router.dart';
|
||||
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
||||
import 'package:app_flowy/workspace/presentation/home/menu/menu.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
|
@ -3,7 +3,7 @@ import 'package:app_flowy/core/folder_notification.dart';
|
||||
import 'package:app_flowy/core/user_notification.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error-code/code.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/workspace.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'dart:typed_data';
|
||||
import 'package:flowy_infra/notifier.dart';
|
||||
|
@ -3,7 +3,7 @@ import 'dart:async';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/workspace.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
|
||||
|
||||
class UserService {
|
||||
|
@ -8,7 +8,7 @@ import 'package:app_flowy/workspace/presentation/home/home_screen.dart';
|
||||
import 'package:flowy_infra/time/duration.dart';
|
||||
import 'package:flowy_infra_ui/widget/route/animation.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart' show UserProfile;
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/protobuf.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/protobuf.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AuthRouter {
|
||||
|
@ -9,7 +9,7 @@ import 'package:flowy_infra_ui/widget/rounded_button.dart';
|
||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||
import 'package:flowy_sdk/log.dart';
|
||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/protobuf.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/protobuf.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -5,7 +5,7 @@ import 'package:flowy_infra/theme.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/button.dart';
|
||||
import 'package:flowy_infra_ui/widget/error_page.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/workspace.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
@ -7,8 +7,8 @@ import 'package:app_flowy/workspace/application/app/app_service.dart';
|
||||
import 'package:app_flowy/workspace/presentation/home/menu/menu.dart';
|
||||
import 'package:expandable/expandable.dart';
|
||||
import 'package:flowy_sdk/log.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
@ -5,8 +5,8 @@ import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/log.dart';
|
||||
import 'package:flowy_sdk/protobuf/dart-notify/subject.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/dart_notification.pb.dart';
|
||||
import 'package:flowy_sdk/rust_stream.dart';
|
||||
|
||||
|
@ -3,8 +3,8 @@ import 'dart:async';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
|
||||
import 'package:app_flowy/plugin/plugin.dart';
|
||||
|
||||
|
@ -2,9 +2,9 @@ import 'dart:convert';
|
||||
import 'package:app_flowy/workspace/application/doc/doc_service.dart';
|
||||
import 'package:app_flowy/workspace/application/trash/trash_service.dart';
|
||||
import 'package:app_flowy/workspace/application/view/view_listener.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/trash.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/trash.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flutter_quill/flutter_quill.dart' show Document, Delta;
|
||||
import 'package:flowy_sdk/log.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
||||
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-sync/text_block.pb.dart';
|
||||
|
||||
|
@ -4,7 +4,7 @@ import 'package:app_flowy/startup/tasks/rust_sdk.dart';
|
||||
import 'package:app_flowy/workspace/application/doc/share_service.dart';
|
||||
import 'package:app_flowy/workspace/application/markdown/delta_markdown.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-text-block/entities.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
@ -3,7 +3,7 @@ import 'package:dartz/dartz.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flowy_sdk/log.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-grid/protobuf.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
@ -5,7 +5,7 @@ import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
||||
import 'package:flowy_sdk/log.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-grid/block_entities.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-grid/grid_entities.pb.dart';
|
||||
|
@ -3,7 +3,7 @@ import 'package:app_flowy/workspace/application/edit_pannel/edit_context.dart';
|
||||
import 'package:flowy_sdk/log.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error-code/code.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/workspace.pb.dart' show CurrentWorkspaceSetting;
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart' show CurrentWorkspaceSetting;
|
||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
@ -4,7 +4,7 @@ import 'package:app_flowy/workspace/application/workspace/workspace_listener.dar
|
||||
import 'package:app_flowy/workspace/application/workspace/workspace_service.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/log.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:app_flowy/user/application/user_listener.dart';
|
||||
import 'package:app_flowy/user/application/user_service.dart';
|
||||
import 'package:flowy_sdk/log.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/workspace.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
@ -3,7 +3,7 @@ import 'dart:async';
|
||||
import 'package:app_flowy/workspace/application/app/app_bloc.dart';
|
||||
import 'package:app_flowy/workspace/application/app/app_service.dart';
|
||||
import 'package:flowy_sdk/log.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/log.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/trash.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/trash.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
@ -5,7 +5,7 @@ import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/protobuf/dart-notify/subject.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/dart_notification.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/trash.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/trash.pb.dart';
|
||||
import 'package:flowy_sdk/rust_stream.dart';
|
||||
|
||||
typedef TrashUpdatedCallback = void Function(Either<List<Trash>, FlowyError> trashOrFailed);
|
||||
|
@ -2,7 +2,7 @@ import 'dart:async';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/trash.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/trash.pb.dart';
|
||||
|
||||
class TrashService {
|
||||
Future<Either<RepeatedTrash, FlowyError>> readTrash() {
|
||||
@ -34,4 +34,3 @@ class TrashService {
|
||||
return FolderEventDeleteAllTrash().send();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:app_flowy/workspace/application/view/view_listener.dart';
|
||||
import 'package:app_flowy/workspace/application/view/view_service.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'package:app_flowy/plugin/plugin.dart';
|
||||
import 'package:flowy_infra/image.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum FlowyPlugin {
|
||||
|
@ -3,7 +3,7 @@ import 'dart:typed_data';
|
||||
import 'package:app_flowy/core/folder_notification.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/protobuf/dart-notify/subject.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/dart_notification.pb.dart';
|
||||
import 'package:flowy_sdk/rust_stream.dart';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
|
||||
class ViewService {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:app_flowy/user/application/user_listener.dart';
|
||||
import 'package:app_flowy/user/application/user_service.dart';
|
||||
import 'package:flowy_sdk/log.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/workspace.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
@ -4,8 +4,8 @@ import 'package:app_flowy/core/folder_notification.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_infra/notifier.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart' show UserProfile;
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/workspace.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/dart_notification.pb.dart';
|
||||
|
||||
|
@ -4,9 +4,9 @@ import 'package:dartz/dartz.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart' show MoveFolderItemPayload, MoveFolderItemType;
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/workspace.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart' show MoveFolderItemPayload, MoveFolderItemType;
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart';
|
||||
|
||||
import 'package:app_flowy/generated/locale_keys.g.dart';
|
||||
|
||||
|
@ -6,7 +6,7 @@ import 'package:app_flowy/startup/startup.dart';
|
||||
import 'package:flowy_sdk/log.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/container.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart' show UserProfile;
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/protobuf.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/protobuf.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
|
@ -5,7 +5,7 @@ import 'package:flowy_infra/icon_data.dart';
|
||||
import 'package:flowy_infra/theme.dart';
|
||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/text.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:app_flowy/workspace/application/app/app_bloc.dart';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:app_flowy/workspace/application/appearance.dart';
|
||||
import 'package:app_flowy/workspace/presentation/home/menu/menu.dart';
|
||||
import 'package:expandable/expandable.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:app_flowy/startup/startup.dart';
|
||||
|
@ -9,7 +9,7 @@ import 'package:flowy_infra/theme.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/hover.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/text.dart';
|
||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
|
@ -11,8 +11,8 @@ import 'package:flowy_infra/theme.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart';
|
||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart' show UserProfile;
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/workspace.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
||||
import 'package:app_flowy/workspace/presentation/plugins/widgets/left_bar_item.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:app_flowy/plugin/plugin.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// ignore_for_file: unused_field
|
||||
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BoardPage extends StatelessWidget {
|
||||
|
@ -20,7 +20,7 @@ import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||
import 'package:flowy_infra_ui/widget/rounded_button.dart';
|
||||
import 'package:flowy_sdk/log.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-text-block/entities.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
@ -6,7 +6,7 @@ import 'package:flowy_infra_ui/style_widget/scrolling/styled_scroll_bar.dart';
|
||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||
import 'package:flutter_quill/flutter_quill.dart' as quill;
|
||||
import 'package:flowy_infra_ui/widget/error_page.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
@ -3,7 +3,7 @@ import 'package:app_flowy/plugin/plugin.dart';
|
||||
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
||||
import 'package:app_flowy/workspace/presentation/plugins/widgets/left_bar_item.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'src/grid_page.dart';
|
||||
|
@ -5,7 +5,7 @@ import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/scrolling/styled_scroll_bar.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/scrolling/styled_scrollview.dart';
|
||||
import 'package:flowy_infra_ui/widget/error_page.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:linked_scroll_controller/linked_scroll_controller.dart';
|
||||
|
@ -3,7 +3,7 @@ import 'package:flowy_infra/theme.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/text.dart';
|
||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/trash.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/trash.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:fixnum/fixnum.dart' as $fixnum;
|
||||
|
@ -2,7 +2,7 @@ import 'package:app_flowy/workspace/application/view/view_listener.dart';
|
||||
import 'package:app_flowy/workspace/application/view/view_service.dart';
|
||||
import 'package:flowy_infra/theme.dart';
|
||||
import 'package:flowy_sdk/log.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
|
@ -6,7 +6,6 @@ import 'package:flowy_sdk/protobuf/dart-ffi/ffi_response.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-net/network_state.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user/event_map.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/event_map.pb.dart';
|
||||
import 'package:isolates/isolates.dart';
|
||||
import 'package:isolates/ports.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
@ -17,7 +16,7 @@ import 'dart:typed_data';
|
||||
import 'package:flowy_sdk/ffi.dart' as ffi;
|
||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart';
|
||||
import 'package:flowy_sdk/protobuf/dart-ffi/protobuf.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/protobuf.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/protobuf.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-text-block/protobuf.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-grid/protobuf.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-sync/protobuf.dart';
|
||||
|
1
frontend/rust-lib/Cargo.lock
generated
1
frontend/rust-lib/Cargo.lock
generated
@ -904,6 +904,7 @@ dependencies = [
|
||||
"strum_macros",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -34,6 +34,7 @@ serde = { version = "1.0", features = ["derive"] }
|
||||
tracing = { version = "0.1", features = ["log"] }
|
||||
bytes = { version = "1.0" }
|
||||
|
||||
unicode-segmentation = "1.8"
|
||||
[dev-dependencies]
|
||||
serde_json = "1.0"
|
||||
flowy-folder = { path = "../flowy-folder", features = ["flowy_unit_test"]}
|
||||
|
@ -1,20 +1,16 @@
|
||||
use crate::{
|
||||
entities::view::RepeatedView,
|
||||
errors::ErrorCode,
|
||||
impl_def_and_def_mut,
|
||||
parser::{
|
||||
entities::parser::{
|
||||
app::{AppColorStyle, AppIdentify, AppName},
|
||||
workspace::WorkspaceIdentify,
|
||||
},
|
||||
entities::view::RepeatedView,
|
||||
errors::ErrorCode,
|
||||
impl_def_and_def_mut,
|
||||
};
|
||||
use flowy_derive::ProtoBuf;
|
||||
use nanoid::nanoid;
|
||||
|
||||
use flowy_folder_data_model::revision::AppRevision;
|
||||
use std::convert::TryInto;
|
||||
|
||||
pub fn gen_app_id() -> String {
|
||||
nanoid!(10)
|
||||
}
|
||||
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
|
||||
pub struct App {
|
||||
#[pb(index = 1)]
|
||||
@ -42,6 +38,20 @@ pub struct App {
|
||||
pub create_time: i64,
|
||||
}
|
||||
|
||||
impl std::convert::From<AppRevision> for App {
|
||||
fn from(app_serde: AppRevision) -> Self {
|
||||
App {
|
||||
id: app_serde.id,
|
||||
workspace_id: app_serde.workspace_id,
|
||||
name: app_serde.name,
|
||||
desc: app_serde.desc,
|
||||
belongings: app_serde.belongings.into(),
|
||||
version: app_serde.version,
|
||||
modified_time: app_serde.modified_time,
|
||||
create_time: app_serde.create_time,
|
||||
}
|
||||
}
|
||||
}
|
||||
#[derive(Eq, PartialEq, Debug, Default, ProtoBuf, Clone)]
|
||||
pub struct RepeatedApp {
|
||||
#[pb(index = 1)]
|
||||
@ -50,6 +60,12 @@ pub struct RepeatedApp {
|
||||
|
||||
impl_def_and_def_mut!(RepeatedApp, App);
|
||||
|
||||
impl std::convert::From<Vec<AppRevision>> for RepeatedApp {
|
||||
fn from(values: Vec<AppRevision>) -> Self {
|
||||
let items = values.into_iter().map(|value| value.into()).collect::<Vec<App>>();
|
||||
RepeatedApp { items }
|
||||
}
|
||||
}
|
||||
#[derive(ProtoBuf, Default)]
|
||||
pub struct CreateAppPayload {
|
||||
#[pb(index = 1)]
|
@ -1,4 +1,5 @@
|
||||
pub mod app;
|
||||
mod parser;
|
||||
pub mod trash;
|
||||
pub mod view;
|
||||
mod view_info;
|
@ -3,6 +3,7 @@ use unicode_segmentation::UnicodeSegmentation;
|
||||
pub struct AppDesc(pub String);
|
||||
|
||||
impl AppDesc {
|
||||
#[allow(dead_code)]
|
||||
pub fn parse(s: String) -> Result<AppDesc, String> {
|
||||
if s.graphemes(true).count() > 1024 {
|
||||
return Err("Workspace description too long".to_string());
|
@ -2,6 +2,7 @@
|
||||
pub struct TrashIdentify(pub String);
|
||||
|
||||
impl TrashIdentify {
|
||||
#[allow(dead_code)]
|
||||
pub fn parse(s: String) -> Result<TrashIdentify, String> {
|
||||
if s.trim().is_empty() {
|
||||
return Err("Trash id can not be empty or whitespace".to_string());
|
||||
@ -21,6 +22,7 @@ impl AsRef<str> for TrashIdentify {
|
||||
pub struct TrashIds(pub Vec<String>);
|
||||
|
||||
impl TrashIds {
|
||||
#[allow(dead_code)]
|
||||
pub fn parse(ids: Vec<String>) -> Result<TrashIds, String> {
|
||||
let mut trash_ids = vec![];
|
||||
for id in ids {
|
@ -1,13 +1,9 @@
|
||||
mod delta_data;
|
||||
mod view_desc;
|
||||
mod view_ext;
|
||||
mod view_id;
|
||||
mod view_name;
|
||||
mod view_thumbnail;
|
||||
|
||||
pub use delta_data::*;
|
||||
pub use view_desc::*;
|
||||
pub use view_ext::*;
|
||||
pub use view_id::*;
|
||||
pub use view_name::*;
|
||||
pub use view_thumbnail::*;
|
@ -1,6 +1,6 @@
|
||||
use crate::impl_def_and_def_mut;
|
||||
use crate::revision::TrashRevision;
|
||||
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
||||
use flowy_folder_data_model::revision::{TrashRevision, TrashTypeRevision};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Formatter;
|
||||
|
||||
@ -22,6 +22,29 @@ pub struct Trash {
|
||||
pub ty: TrashType,
|
||||
}
|
||||
|
||||
impl std::convert::From<TrashRevision> for Trash {
|
||||
fn from(trash_rev: TrashRevision) -> Self {
|
||||
Trash {
|
||||
id: trash_rev.id,
|
||||
name: trash_rev.name,
|
||||
modified_time: trash_rev.modified_time,
|
||||
create_time: trash_rev.create_time,
|
||||
ty: trash_rev.ty.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<Trash> for TrashRevision {
|
||||
fn from(trash: Trash) -> Self {
|
||||
TrashRevision {
|
||||
id: trash.id,
|
||||
name: trash.name,
|
||||
modified_time: trash.modified_time,
|
||||
create_time: trash.create_time,
|
||||
ty: trash.ty.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
#[derive(PartialEq, Debug, Default, ProtoBuf, Clone)]
|
||||
pub struct RepeatedTrash {
|
||||
#[pb(index = 1)]
|
||||
@ -29,10 +52,16 @@ pub struct RepeatedTrash {
|
||||
}
|
||||
|
||||
impl_def_and_def_mut!(RepeatedTrash, Trash);
|
||||
impl std::convert::From<Vec<TrashRevision>> for RepeatedTrash {
|
||||
fn from(trash_revs: Vec<TrashRevision>) -> Self {
|
||||
let items: Vec<Trash> = trash_revs.into_iter().map(|trash_rev| trash_rev.into()).collect();
|
||||
RepeatedTrash { items }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Debug, ProtoBuf_Enum, Clone, Serialize, Deserialize)]
|
||||
pub enum TrashType {
|
||||
Unknown = 0,
|
||||
TrashUnknown = 0,
|
||||
TrashView = 1,
|
||||
TrashApp = 2,
|
||||
}
|
||||
@ -42,7 +71,7 @@ impl std::convert::TryFrom<i32> for TrashType {
|
||||
|
||||
fn try_from(value: i32) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
0 => Ok(TrashType::Unknown),
|
||||
0 => Ok(TrashType::TrashUnknown),
|
||||
1 => Ok(TrashType::TrashView),
|
||||
2 => Ok(TrashType::TrashApp),
|
||||
_ => Err(format!("Invalid trash type: {}", value)),
|
||||
@ -50,9 +79,29 @@ impl std::convert::TryFrom<i32> for TrashType {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<TrashTypeRevision> for TrashType {
|
||||
fn from(rev: TrashTypeRevision) -> Self {
|
||||
match rev {
|
||||
TrashTypeRevision::Unknown => TrashType::TrashUnknown,
|
||||
TrashTypeRevision::TrashView => TrashType::TrashView,
|
||||
TrashTypeRevision::TrashApp => TrashType::TrashApp,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<TrashType> for TrashTypeRevision {
|
||||
fn from(rev: TrashType) -> Self {
|
||||
match rev {
|
||||
TrashType::TrashUnknown => TrashTypeRevision::Unknown,
|
||||
TrashType::TrashView => TrashTypeRevision::TrashView,
|
||||
TrashType::TrashApp => TrashTypeRevision::TrashApp,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::default::Default for TrashType {
|
||||
fn default() -> Self {
|
||||
TrashType::Unknown
|
||||
TrashType::TrashUnknown
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,7 +145,10 @@ impl std::convert::From<Vec<TrashRevision>> for RepeatedTrashId {
|
||||
fn from(trash: Vec<TrashRevision>) -> Self {
|
||||
let items = trash
|
||||
.into_iter()
|
||||
.map(|t| TrashId { id: t.id, ty: t.ty })
|
||||
.map(|t| TrashId {
|
||||
id: t.id,
|
||||
ty: t.ty.into(),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
RepeatedTrashId {
|
||||
@ -120,3 +172,12 @@ impl std::fmt::Display for TrashId {
|
||||
f.write_str(&format!("{:?}:{}", self.ty, self.id))
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<&TrashRevision> for TrashId {
|
||||
fn from(trash: &TrashRevision) -> Self {
|
||||
TrashId {
|
||||
id: trash.id.clone(),
|
||||
ty: trash.ty.clone().into(),
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +1,15 @@
|
||||
use crate::{
|
||||
errors::ErrorCode,
|
||||
impl_def_and_def_mut,
|
||||
parser::{
|
||||
entities::parser::{
|
||||
app::AppIdentify,
|
||||
view::{ViewDesc, ViewIdentify, ViewName, ViewThumbnail},
|
||||
},
|
||||
errors::ErrorCode,
|
||||
impl_def_and_def_mut,
|
||||
};
|
||||
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
||||
use nanoid::nanoid;
|
||||
use serde_repr::*;
|
||||
use flowy_folder_data_model::revision::{gen_view_id, ViewDataTypeRevision, ViewRevision};
|
||||
use std::convert::TryInto;
|
||||
|
||||
pub fn gen_view_id() -> String {
|
||||
nanoid!(10)
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
|
||||
pub struct View {
|
||||
#[pb(index = 1)]
|
||||
@ -39,8 +34,21 @@ pub struct View {
|
||||
pub plugin_type: i32,
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Hash, Debug, ProtoBuf_Enum, Clone, Serialize_repr, Deserialize_repr)]
|
||||
#[repr(u8)]
|
||||
impl std::convert::From<ViewRevision> for View {
|
||||
fn from(rev: ViewRevision) -> Self {
|
||||
View {
|
||||
id: rev.id,
|
||||
belong_to_id: rev.belong_to_id,
|
||||
name: rev.name,
|
||||
data_type: rev.data_type.into(),
|
||||
modified_time: rev.modified_time,
|
||||
create_time: rev.create_time,
|
||||
plugin_type: rev.plugin_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Hash, Debug, ProtoBuf_Enum, Clone)]
|
||||
pub enum ViewDataType {
|
||||
TextBlock = 0,
|
||||
Grid = 1,
|
||||
@ -48,19 +56,24 @@ pub enum ViewDataType {
|
||||
|
||||
impl std::default::Default for ViewDataType {
|
||||
fn default() -> Self {
|
||||
ViewDataType::TextBlock
|
||||
ViewDataTypeRevision::default().into()
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<i32> for ViewDataType {
|
||||
fn from(val: i32) -> Self {
|
||||
match val {
|
||||
0 => ViewDataType::TextBlock,
|
||||
1 => ViewDataType::Grid,
|
||||
_ => {
|
||||
log::error!("Invalid view type: {}", val);
|
||||
ViewDataType::TextBlock
|
||||
}
|
||||
impl std::convert::From<ViewDataTypeRevision> for ViewDataType {
|
||||
fn from(rev: ViewDataTypeRevision) -> Self {
|
||||
match rev {
|
||||
ViewDataTypeRevision::TextBlock => ViewDataType::TextBlock,
|
||||
ViewDataTypeRevision::Grid => ViewDataType::Grid,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<ViewDataType> for ViewDataTypeRevision {
|
||||
fn from(ty: ViewDataType) -> Self {
|
||||
match ty {
|
||||
ViewDataType::TextBlock => ViewDataTypeRevision::TextBlock,
|
||||
ViewDataType::Grid => ViewDataTypeRevision::Grid,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -73,6 +86,12 @@ pub struct RepeatedView {
|
||||
|
||||
impl_def_and_def_mut!(RepeatedView, View);
|
||||
|
||||
impl std::convert::From<Vec<ViewRevision>> for RepeatedView {
|
||||
fn from(values: Vec<ViewRevision>) -> Self {
|
||||
let items = values.into_iter().map(|value| value.into()).collect::<Vec<View>>();
|
||||
RepeatedView { items }
|
||||
}
|
||||
}
|
||||
#[derive(Default, ProtoBuf)]
|
||||
pub struct RepeatedViewId {
|
||||
#[pb(index = 1)]
|
@ -1,17 +1,13 @@
|
||||
use crate::{
|
||||
entities::parser::workspace::{WorkspaceDesc, WorkspaceIdentify, WorkspaceName},
|
||||
entities::{app::RepeatedApp, view::View},
|
||||
errors::*,
|
||||
impl_def_and_def_mut,
|
||||
parser::workspace::{WorkspaceDesc, WorkspaceIdentify, WorkspaceName},
|
||||
};
|
||||
use flowy_derive::ProtoBuf;
|
||||
use nanoid::nanoid;
|
||||
|
||||
use flowy_folder_data_model::revision::WorkspaceRevision;
|
||||
use std::convert::TryInto;
|
||||
|
||||
pub fn gen_workspace_id() -> String {
|
||||
nanoid!(10)
|
||||
}
|
||||
#[derive(Eq, PartialEq, ProtoBuf, Default, Debug, Clone)]
|
||||
pub struct Workspace {
|
||||
#[pb(index = 1)]
|
||||
@ -33,6 +29,18 @@ pub struct Workspace {
|
||||
pub create_time: i64,
|
||||
}
|
||||
|
||||
impl std::convert::From<WorkspaceRevision> for Workspace {
|
||||
fn from(workspace_serde: WorkspaceRevision) -> Self {
|
||||
Workspace {
|
||||
id: workspace_serde.id,
|
||||
name: workspace_serde.name,
|
||||
desc: workspace_serde.desc,
|
||||
apps: workspace_serde.apps.into(),
|
||||
modified_time: workspace_serde.modified_time,
|
||||
create_time: workspace_serde.create_time,
|
||||
}
|
||||
}
|
||||
}
|
||||
#[derive(PartialEq, Debug, Default, ProtoBuf)]
|
||||
pub struct RepeatedWorkspace {
|
||||
#[pb(index = 1)]
|
@ -1,4 +1,4 @@
|
||||
pub use flowy_folder_data_model::entities;
|
||||
pub mod entities;
|
||||
pub mod event_map;
|
||||
pub mod services;
|
||||
|
||||
@ -14,8 +14,6 @@ pub mod protobuf;
|
||||
mod util;
|
||||
|
||||
pub mod prelude {
|
||||
pub use flowy_folder_data_model::entities::{app::*, trash::*, view::*, workspace::*};
|
||||
|
||||
pub use crate::{errors::*, event_map::*};
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
use crate::entities::view::ViewDataType;
|
||||
use crate::{
|
||||
dart_notification::{send_dart_notification, FolderNotification},
|
||||
entities::workspace::RepeatedWorkspace,
|
||||
@ -10,7 +11,6 @@ use crate::{
|
||||
};
|
||||
use bytes::Bytes;
|
||||
use flowy_error::FlowyError;
|
||||
use flowy_folder_data_model::entities::view::ViewDataType;
|
||||
use flowy_folder_data_model::user_default;
|
||||
use flowy_revision::disk::SQLiteTextBlockRevisionPersistence;
|
||||
use flowy_revision::{RevisionManager, RevisionPersistence, RevisionWebSocket};
|
||||
|
@ -1,14 +1,11 @@
|
||||
use crate::{
|
||||
entities::trash::{Trash, TrashType},
|
||||
errors::FlowyError,
|
||||
};
|
||||
use crate::errors::FlowyError;
|
||||
use diesel::sql_types::Integer;
|
||||
use flowy_database::{
|
||||
prelude::*,
|
||||
schema::{trash_table, trash_table::dsl},
|
||||
SqliteConnection,
|
||||
};
|
||||
use flowy_folder_data_model::revision::TrashRevision;
|
||||
use flowy_folder_data_model::revision::{TrashRevision, TrashTypeRevision};
|
||||
|
||||
pub struct TrashTableSql();
|
||||
impl TrashTableSql {
|
||||
@ -64,18 +61,18 @@ pub(crate) struct TrashTable {
|
||||
pub create_time: i64,
|
||||
pub ty: SqlTrashType,
|
||||
}
|
||||
impl std::convert::From<TrashTable> for Trash {
|
||||
fn from(table: TrashTable) -> Self {
|
||||
Trash {
|
||||
id: table.id,
|
||||
name: table.name,
|
||||
modified_time: table.modified_time,
|
||||
create_time: table.create_time,
|
||||
ty: table.ty.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// impl std::convert::From<TrashTable> for Trash {
|
||||
// fn from(table: TrashTable) -> Self {
|
||||
// Trash {
|
||||
// id: table.id,
|
||||
// name: table.name,
|
||||
// modified_time: table.modified_time,
|
||||
// create_time: table.create_time,
|
||||
// ty: table.ty.into(),
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
impl std::convert::From<TrashTable> for TrashRevision {
|
||||
fn from(trash: TrashTable) -> Self {
|
||||
TrashRevision {
|
||||
@ -141,22 +138,22 @@ impl std::convert::From<i32> for SqlTrashType {
|
||||
|
||||
impl_sql_integer_expression!(SqlTrashType);
|
||||
|
||||
impl std::convert::From<SqlTrashType> for TrashType {
|
||||
impl std::convert::From<SqlTrashType> for TrashTypeRevision {
|
||||
fn from(ty: SqlTrashType) -> Self {
|
||||
match ty {
|
||||
SqlTrashType::Unknown => TrashType::Unknown,
|
||||
SqlTrashType::View => TrashType::TrashView,
|
||||
SqlTrashType::App => TrashType::TrashApp,
|
||||
SqlTrashType::Unknown => TrashTypeRevision::Unknown,
|
||||
SqlTrashType::View => TrashTypeRevision::TrashView,
|
||||
SqlTrashType::App => TrashTypeRevision::TrashApp,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<TrashType> for SqlTrashType {
|
||||
fn from(ty: TrashType) -> Self {
|
||||
impl std::convert::From<TrashTypeRevision> for SqlTrashType {
|
||||
fn from(ty: TrashTypeRevision) -> Self {
|
||||
match ty {
|
||||
TrashType::Unknown => SqlTrashType::Unknown,
|
||||
TrashType::TrashView => SqlTrashType::View,
|
||||
TrashType::TrashApp => SqlTrashType::App,
|
||||
TrashTypeRevision::Unknown => SqlTrashType::Unknown,
|
||||
TrashTypeRevision::TrashView => SqlTrashType::View,
|
||||
TrashTypeRevision::TrashApp => SqlTrashType::App,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
entities::{
|
||||
trash::{Trash, TrashType},
|
||||
view::{UpdateViewParams, ViewDataType},
|
||||
view::UpdateViewParams,
|
||||
},
|
||||
errors::FlowyError,
|
||||
services::persistence::version_1::app_sql::AppTable,
|
||||
@ -13,7 +13,7 @@ use flowy_database::{
|
||||
SqliteConnection,
|
||||
};
|
||||
|
||||
use flowy_folder_data_model::revision::ViewRevision;
|
||||
use flowy_folder_data_model::revision::{ViewDataTypeRevision, ViewRevision};
|
||||
use lib_infra::util::timestamp;
|
||||
|
||||
pub struct ViewTableSql();
|
||||
@ -87,8 +87,8 @@ pub(crate) struct ViewTable {
|
||||
impl ViewTable {
|
||||
pub fn new(view_rev: ViewRevision) -> Self {
|
||||
let data_type = match view_rev.data_type {
|
||||
ViewDataType::TextBlock => SqlViewDataType::Block,
|
||||
ViewDataType::Grid => SqlViewDataType::Grid,
|
||||
ViewDataTypeRevision::TextBlock => SqlViewDataType::Block,
|
||||
ViewDataTypeRevision::Grid => SqlViewDataType::Grid,
|
||||
};
|
||||
|
||||
ViewTable {
|
||||
@ -110,8 +110,8 @@ impl ViewTable {
|
||||
impl std::convert::From<ViewTable> for ViewRevision {
|
||||
fn from(table: ViewTable) -> Self {
|
||||
let data_type = match table.view_type {
|
||||
SqlViewDataType::Block => ViewDataType::TextBlock,
|
||||
SqlViewDataType::Grid => ViewDataType::Grid,
|
||||
SqlViewDataType::Block => ViewDataTypeRevision::TextBlock,
|
||||
SqlViewDataType::Grid => ViewDataTypeRevision::Grid,
|
||||
};
|
||||
|
||||
ViewRevision {
|
||||
|
@ -51,7 +51,7 @@ impl TrashController {
|
||||
|
||||
let identifier = TrashId {
|
||||
id: trash.id,
|
||||
ty: trash.ty,
|
||||
ty: trash.ty.into(),
|
||||
};
|
||||
|
||||
let _ = self.delete_trash_on_server(RepeatedTrashId {
|
||||
|
@ -1,3 +1,5 @@
|
||||
pub use crate::entities::view::ViewDataType;
|
||||
use crate::entities::ViewInfo;
|
||||
use crate::manager::{ViewDataProcessor, ViewDataProcessorMap};
|
||||
use crate::{
|
||||
dart_notification::{send_dart_notification, FolderNotification},
|
||||
@ -14,9 +16,7 @@ use crate::{
|
||||
};
|
||||
use bytes::Bytes;
|
||||
use flowy_database::kv::KV;
|
||||
use flowy_folder_data_model::entities::view::{gen_view_id, ViewDataType};
|
||||
use flowy_folder_data_model::entities::ViewInfo;
|
||||
use flowy_folder_data_model::revision::ViewRevision;
|
||||
use flowy_folder_data_model::revision::{gen_view_id, ViewRevision};
|
||||
use flowy_sync::entities::text_block::TextBlockId;
|
||||
use futures::{FutureExt, StreamExt};
|
||||
use std::{collections::HashSet, sync::Arc};
|
||||
@ -58,7 +58,7 @@ impl ViewController {
|
||||
&self,
|
||||
mut params: CreateViewParams,
|
||||
) -> Result<ViewRevision, FlowyError> {
|
||||
let processor = self.get_data_processor(¶ms.data_type)?;
|
||||
let processor = self.get_data_processor(params.data_type.clone())?;
|
||||
let user_id = self.user.user_id()?;
|
||||
if params.data.is_empty() {
|
||||
let view_data = processor.create_default_view(&user_id, ¶ms.view_id).await?;
|
||||
@ -88,7 +88,7 @@ impl ViewController {
|
||||
return Err(FlowyError::internal().context("The content of the view should not be empty"));
|
||||
}
|
||||
let user_id = self.user.user_id()?;
|
||||
let processor = self.get_data_processor(&data_type)?;
|
||||
let processor = self.get_data_processor(data_type)?;
|
||||
let _ = processor.create_container(&user_id, view_id, delta_data).await?;
|
||||
Ok(())
|
||||
}
|
||||
@ -140,7 +140,7 @@ impl ViewController {
|
||||
belong_to_id: view_rev.belong_to_id,
|
||||
name: view_rev.name,
|
||||
desc: view_rev.desc,
|
||||
data_type: view_rev.data_type,
|
||||
data_type: view_rev.data_type.into(),
|
||||
belongings: RepeatedView { items },
|
||||
ext_data: view_rev.ext_data,
|
||||
};
|
||||
@ -209,14 +209,14 @@ impl ViewController {
|
||||
.begin_transaction(|transaction| transaction.read_view(view_id))
|
||||
.await?;
|
||||
|
||||
let processor = self.get_data_processor(&view_rev.data_type)?;
|
||||
let processor = self.get_data_processor(view_rev.data_type.clone())?;
|
||||
let delta_bytes = processor.get_delta_data(view_id).await?;
|
||||
let duplicate_params = CreateViewParams {
|
||||
belong_to_id: view_rev.belong_to_id.clone(),
|
||||
name: format!("{} (copy)", &view_rev.name),
|
||||
desc: view_rev.desc,
|
||||
thumbnail: view_rev.thumbnail,
|
||||
data_type: view_rev.data_type,
|
||||
data_type: view_rev.data_type.into(),
|
||||
data: delta_bytes.to_vec(),
|
||||
view_id: gen_view_id(),
|
||||
plugin_type: view_rev.plugin_type,
|
||||
@ -360,12 +360,16 @@ impl ViewController {
|
||||
.persistence
|
||||
.begin_transaction(|transaction| transaction.read_view(view_id))
|
||||
.await?;
|
||||
self.get_data_processor(&view.data_type)
|
||||
self.get_data_processor(view.data_type)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get_data_processor(&self, data_type: &ViewDataType) -> FlowyResult<Arc<dyn ViewDataProcessor + Send + Sync>> {
|
||||
match self.data_processors.get(data_type) {
|
||||
fn get_data_processor<T: Into<ViewDataType>>(
|
||||
&self,
|
||||
data_type: T,
|
||||
) -> FlowyResult<Arc<dyn ViewDataProcessor + Send + Sync>> {
|
||||
let data_type = data_type.into();
|
||||
match self.data_processors.get(&data_type) {
|
||||
None => Err(FlowyError::internal().context(format!(
|
||||
"Get data processor failed. Unknown view data type: {:?}",
|
||||
data_type
|
||||
@ -429,7 +433,8 @@ async fn handle_trash_event(
|
||||
.await?;
|
||||
|
||||
for view in views {
|
||||
match get_data_processor(data_processors.clone(), &view.data_type) {
|
||||
let data_type = view.data_type.clone().into();
|
||||
match get_data_processor(data_processors.clone(), &data_type) {
|
||||
Ok(processor) => {
|
||||
let _ = processor.close_container(&view.id).await?;
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
use crate::entities::view::{MoveFolderItemParams, MoveFolderItemPayload, MoveFolderItemType};
|
||||
use crate::entities::ViewInfo;
|
||||
use crate::manager::FolderManager;
|
||||
use crate::services::{notify_workspace_setting_did_change, AppController};
|
||||
use crate::{
|
||||
@ -10,8 +12,6 @@ use crate::{
|
||||
errors::FlowyError,
|
||||
services::{TrashController, ViewController},
|
||||
};
|
||||
use flowy_folder_data_model::entities::view::{MoveFolderItemParams, MoveFolderItemPayload, MoveFolderItemType};
|
||||
use flowy_folder_data_model::entities::ViewInfo;
|
||||
use flowy_folder_data_model::revision::TrashRevision;
|
||||
use lib_dispatch::prelude::{data_result, AppData, Data, DataResult};
|
||||
use std::{convert::TryInto, sync::Arc};
|
||||
|
@ -1,3 +1,4 @@
|
||||
use crate::entities::workspace::*;
|
||||
use crate::manager::FolderManager;
|
||||
use crate::{
|
||||
dart_notification::*,
|
||||
@ -9,7 +10,6 @@ use crate::{
|
||||
},
|
||||
};
|
||||
use flowy_database::kv::KV;
|
||||
use flowy_folder_data_model::entities::workspace::*;
|
||||
use flowy_folder_data_model::revision::{AppRevision, WorkspaceRevision};
|
||||
use std::sync::Arc;
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
use crate::entities::{
|
||||
app::RepeatedApp,
|
||||
view::View,
|
||||
workspace::{CurrentWorkspaceSetting, RepeatedWorkspace, WorkspaceId, *},
|
||||
};
|
||||
use crate::{
|
||||
dart_notification::{send_dart_notification, FolderNotification},
|
||||
errors::FlowyError,
|
||||
manager::FolderManager,
|
||||
services::{get_current_workspace, read_local_workspace_apps, WorkspaceController},
|
||||
};
|
||||
use flowy_folder_data_model::entities::{
|
||||
app::RepeatedApp,
|
||||
view::View,
|
||||
workspace::{CurrentWorkspaceSetting, RepeatedWorkspace, WorkspaceId, *},
|
||||
};
|
||||
use lib_dispatch::prelude::{data_result, AppData, Data, DataResult};
|
||||
use std::{convert::TryInto, sync::Arc};
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::script::{invalid_workspace_name_test_case, FolderScript::*, FolderTest};
|
||||
use flowy_folder::entities::view::ViewDataType;
|
||||
use flowy_folder::entities::workspace::CreateWorkspacePayload;
|
||||
use flowy_folder_data_model::entities::view::ViewDataType;
|
||||
|
||||
use flowy_revision::disk::RevisionState;
|
||||
use flowy_test::{event_builder::*, FlowySDKTest};
|
||||
|
@ -1,19 +1,19 @@
|
||||
use flowy_folder::event_map::FolderEvent::*;
|
||||
use flowy_folder::{errors::ErrorCode, services::folder_editor::FolderEditor};
|
||||
use flowy_folder_data_model::entities::view::{RepeatedViewId, ViewId};
|
||||
use flowy_folder_data_model::entities::workspace::WorkspaceId;
|
||||
use flowy_folder_data_model::entities::{
|
||||
use flowy_folder::entities::view::{RepeatedViewId, ViewId};
|
||||
use flowy_folder::entities::workspace::WorkspaceId;
|
||||
use flowy_folder::entities::{
|
||||
app::{App, RepeatedApp},
|
||||
trash::Trash,
|
||||
view::{RepeatedView, View, ViewDataType},
|
||||
workspace::Workspace,
|
||||
};
|
||||
use flowy_folder_data_model::entities::{
|
||||
use flowy_folder::entities::{
|
||||
app::{AppId, CreateAppPayload, UpdateAppPayload},
|
||||
trash::{RepeatedTrash, TrashId, TrashType},
|
||||
view::{CreateViewPayload, UpdateViewPayload},
|
||||
workspace::{CreateWorkspacePayload, RepeatedWorkspace},
|
||||
};
|
||||
use flowy_folder::event_map::FolderEvent::*;
|
||||
use flowy_folder::{errors::ErrorCode, services::folder_editor::FolderEditor};
|
||||
|
||||
use flowy_revision::disk::RevisionState;
|
||||
use flowy_revision::REVISION_WRITE_INTERVAL_IN_MILLIS;
|
||||
@ -205,7 +205,7 @@ impl FolderTest {
|
||||
restore_view_from_trash(sdk, &self.view.id).await;
|
||||
}
|
||||
FolderScript::ReadTrash => {
|
||||
let trash = read_trash(sdk).await;
|
||||
let mut trash = read_trash(sdk).await;
|
||||
self.trash = trash.into_inner();
|
||||
}
|
||||
FolderScript::DeleteAllTrash => {
|
||||
@ -264,7 +264,7 @@ pub async fn create_workspace(sdk: &FlowySDKTest, name: &str, desc: &str) -> Wor
|
||||
|
||||
pub async fn read_workspace(sdk: &FlowySDKTest, workspace_id: Option<String>) -> Vec<Workspace> {
|
||||
let request = WorkspaceId { value: workspace_id };
|
||||
let repeated_workspace = FolderEventBuilder::new(sdk.clone())
|
||||
let mut repeated_workspace = FolderEventBuilder::new(sdk.clone())
|
||||
.event(ReadWorkspaces)
|
||||
.payload(request.clone())
|
||||
.async_send()
|
||||
|
@ -3,7 +3,7 @@ use crate::{
|
||||
request::{HttpRequestBuilder, ResponseMiddleware},
|
||||
};
|
||||
use flowy_error::FlowyError;
|
||||
use flowy_folder_data_model::entities::{
|
||||
use flowy_folder::entities::{
|
||||
trash::RepeatedTrashId,
|
||||
view::{CreateViewParams, RepeatedViewId, UpdateViewParams, ViewId},
|
||||
workspace::{CreateWorkspaceParams, UpdateWorkspaceParams, WorkspaceId},
|
||||
|
@ -252,15 +252,15 @@ impl RevisionUser for LocalRevisionUser {
|
||||
}
|
||||
}
|
||||
|
||||
use flowy_folder_data_model::entities::app::gen_app_id;
|
||||
use flowy_folder_data_model::entities::workspace::gen_workspace_id;
|
||||
use flowy_folder_data_model::entities::{
|
||||
use flowy_folder::entities::{
|
||||
app::{AppId, CreateAppParams, UpdateAppParams},
|
||||
trash::RepeatedTrashId,
|
||||
view::{CreateViewParams, RepeatedViewId, UpdateViewParams, ViewId},
|
||||
workspace::{CreateWorkspaceParams, UpdateWorkspaceParams, WorkspaceId},
|
||||
};
|
||||
use flowy_folder_data_model::revision::{AppRevision, TrashRevision, ViewRevision, WorkspaceRevision};
|
||||
use flowy_folder_data_model::revision::{
|
||||
gen_app_id, gen_workspace_id, AppRevision, TrashRevision, ViewRevision, WorkspaceRevision,
|
||||
};
|
||||
use flowy_text_block::BlockCloudService;
|
||||
use flowy_user::event_map::UserCloudService;
|
||||
use flowy_user_data_model::entities::{
|
||||
@ -308,7 +308,7 @@ impl FolderCouldServiceV1 for LocalServer {
|
||||
belong_to_id: params.belong_to_id,
|
||||
name: params.name,
|
||||
desc: params.desc,
|
||||
data_type: params.data_type,
|
||||
data_type: params.data_type.into(),
|
||||
version: 0,
|
||||
belongings: vec![],
|
||||
modified_time: time,
|
||||
|
@ -1,7 +1,7 @@
|
||||
use bytes::Bytes;
|
||||
use flowy_database::ConnectionPool;
|
||||
use flowy_folder::entities::ViewDataType;
|
||||
use flowy_folder::manager::{ViewDataProcessor, ViewDataProcessorMap};
|
||||
use flowy_folder::prelude::ViewDataType;
|
||||
use flowy_folder::{
|
||||
errors::{internal_error, FlowyError},
|
||||
event_map::{FolderCouldServiceV1, WorkspaceDatabase, WorkspaceUser},
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::prelude::*;
|
||||
use flowy_folder::prelude::WorkspaceId;
|
||||
use flowy_folder::entities::WorkspaceId;
|
||||
use flowy_folder::{
|
||||
entities::{
|
||||
app::*,
|
||||
|
@ -1,2 +0,0 @@
|
||||
# Check out the FlowyConfig (located in flowy_toml.rs) for more details.
|
||||
proto_input = ["src/entities",]
|
@ -1,5 +0,0 @@
|
||||
use lib_infra::code_gen;
|
||||
|
||||
fn main() {
|
||||
code_gen::protobuf_file::gen(env!("CARGO_PKG_NAME"));
|
||||
}
|
@ -1,11 +1,6 @@
|
||||
pub mod entities;
|
||||
pub mod parser;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
|
||||
// #[cfg(feature = "backend")]
|
||||
pub mod protobuf;
|
||||
pub mod revision;
|
||||
pub mod user_default;
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
#[derive(Debug)]
|
||||
pub struct DeltaData(pub Vec<u8>);
|
||||
|
||||
impl DeltaData {
|
||||
pub fn parse(data: Vec<u8>) -> Result<DeltaData, String> {
|
||||
// let _ = Delta::from_bytes(data.clone()).map_err(|e| format!("{:?}", e))?;
|
||||
|
||||
Ok(Self(data))
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
use crate::errors::ErrorCode;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ViewExtensionData(pub String);
|
||||
|
||||
impl ViewExtensionData {
|
||||
pub fn parse(s: String) -> Result<ViewExtensionData, ErrorCode> {
|
||||
Ok(Self(s))
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<str> for ViewExtensionData {
|
||||
fn as_ref(&self) -> &str {
|
||||
&self.0
|
||||
}
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
use crate::entities::app::App;
|
||||
use crate::entities::{RepeatedApp, TrashType};
|
||||
use crate::revision::{TrashRevision, ViewRevision};
|
||||
use crate::revision::{TrashRevision, TrashTypeRevision, ViewRevision};
|
||||
use nanoid::nanoid;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub fn gen_app_id() -> String {
|
||||
nanoid!(10)
|
||||
}
|
||||
#[derive(Default, Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub struct AppRevision {
|
||||
pub id: String,
|
||||
@ -22,21 +24,6 @@ pub struct AppRevision {
|
||||
pub create_time: i64,
|
||||
}
|
||||
|
||||
impl std::convert::From<AppRevision> for App {
|
||||
fn from(app_serde: AppRevision) -> Self {
|
||||
App {
|
||||
id: app_serde.id,
|
||||
workspace_id: app_serde.workspace_id,
|
||||
name: app_serde.name,
|
||||
desc: app_serde.desc,
|
||||
belongings: app_serde.belongings.into(),
|
||||
version: app_serde.version,
|
||||
modified_time: app_serde.modified_time,
|
||||
create_time: app_serde.create_time,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<AppRevision> for TrashRevision {
|
||||
fn from(app_rev: AppRevision) -> Self {
|
||||
TrashRevision {
|
||||
@ -44,14 +31,7 @@ impl std::convert::From<AppRevision> for TrashRevision {
|
||||
name: app_rev.name,
|
||||
modified_time: app_rev.modified_time,
|
||||
create_time: app_rev.create_time,
|
||||
ty: TrashType::TrashApp,
|
||||
ty: TrashTypeRevision::TrashApp,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<Vec<AppRevision>> for RepeatedApp {
|
||||
fn from(values: Vec<AppRevision>) -> Self {
|
||||
let items = values.into_iter().map(|value| value.into()).collect::<Vec<App>>();
|
||||
RepeatedApp { items }
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::entities::trash::{Trash, TrashType};
|
||||
use crate::entities::{RepeatedTrash, TrashId};
|
||||
use serde::de::Visitor;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use serde_repr::*;
|
||||
use std::fmt;
|
||||
#[derive(Default, Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub struct TrashRevision {
|
||||
pub id: String,
|
||||
@ -12,45 +12,122 @@ pub struct TrashRevision {
|
||||
|
||||
pub create_time: i64,
|
||||
|
||||
pub ty: TrashType,
|
||||
pub ty: TrashTypeRevision,
|
||||
}
|
||||
|
||||
impl std::convert::From<Vec<TrashRevision>> for RepeatedTrash {
|
||||
fn from(trash_revs: Vec<TrashRevision>) -> Self {
|
||||
let items: Vec<Trash> = trash_revs.into_iter().map(|trash_rev| trash_rev.into()).collect();
|
||||
RepeatedTrash { items }
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize_repr)]
|
||||
#[repr(u8)]
|
||||
pub enum TrashTypeRevision {
|
||||
Unknown = 0,
|
||||
TrashView = 1,
|
||||
TrashApp = 2,
|
||||
}
|
||||
impl<'de> serde::Deserialize<'de> for TrashTypeRevision {
|
||||
fn deserialize<D>(deserializer: D) -> core::result::Result<Self, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
struct TrashTypeVisitor();
|
||||
|
||||
impl<'de> Visitor<'de> for TrashTypeVisitor {
|
||||
type Value = TrashTypeRevision;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
formatter.write_str("u8")
|
||||
}
|
||||
|
||||
fn visit_i8<E>(self, v: i8) -> Result<Self::Value, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
self.visit_u8(v as u8)
|
||||
}
|
||||
|
||||
fn visit_i16<E>(self, v: i16) -> Result<Self::Value, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
self.visit_u8(v as u8)
|
||||
}
|
||||
|
||||
fn visit_i32<E>(self, v: i32) -> Result<Self::Value, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
self.visit_u8(v as u8)
|
||||
}
|
||||
|
||||
fn visit_i64<E>(self, v: i64) -> Result<Self::Value, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
self.visit_u8(v as u8)
|
||||
}
|
||||
|
||||
fn visit_u8<E>(self, v: u8) -> Result<Self::Value, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
let ty = match v {
|
||||
0 => TrashTypeRevision::Unknown,
|
||||
1 => TrashTypeRevision::TrashView,
|
||||
2 => TrashTypeRevision::TrashApp,
|
||||
_ => TrashTypeRevision::Unknown,
|
||||
};
|
||||
|
||||
Ok(ty)
|
||||
}
|
||||
|
||||
fn visit_u16<E>(self, v: u16) -> Result<Self::Value, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
self.visit_u8(v as u8)
|
||||
}
|
||||
|
||||
fn visit_u32<E>(self, v: u32) -> Result<Self::Value, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
self.visit_u8(v as u8)
|
||||
}
|
||||
|
||||
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
self.visit_u8(v as u8)
|
||||
}
|
||||
|
||||
fn visit_str<E>(self, s: &str) -> Result<Self::Value, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
let value = match s {
|
||||
"Unknown" => TrashTypeRevision::Unknown,
|
||||
"TrashView" => TrashTypeRevision::TrashView,
|
||||
"TrashApp" => TrashTypeRevision::TrashApp,
|
||||
_ => TrashTypeRevision::Unknown,
|
||||
};
|
||||
Ok(value)
|
||||
}
|
||||
}
|
||||
|
||||
deserializer.deserialize_any(TrashTypeVisitor())
|
||||
}
|
||||
}
|
||||
impl std::default::Default for TrashTypeRevision {
|
||||
fn default() -> Self {
|
||||
TrashTypeRevision::Unknown
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<TrashRevision> for Trash {
|
||||
fn from(trash_rev: TrashRevision) -> Self {
|
||||
Trash {
|
||||
id: trash_rev.id,
|
||||
name: trash_rev.name,
|
||||
modified_time: trash_rev.modified_time,
|
||||
create_time: trash_rev.create_time,
|
||||
ty: trash_rev.ty,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<Trash> for TrashRevision {
|
||||
fn from(trash: Trash) -> Self {
|
||||
TrashRevision {
|
||||
id: trash.id,
|
||||
name: trash.name,
|
||||
modified_time: trash.modified_time,
|
||||
create_time: trash.create_time,
|
||||
ty: trash.ty,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<&TrashRevision> for TrashId {
|
||||
fn from(trash: &TrashRevision) -> Self {
|
||||
TrashId {
|
||||
id: trash.id.clone(),
|
||||
ty: trash.ty.clone(),
|
||||
impl std::convert::From<TrashTypeRevision> for u8 {
|
||||
fn from(rev: TrashTypeRevision) -> Self {
|
||||
match rev {
|
||||
TrashTypeRevision::Unknown => 0,
|
||||
TrashTypeRevision::TrashView => 1,
|
||||
TrashTypeRevision::TrashApp => 2,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
use crate::entities::view::{View, ViewDataType};
|
||||
use crate::entities::{RepeatedView, TrashType};
|
||||
use crate::revision::TrashRevision;
|
||||
use crate::revision::{TrashRevision, TrashTypeRevision};
|
||||
use nanoid::nanoid;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use serde_repr::*;
|
||||
pub fn gen_view_id() -> String {
|
||||
nanoid!(10)
|
||||
}
|
||||
#[derive(Default, Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ViewRevision {
|
||||
pub id: String,
|
||||
@ -14,7 +16,7 @@ pub struct ViewRevision {
|
||||
pub desc: String,
|
||||
|
||||
#[serde(default)]
|
||||
pub data_type: ViewDataType,
|
||||
pub data_type: ViewDataTypeRevision,
|
||||
|
||||
pub version: i64,
|
||||
|
||||
@ -35,20 +37,6 @@ pub struct ViewRevision {
|
||||
}
|
||||
const DEFAULT_PLUGIN_TYPE: fn() -> i32 = || 0;
|
||||
|
||||
impl std::convert::From<ViewRevision> for View {
|
||||
fn from(view_serde: ViewRevision) -> Self {
|
||||
View {
|
||||
id: view_serde.id,
|
||||
belong_to_id: view_serde.belong_to_id,
|
||||
name: view_serde.name,
|
||||
data_type: view_serde.data_type,
|
||||
modified_time: view_serde.modified_time,
|
||||
create_time: view_serde.create_time,
|
||||
plugin_type: view_serde.plugin_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<ViewRevision> for TrashRevision {
|
||||
fn from(view_rev: ViewRevision) -> Self {
|
||||
TrashRevision {
|
||||
@ -56,13 +44,20 @@ impl std::convert::From<ViewRevision> for TrashRevision {
|
||||
name: view_rev.name,
|
||||
modified_time: view_rev.modified_time,
|
||||
create_time: view_rev.create_time,
|
||||
ty: TrashType::TrashView,
|
||||
ty: TrashTypeRevision::TrashView,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl std::convert::From<Vec<ViewRevision>> for RepeatedView {
|
||||
fn from(values: Vec<ViewRevision>) -> Self {
|
||||
let items = values.into_iter().map(|value| value.into()).collect::<Vec<View>>();
|
||||
RepeatedView { items }
|
||||
|
||||
#[derive(Eq, PartialEq, Debug, Clone, Serialize_repr, Deserialize_repr)]
|
||||
#[repr(u8)]
|
||||
pub enum ViewDataTypeRevision {
|
||||
TextBlock = 0,
|
||||
Grid = 1,
|
||||
}
|
||||
|
||||
impl std::default::Default for ViewDataTypeRevision {
|
||||
fn default() -> Self {
|
||||
ViewDataTypeRevision::TextBlock
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
use crate::entities::workspace::Workspace;
|
||||
use crate::revision::AppRevision;
|
||||
use nanoid::nanoid;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub fn gen_workspace_id() -> String {
|
||||
nanoid!(10)
|
||||
}
|
||||
#[derive(Default, Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub struct WorkspaceRevision {
|
||||
pub id: String,
|
||||
@ -16,16 +18,3 @@ pub struct WorkspaceRevision {
|
||||
|
||||
pub create_time: i64,
|
||||
}
|
||||
|
||||
impl std::convert::From<WorkspaceRevision> for Workspace {
|
||||
fn from(workspace_serde: WorkspaceRevision) -> Self {
|
||||
Workspace {
|
||||
id: workspace_serde.id,
|
||||
name: workspace_serde.name,
|
||||
desc: workspace_serde.desc,
|
||||
apps: workspace_serde.apps.into(),
|
||||
modified_time: workspace_serde.modified_time,
|
||||
create_time: workspace_serde.create_time,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
use crate::entities::app::gen_app_id;
|
||||
use crate::entities::view::gen_view_id;
|
||||
use crate::entities::view::ViewDataType;
|
||||
use crate::entities::workspace::gen_workspace_id;
|
||||
use crate::revision::{AppRevision, ViewRevision, WorkspaceRevision};
|
||||
use crate::revision::{
|
||||
gen_app_id, gen_view_id, gen_workspace_id, AppRevision, ViewDataTypeRevision, ViewRevision, WorkspaceRevision,
|
||||
};
|
||||
use chrono::Utc;
|
||||
|
||||
pub fn create_default_workspace() -> WorkspaceRevision {
|
||||
@ -45,14 +43,13 @@ fn create_default_app(workspace_id: String, time: chrono::DateTime<Utc>) -> AppR
|
||||
fn create_default_view(app_id: String, time: chrono::DateTime<Utc>) -> ViewRevision {
|
||||
let view_id = gen_view_id();
|
||||
let name = "Read me".to_string();
|
||||
let data_type = ViewDataType::TextBlock;
|
||||
|
||||
ViewRevision {
|
||||
id: view_id,
|
||||
belong_to_id: app_id,
|
||||
name,
|
||||
desc: "".to_string(),
|
||||
data_type,
|
||||
data_type: ViewDataTypeRevision::TextBlock,
|
||||
version: 0,
|
||||
belongings: vec![],
|
||||
modified_time: time.timestamp(),
|
||||
|
@ -8,7 +8,6 @@ use crate::{
|
||||
},
|
||||
errors::{CollaborateError, CollaborateResult},
|
||||
};
|
||||
|
||||
use flowy_folder_data_model::revision::{AppRevision, TrashRevision, ViewRevision, WorkspaceRevision};
|
||||
use lib_infra::util::move_vec_element;
|
||||
use lib_ot::core::*;
|
||||
@ -724,7 +723,7 @@ mod tests {
|
||||
"name": "🚽 my first trash",
|
||||
"modified_time": 0,
|
||||
"create_time": 0,
|
||||
"ty": "Unknown"
|
||||
"ty": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user