mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-11-10 10:18:57 +03:00
chore: rename flowy-folder structs
This commit is contained in:
parent
0ecff26636
commit
193527e043
@ -67,7 +67,7 @@ void _resolveHomeDeps(GetIt getIt) {
|
||||
|
||||
// share
|
||||
getIt.registerLazySingleton<ShareService>(() => ShareService());
|
||||
getIt.registerFactoryParam<DocShareBloc, View, void>(
|
||||
getIt.registerFactoryParam<DocShareBloc, ViewPB, void>(
|
||||
(view, _) => DocShareBloc(view: view, service: getIt<ShareService>()));
|
||||
}
|
||||
|
||||
@ -76,12 +76,12 @@ void _resolveFolderDeps(GetIt getIt) {
|
||||
getIt.registerFactoryParam<WorkspaceListener, UserProfile, String>(
|
||||
(user, workspaceId) => WorkspaceListener(user: user, workspaceId: workspaceId));
|
||||
|
||||
// View
|
||||
getIt.registerFactoryParam<ViewListener, View, void>(
|
||||
// ViewPB
|
||||
getIt.registerFactoryParam<ViewListener, ViewPB, void>(
|
||||
(view, _) => ViewListener(view: view),
|
||||
);
|
||||
|
||||
getIt.registerFactoryParam<ViewBloc, View, void>(
|
||||
getIt.registerFactoryParam<ViewBloc, ViewPB, void>(
|
||||
(view, _) => ViewBloc(
|
||||
view: view,
|
||||
service: ViewService(),
|
||||
@ -101,8 +101,8 @@ void _resolveFolderDeps(GetIt getIt) {
|
||||
(user, _) => MenuUserBloc(user),
|
||||
);
|
||||
|
||||
// App
|
||||
getIt.registerFactoryParam<AppBloc, App, void>(
|
||||
// AppPB
|
||||
getIt.registerFactoryParam<AppBloc, AppPB, void>(
|
||||
(app, _) => AppBloc(
|
||||
app: app,
|
||||
appService: AppService(appId: app.id),
|
||||
@ -123,7 +123,7 @@ void _resolveFolderDeps(GetIt getIt) {
|
||||
|
||||
void _resolveDocDeps(GetIt getIt) {
|
||||
// Doc
|
||||
getIt.registerFactoryParam<DocumentBloc, View, void>(
|
||||
getIt.registerFactoryParam<DocumentBloc, ViewPB, void>(
|
||||
(view, _) => DocumentBloc(
|
||||
view: view,
|
||||
service: DocumentService(),
|
||||
@ -135,7 +135,7 @@ void _resolveDocDeps(GetIt getIt) {
|
||||
|
||||
void _resolveGridDeps(GetIt getIt) {
|
||||
// GridPB
|
||||
getIt.registerFactoryParam<GridBloc, View, void>(
|
||||
getIt.registerFactoryParam<GridBloc, ViewPB, void>(
|
||||
(view, _) => GridBloc(view: view),
|
||||
);
|
||||
|
||||
|
@ -75,8 +75,8 @@ class UserListener {
|
||||
}
|
||||
}
|
||||
|
||||
typedef WorkspaceListNotifyValue = Either<List<Workspace>, FlowyError>;
|
||||
typedef WorkspaceSettingNotifyValue = Either<CurrentWorkspaceSetting, FlowyError>;
|
||||
typedef WorkspaceListNotifyValue = Either<List<WorkspacePB>, FlowyError>;
|
||||
typedef WorkspaceSettingNotifyValue = Either<CurrentWorkspaceSettingPB, FlowyError>;
|
||||
|
||||
class UserWorkspaceListener {
|
||||
PublishNotifier<AuthNotifyValue>? _authNotifier = PublishNotifier();
|
||||
@ -119,13 +119,13 @@ class UserWorkspaceListener {
|
||||
case FolderNotification.UserDeleteWorkspace:
|
||||
case FolderNotification.WorkspaceListUpdated:
|
||||
result.fold(
|
||||
(payload) => _workspacesChangedNotifier?.value = left(RepeatedWorkspace.fromBuffer(payload).items),
|
||||
(payload) => _workspacesChangedNotifier?.value = left(RepeatedWorkspacePB.fromBuffer(payload).items),
|
||||
(error) => _workspacesChangedNotifier?.value = right(error),
|
||||
);
|
||||
break;
|
||||
case FolderNotification.WorkspaceSetting:
|
||||
result.fold(
|
||||
(payload) => _settingChangedNotifier?.value = left(CurrentWorkspaceSetting.fromBuffer(payload)),
|
||||
(payload) => _settingChangedNotifier?.value = left(CurrentWorkspaceSettingPB.fromBuffer(payload)),
|
||||
(error) => _settingChangedNotifier?.value = right(error),
|
||||
);
|
||||
break;
|
||||
|
@ -49,8 +49,8 @@ class UserService {
|
||||
return UserEventInitUser().send();
|
||||
}
|
||||
|
||||
Future<Either<List<Workspace>, FlowyError>> getWorkspaces() {
|
||||
final request = WorkspaceId.create();
|
||||
Future<Either<List<WorkspacePB>, FlowyError>> getWorkspaces() {
|
||||
final request = WorkspaceIdPB.create();
|
||||
|
||||
return FolderEventReadWorkspaces(request).send().then((result) {
|
||||
return result.fold(
|
||||
@ -60,8 +60,8 @@ class UserService {
|
||||
});
|
||||
}
|
||||
|
||||
Future<Either<Workspace, FlowyError>> openWorkspace(String workspaceId) {
|
||||
final request = WorkspaceId.create()..value = workspaceId;
|
||||
Future<Either<WorkspacePB, FlowyError>> openWorkspace(String workspaceId) {
|
||||
final request = WorkspaceIdPB.create()..value = workspaceId;
|
||||
return FolderEventOpenWorkspace(request).send().then((result) {
|
||||
return result.fold(
|
||||
(workspace) => left(workspace),
|
||||
@ -70,8 +70,8 @@ class UserService {
|
||||
});
|
||||
}
|
||||
|
||||
Future<Either<Workspace, FlowyError>> createWorkspace(String name, String desc) {
|
||||
final request = CreateWorkspacePayload.create()
|
||||
Future<Either<WorkspacePB, FlowyError>> createWorkspace(String name, String desc) {
|
||||
final request = CreateWorkspacePayloadPB.create()
|
||||
..name = name
|
||||
..desc = desc;
|
||||
return FolderEventCreateWorkspace(request).send().then((result) {
|
||||
|
@ -28,7 +28,7 @@ class AuthRouter {
|
||||
);
|
||||
}
|
||||
|
||||
void pushHomeScreen(BuildContext context, UserProfile profile, CurrentWorkspaceSetting workspaceSetting) {
|
||||
void pushHomeScreen(BuildContext context, UserProfile profile, CurrentWorkspaceSettingPB workspaceSetting) {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRoutes.fade(() => HomeScreen(profile, workspaceSetting), RouteDurations.slow.inMilliseconds * .001),
|
||||
@ -49,7 +49,7 @@ class SplashRoute {
|
||||
pushHomeScreen(context, userProfile, workspaceId);
|
||||
}
|
||||
|
||||
void pushHomeScreen(BuildContext context, UserProfile userProfile, CurrentWorkspaceSetting workspaceSetting) {
|
||||
void pushHomeScreen(BuildContext context, UserProfile userProfile, CurrentWorkspaceSettingPB workspaceSetting) {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRoutes.fade(() => HomeScreen(userProfile, workspaceSetting), RouteDurations.slow.inMilliseconds * .001),
|
||||
|
@ -117,7 +117,7 @@ class _SkipLogInScreenState extends State<SkipLogInScreen> {
|
||||
void _openCurrentWorkspace(
|
||||
BuildContext context,
|
||||
UserProfile user,
|
||||
dartz.Either<CurrentWorkspaceSetting, FlowyError> workspacesOrError,
|
||||
dartz.Either<CurrentWorkspaceSettingPB, FlowyError> workspacesOrError,
|
||||
) {
|
||||
workspacesOrError.fold(
|
||||
(workspaceSetting) {
|
||||
|
@ -65,7 +65,7 @@ class WelcomeScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _renderList(List<Workspace> workspaces) {
|
||||
Widget _renderList(List<WorkspacePB> workspaces) {
|
||||
return Expanded(
|
||||
child: StyledListView(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
@ -80,7 +80,7 @@ class WelcomeScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
void _handleOnPress(BuildContext context, Workspace workspace) {
|
||||
void _handleOnPress(BuildContext context, WorkspacePB workspace) {
|
||||
context.read<WelcomeBloc>().add(WelcomeEvent.openWorkspace(workspace));
|
||||
|
||||
Navigator.of(context).pop(workspace.id);
|
||||
@ -88,8 +88,8 @@ class WelcomeScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
class WorkspaceItem extends StatelessWidget {
|
||||
final Workspace workspace;
|
||||
final void Function(Workspace workspace) onPressed;
|
||||
final WorkspacePB workspace;
|
||||
final void Function(WorkspacePB workspace) onPressed;
|
||||
const WorkspaceItem({Key? key, required this.workspace, required this.onPressed}) : super(key: key);
|
||||
|
||||
@override
|
||||
|
@ -18,7 +18,7 @@ import 'package:dartz/dartz.dart';
|
||||
part 'app_bloc.freezed.dart';
|
||||
|
||||
class AppBloc extends Bloc<AppEvent, AppState> {
|
||||
final App app;
|
||||
final AppPB app;
|
||||
final AppService appService;
|
||||
final AppListener appListener;
|
||||
|
||||
@ -103,7 +103,7 @@ class AppBloc extends Bloc<AppEvent, AppState> {
|
||||
return super.close();
|
||||
}
|
||||
|
||||
Future<void> _didReceiveViewUpdated(List<View> views, Emitter<AppState> emit) async {
|
||||
Future<void> _didReceiveViewUpdated(List<ViewPB> views, Emitter<AppState> emit) async {
|
||||
final latestCreatedView = state.latestCreatedView;
|
||||
AppState newState = state.copyWith(views: views);
|
||||
if (latestCreatedView != null) {
|
||||
@ -139,20 +139,20 @@ class AppEvent with _$AppEvent {
|
||||
) = CreateView;
|
||||
const factory AppEvent.delete() = Delete;
|
||||
const factory AppEvent.rename(String newName) = Rename;
|
||||
const factory AppEvent.didReceiveViewUpdated(List<View> views) = ReceiveViews;
|
||||
const factory AppEvent.appDidUpdate(App app) = AppDidUpdate;
|
||||
const factory AppEvent.didReceiveViewUpdated(List<ViewPB> views) = ReceiveViews;
|
||||
const factory AppEvent.appDidUpdate(AppPB app) = AppDidUpdate;
|
||||
}
|
||||
|
||||
@freezed
|
||||
class AppState with _$AppState {
|
||||
const factory AppState({
|
||||
required App app,
|
||||
required List<View> views,
|
||||
View? latestCreatedView,
|
||||
required AppPB app,
|
||||
required List<ViewPB> views,
|
||||
ViewPB? latestCreatedView,
|
||||
required Either<Unit, FlowyError> successOrFailure,
|
||||
}) = _AppState;
|
||||
|
||||
factory AppState.initial(App app) => AppState(
|
||||
factory AppState.initial(AppPB app) => AppState(
|
||||
app: app,
|
||||
views: [],
|
||||
successOrFailure: left(unit),
|
||||
@ -161,8 +161,8 @@ class AppState with _$AppState {
|
||||
|
||||
class AppViewDataContext extends ChangeNotifier {
|
||||
final String appId;
|
||||
final ValueNotifier<List<View>> _viewsNotifier = ValueNotifier([]);
|
||||
final ValueNotifier<View?> _selectedViewNotifier = ValueNotifier(null);
|
||||
final ValueNotifier<List<ViewPB>> _viewsNotifier = ValueNotifier([]);
|
||||
final ValueNotifier<ViewPB?> _selectedViewNotifier = ValueNotifier(null);
|
||||
VoidCallback? _menuSharedStateListener;
|
||||
ExpandableController expandController = ExpandableController(initialExpanded: false);
|
||||
|
||||
@ -173,7 +173,7 @@ class AppViewDataContext extends ChangeNotifier {
|
||||
});
|
||||
}
|
||||
|
||||
VoidCallback addSelectedViewChangeListener(void Function(View?) callback) {
|
||||
VoidCallback addSelectedViewChangeListener(void Function(ViewPB?) callback) {
|
||||
listener() {
|
||||
callback(_selectedViewNotifier.value);
|
||||
}
|
||||
@ -186,7 +186,7 @@ class AppViewDataContext extends ChangeNotifier {
|
||||
_selectedViewNotifier.removeListener(listener);
|
||||
}
|
||||
|
||||
void _setLatestView(View? view) {
|
||||
void _setLatestView(ViewPB? view) {
|
||||
view?.freeze();
|
||||
|
||||
if (_selectedViewNotifier.value != view) {
|
||||
@ -196,9 +196,9 @@ class AppViewDataContext extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
View? get selectedView => _selectedViewNotifier.value;
|
||||
ViewPB? get selectedView => _selectedViewNotifier.value;
|
||||
|
||||
set views(List<View> views) {
|
||||
set views(List<ViewPB> views) {
|
||||
if (_viewsNotifier.value != views) {
|
||||
_viewsNotifier.value = views;
|
||||
_expandIfNeed();
|
||||
@ -206,9 +206,9 @@ class AppViewDataContext extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
UnmodifiableListView<View> get views => UnmodifiableListView(_viewsNotifier.value);
|
||||
UnmodifiableListView<ViewPB> get views => UnmodifiableListView(_viewsNotifier.value);
|
||||
|
||||
VoidCallback addViewsChangeListener(void Function(UnmodifiableListView<View>) callback) {
|
||||
VoidCallback addViewsChangeListener(void Function(UnmodifiableListView<ViewPB>) callback) {
|
||||
listener() {
|
||||
callback(views);
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ 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';
|
||||
|
||||
typedef AppDidUpdateCallback = void Function(App app);
|
||||
typedef ViewsDidChangeCallback = void Function(Either<List<View>, FlowyError> viewsOrFailed);
|
||||
typedef AppDidUpdateCallback = void Function(AppPB app);
|
||||
typedef ViewsDidChangeCallback = void Function(Either<List<ViewPB>, FlowyError> viewsOrFailed);
|
||||
|
||||
class AppListener {
|
||||
StreamSubscription<SubscribeObject>? _subscription;
|
||||
@ -37,7 +37,7 @@ class AppListener {
|
||||
if (_viewsChanged != null) {
|
||||
result.fold(
|
||||
(payload) {
|
||||
final repeatedView = RepeatedView.fromBuffer(payload);
|
||||
final repeatedView = RepeatedViewPB.fromBuffer(payload);
|
||||
_viewsChanged!(left(repeatedView.items));
|
||||
},
|
||||
(error) => _viewsChanged!(right(error)),
|
||||
@ -48,7 +48,7 @@ class AppListener {
|
||||
if (_updated != null) {
|
||||
result.fold(
|
||||
(payload) {
|
||||
final app = App.fromBuffer(payload);
|
||||
final app = AppPB.fromBuffer(payload);
|
||||
_updated!(app);
|
||||
},
|
||||
(error) => Log.error(error),
|
||||
|
@ -14,20 +14,20 @@ class AppService {
|
||||
required this.appId,
|
||||
});
|
||||
|
||||
Future<Either<App, FlowyError>> getAppDesc({required String appId}) {
|
||||
final payload = AppId.create()..value = appId;
|
||||
Future<Either<AppPB, FlowyError>> getAppDesc({required String appId}) {
|
||||
final payload = AppIdPB.create()..value = appId;
|
||||
|
||||
return FolderEventReadApp(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<View, FlowyError>> createView({
|
||||
Future<Either<ViewPB, FlowyError>> createView({
|
||||
required String appId,
|
||||
required String name,
|
||||
required String desc,
|
||||
required PluginDataType dataType,
|
||||
required PluginType pluginType,
|
||||
}) {
|
||||
final payload = CreateViewPayload.create()
|
||||
final payload = CreateViewPayloadPB.create()
|
||||
..belongToId = appId
|
||||
..name = name
|
||||
..desc = desc
|
||||
@ -37,8 +37,8 @@ class AppService {
|
||||
return FolderEventCreateView(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<List<View>, FlowyError>> getViews({required String appId}) {
|
||||
final payload = AppId.create()..value = appId;
|
||||
Future<Either<List<ViewPB>, FlowyError>> getViews({required String appId}) {
|
||||
final payload = AppIdPB.create()..value = appId;
|
||||
|
||||
return FolderEventReadApp(payload).send().then((result) {
|
||||
return result.fold(
|
||||
@ -49,12 +49,12 @@ class AppService {
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> delete({required String appId}) {
|
||||
final request = AppId.create()..value = appId;
|
||||
final request = AppIdPB.create()..value = appId;
|
||||
return FolderEventDeleteApp(request).send();
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> updateApp({required String appId, String? name}) {
|
||||
UpdateAppPayload payload = UpdateAppPayload.create()..appId = appId;
|
||||
UpdateAppPayloadPB payload = UpdateAppPayloadPB.create()..appId = appId;
|
||||
|
||||
if (name != null) {
|
||||
payload.name = name;
|
||||
@ -67,7 +67,7 @@ class AppService {
|
||||
required int fromIndex,
|
||||
required int toIndex,
|
||||
}) {
|
||||
final payload = MoveFolderItemPayload.create()
|
||||
final payload = MoveFolderItemPayloadPB.create()
|
||||
..itemId = viewId
|
||||
..from = fromIndex
|
||||
..to = toIndex
|
||||
|
@ -17,7 +17,7 @@ part 'doc_bloc.freezed.dart';
|
||||
typedef FlutterQuillDocument = Document;
|
||||
|
||||
class DocumentBloc extends Bloc<DocumentEvent, DocumentState> {
|
||||
final View view;
|
||||
final ViewPB view;
|
||||
final DocumentService service;
|
||||
|
||||
final ViewListener listener;
|
||||
|
@ -9,7 +9,7 @@ class DocumentService {
|
||||
Future<Either<TextBlockDeltaPB, FlowyError>> openDocument({
|
||||
required String docId,
|
||||
}) async {
|
||||
await FolderEventSetLatestView(ViewId(value: docId)).send();
|
||||
await FolderEventSetLatestView(ViewIdPB(value: docId)).send();
|
||||
|
||||
final payload = TextBlockIdPB(value: docId);
|
||||
return TextBlockEventGetBlockData(payload).send();
|
||||
@ -23,7 +23,7 @@ class DocumentService {
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> closeDocument({required String docId}) {
|
||||
final request = ViewId(value: docId);
|
||||
final request = ViewIdPB(value: docId);
|
||||
return FolderEventCloseView(request).send();
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ part 'share_bloc.freezed.dart';
|
||||
|
||||
class DocShareBloc extends Bloc<DocShareEvent, DocShareState> {
|
||||
ShareService service;
|
||||
View view;
|
||||
ViewPB view;
|
||||
DocShareBloc({required this.view, required this.service}) : super(const DocShareState.initial()) {
|
||||
on<DocShareEvent>((event, emit) async {
|
||||
await event.map(
|
||||
|
@ -30,7 +30,7 @@ class GridBloc extends Bloc<GridEvent, GridState> {
|
||||
return rows;
|
||||
}
|
||||
|
||||
GridBloc({required View view})
|
||||
GridBloc({required ViewPB view})
|
||||
: gridId = view.id,
|
||||
_blocks = LinkedHashMap.identity(),
|
||||
_gridService = GridService(gridId: view.id),
|
||||
|
@ -20,7 +20,7 @@ class GridService {
|
||||
});
|
||||
|
||||
Future<Either<GridPB, FlowyError>> loadGrid() async {
|
||||
await FolderEventSetLatestView(ViewId(value: gridId)).send();
|
||||
await FolderEventSetLatestView(ViewIdPB(value: gridId)).send();
|
||||
|
||||
final payload = GridIdPB(value: gridId);
|
||||
return GridEventGetGrid(payload).send();
|
||||
@ -40,7 +40,7 @@ class GridService {
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> closeGrid() {
|
||||
final request = ViewId(value: gridId);
|
||||
final request = ViewIdPB(value: gridId);
|
||||
return FolderEventCloseView(request).send();
|
||||
}
|
||||
}
|
||||
|
@ -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/workspace.pb.dart' show CurrentWorkspaceSetting;
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart' show CurrentWorkspaceSettingPB;
|
||||
import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
@ -13,7 +13,7 @@ part 'home_bloc.freezed.dart';
|
||||
class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
||||
final UserWorkspaceListener _listener;
|
||||
|
||||
HomeBloc(UserProfile user, CurrentWorkspaceSetting workspaceSetting)
|
||||
HomeBloc(UserProfile user, CurrentWorkspaceSettingPB workspaceSetting)
|
||||
: _listener = UserWorkspaceListener(userProfile: user),
|
||||
super(HomeState.initial(workspaceSetting)) {
|
||||
on<HomeEvent>((event, emit) async {
|
||||
@ -76,7 +76,7 @@ class HomeEvent with _$HomeEvent {
|
||||
const factory HomeEvent.forceCollapse(bool forceCollapse) = _ForceCollapse;
|
||||
const factory HomeEvent.setEditPannel(EditPannelContext editContext) = _ShowEditPannel;
|
||||
const factory HomeEvent.dismissEditPannel() = _DismissEditPannel;
|
||||
const factory HomeEvent.didReceiveWorkspaceSetting(CurrentWorkspaceSetting setting) = _DidReceiveWorkspaceSetting;
|
||||
const factory HomeEvent.didReceiveWorkspaceSetting(CurrentWorkspaceSettingPB setting) = _DidReceiveWorkspaceSetting;
|
||||
const factory HomeEvent.unauthorized(String msg) = _Unauthorized;
|
||||
const factory HomeEvent.collapseMenu() = _CollapseMenu;
|
||||
}
|
||||
@ -87,12 +87,12 @@ class HomeState with _$HomeState {
|
||||
required bool isLoading,
|
||||
required bool forceCollapse,
|
||||
required Option<EditPannelContext> pannelContext,
|
||||
required CurrentWorkspaceSetting workspaceSetting,
|
||||
required CurrentWorkspaceSettingPB workspaceSetting,
|
||||
required bool unauthorized,
|
||||
required bool isMenuCollapsed,
|
||||
}) = _HomeState;
|
||||
|
||||
factory HomeState.initial(CurrentWorkspaceSetting workspaceSetting) => HomeState(
|
||||
factory HomeState.initial(CurrentWorkspaceSettingPB workspaceSetting) => HomeState(
|
||||
isLoading: false,
|
||||
forceCollapse: false,
|
||||
pannelContext: none(),
|
||||
|
@ -41,7 +41,7 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> {
|
||||
if (state.apps.length > value.fromIndex) {
|
||||
final app = state.apps[value.fromIndex];
|
||||
_workspaceService.moveApp(appId: app.id, fromIndex: value.fromIndex, toIndex: value.toIndex);
|
||||
final apps = List<App>.from(state.apps);
|
||||
final apps = List<AppPB>.from(state.apps);
|
||||
apps.insert(value.toIndex, apps.removeAt(value.fromIndex));
|
||||
emit(state.copyWith(apps: apps));
|
||||
}
|
||||
@ -79,7 +79,7 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> {
|
||||
));
|
||||
}
|
||||
|
||||
void _handleAppsOrFail(Either<List<App>, FlowyError> appsOrFail) {
|
||||
void _handleAppsOrFail(Either<List<AppPB>, FlowyError> appsOrFail) {
|
||||
appsOrFail.fold(
|
||||
(apps) => add(MenuEvent.didReceiveApps(left(apps))),
|
||||
(error) => add(MenuEvent.didReceiveApps(right(error))),
|
||||
@ -93,13 +93,13 @@ class MenuEvent with _$MenuEvent {
|
||||
const factory MenuEvent.openPage(Plugin plugin) = _OpenPage;
|
||||
const factory MenuEvent.createApp(String name, {String? desc}) = _CreateApp;
|
||||
const factory MenuEvent.moveApp(int fromIndex, int toIndex) = _MoveApp;
|
||||
const factory MenuEvent.didReceiveApps(Either<List<App>, FlowyError> appsOrFail) = _ReceiveApps;
|
||||
const factory MenuEvent.didReceiveApps(Either<List<AppPB>, FlowyError> appsOrFail) = _ReceiveApps;
|
||||
}
|
||||
|
||||
@freezed
|
||||
class MenuState with _$MenuState {
|
||||
const factory MenuState({
|
||||
required List<App> apps,
|
||||
required List<AppPB> apps,
|
||||
required Either<Unit, FlowyError> successOrFailure,
|
||||
required Plugin plugin,
|
||||
}) = _MenuState;
|
||||
|
@ -65,7 +65,7 @@ class MenuUserBloc extends Bloc<MenuUserEvent, MenuUserState> {
|
||||
);
|
||||
}
|
||||
|
||||
void _workspaceListUpdated(Either<List<Workspace>, FlowyError> workspacesOrFailed) {
|
||||
void _workspaceListUpdated(Either<List<WorkspacePB>, FlowyError> workspacesOrFailed) {
|
||||
// Do nothing by now
|
||||
}
|
||||
}
|
||||
@ -82,7 +82,7 @@ class MenuUserEvent with _$MenuUserEvent {
|
||||
class MenuUserState with _$MenuUserState {
|
||||
const factory MenuUserState({
|
||||
required UserProfile userProfile,
|
||||
required Option<List<Workspace>> workspaces,
|
||||
required Option<List<WorkspacePB>> workspaces,
|
||||
required Either<Unit, String> successOrFailure,
|
||||
}) = _MenuUserState;
|
||||
|
||||
|
@ -62,7 +62,7 @@ class ViewSectionBloc extends Bloc<ViewSectionEvent, ViewSectionState> {
|
||||
Future<void> _moveView(_MoveView value, Emitter<ViewSectionState> emit) async {
|
||||
if (value.fromIndex < state.views.length) {
|
||||
final viewId = state.views[value.fromIndex].id;
|
||||
final views = List<View>.from(state.views);
|
||||
final views = List<ViewPB>.from(state.views);
|
||||
views.insert(value.toIndex, views.removeAt(value.fromIndex));
|
||||
emit(state.copyWith(views: views));
|
||||
|
||||
@ -92,16 +92,16 @@ class ViewSectionBloc extends Bloc<ViewSectionEvent, ViewSectionState> {
|
||||
@freezed
|
||||
class ViewSectionEvent with _$ViewSectionEvent {
|
||||
const factory ViewSectionEvent.initial() = _Initial;
|
||||
const factory ViewSectionEvent.setSelectedView(View? view) = _SetSelectedView;
|
||||
const factory ViewSectionEvent.setSelectedView(ViewPB? view) = _SetSelectedView;
|
||||
const factory ViewSectionEvent.moveView(int fromIndex, int toIndex) = _MoveView;
|
||||
const factory ViewSectionEvent.didReceiveViewUpdated(List<View> views) = _DidReceiveViewUpdated;
|
||||
const factory ViewSectionEvent.didReceiveViewUpdated(List<ViewPB> views) = _DidReceiveViewUpdated;
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ViewSectionState with _$ViewSectionState {
|
||||
const factory ViewSectionState({
|
||||
required List<View> views,
|
||||
View? selectedView,
|
||||
required List<ViewPB> views,
|
||||
ViewPB? selectedView,
|
||||
}) = _ViewSectionState;
|
||||
|
||||
factory ViewSectionState.initial(AppViewDataContext appViewData) => ViewSectionState(
|
||||
|
@ -45,7 +45,7 @@ class TrashBloc extends Bloc<TrashEvent, TrashState> {
|
||||
));
|
||||
}
|
||||
|
||||
void _listenTrashUpdated(Either<List<Trash>, FlowyError> trashOrFailed) {
|
||||
void _listenTrashUpdated(Either<List<TrashPB>, FlowyError> trashOrFailed) {
|
||||
trashOrFailed.fold(
|
||||
(trash) {
|
||||
add(TrashEvent.didReceiveTrash(trash));
|
||||
@ -66,9 +66,9 @@ class TrashBloc extends Bloc<TrashEvent, TrashState> {
|
||||
@freezed
|
||||
class TrashEvent with _$TrashEvent {
|
||||
const factory TrashEvent.initial() = Initial;
|
||||
const factory TrashEvent.didReceiveTrash(List<Trash> trash) = ReceiveTrash;
|
||||
const factory TrashEvent.didReceiveTrash(List<TrashPB> trash) = ReceiveTrash;
|
||||
const factory TrashEvent.putback(String trashId) = Putback;
|
||||
const factory TrashEvent.delete(Trash trash) = Delete;
|
||||
const factory TrashEvent.delete(TrashPB trash) = Delete;
|
||||
const factory TrashEvent.restoreAll() = RestoreAll;
|
||||
const factory TrashEvent.deleteAll() = DeleteAll;
|
||||
}
|
||||
@ -76,7 +76,7 @@ class TrashEvent with _$TrashEvent {
|
||||
@freezed
|
||||
class TrashState with _$TrashState {
|
||||
const factory TrashState({
|
||||
required List<Trash> objects,
|
||||
required List<TrashPB> objects,
|
||||
required Either<Unit, FlowyError> successOrFailure,
|
||||
}) = _TrashState;
|
||||
|
||||
|
@ -8,7 +8,7 @@ import 'package:flowy_sdk/protobuf/flowy-error/errors.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);
|
||||
typedef TrashUpdatedCallback = void Function(Either<List<TrashPB>, FlowyError> trashOrFailed);
|
||||
|
||||
class TrashListener {
|
||||
StreamSubscription<SubscribeObject>? _subscription;
|
||||
@ -27,7 +27,7 @@ class TrashListener {
|
||||
if (_trashUpdated != null) {
|
||||
result.fold(
|
||||
(payload) {
|
||||
final repeatedTrash = RepeatedTrash.fromBuffer(payload);
|
||||
final repeatedTrash = RepeatedTrashPB.fromBuffer(payload);
|
||||
_trashUpdated!(left(repeatedTrash.items));
|
||||
},
|
||||
(error) => _trashUpdated!(right(error)),
|
||||
|
@ -5,24 +5,24 @@ import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/trash.pb.dart';
|
||||
|
||||
class TrashService {
|
||||
Future<Either<RepeatedTrash, FlowyError>> readTrash() {
|
||||
Future<Either<RepeatedTrashPB, FlowyError>> readTrash() {
|
||||
return FolderEventReadTrash().send();
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> putback(String trashId) {
|
||||
final id = TrashId.create()..id = trashId;
|
||||
final id = TrashIdPB.create()..id = trashId;
|
||||
|
||||
return FolderEventPutbackTrash(id).send();
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> deleteViews(List<Tuple2<String, TrashType>> trashList) {
|
||||
final items = trashList.map((trash) {
|
||||
return TrashId.create()
|
||||
return TrashIdPB.create()
|
||||
..id = trash.value1
|
||||
..ty = trash.value2;
|
||||
});
|
||||
|
||||
final ids = RepeatedTrashId(items: items);
|
||||
final ids = RepeatedTrashIdPB(items: items);
|
||||
return FolderEventDeleteTrash(ids).send();
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ part 'view_bloc.freezed.dart';
|
||||
class ViewBloc extends Bloc<ViewEvent, ViewState> {
|
||||
final ViewService service;
|
||||
final ViewListener listener;
|
||||
final View view;
|
||||
final ViewPB view;
|
||||
|
||||
ViewBloc({
|
||||
required this.view,
|
||||
@ -81,18 +81,18 @@ class ViewEvent with _$ViewEvent {
|
||||
const factory ViewEvent.rename(String newName) = Rename;
|
||||
const factory ViewEvent.delete() = Delete;
|
||||
const factory ViewEvent.duplicate() = Duplicate;
|
||||
const factory ViewEvent.viewDidUpdate(Either<View, FlowyError> result) = ViewDidUpdate;
|
||||
const factory ViewEvent.viewDidUpdate(Either<ViewPB, FlowyError> result) = ViewDidUpdate;
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ViewState with _$ViewState {
|
||||
const factory ViewState({
|
||||
required View view,
|
||||
required ViewPB view,
|
||||
required bool isEditing,
|
||||
required Either<Unit, FlowyError> successOrFailure,
|
||||
}) = _ViewState;
|
||||
|
||||
factory ViewState.init(View view) => ViewState(
|
||||
factory ViewState.init(ViewPB view) => ViewState(
|
||||
view: view,
|
||||
isEditing: false,
|
||||
successOrFailure: left(unit),
|
||||
|
@ -32,7 +32,7 @@ extension FlowyPluginExtension on FlowyPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
extension ViewExtension on View {
|
||||
extension ViewExtension on ViewPB {
|
||||
Widget renderThumbnail({Color? iconColor}) {
|
||||
String thumbnail = "file_icon";
|
||||
|
||||
|
@ -9,9 +9,9 @@ import 'package:flowy_sdk/protobuf/flowy-folder/dart_notification.pb.dart';
|
||||
import 'package:flowy_sdk/rust_stream.dart';
|
||||
import 'package:flowy_infra/notifier.dart';
|
||||
|
||||
typedef DeleteViewNotifyValue = Either<View, FlowyError>;
|
||||
typedef UpdateViewNotifiedValue = Either<View, FlowyError>;
|
||||
typedef RestoreViewNotifiedValue = Either<View, FlowyError>;
|
||||
typedef DeleteViewNotifyValue = Either<ViewPB, FlowyError>;
|
||||
typedef UpdateViewNotifiedValue = Either<ViewPB, FlowyError>;
|
||||
typedef RestoreViewNotifiedValue = Either<ViewPB, FlowyError>;
|
||||
|
||||
class ViewListener {
|
||||
StreamSubscription<SubscribeObject>? _subscription;
|
||||
@ -19,7 +19,7 @@ class ViewListener {
|
||||
final PublishNotifier<DeleteViewNotifyValue> _deletedNotifier = PublishNotifier();
|
||||
final PublishNotifier<RestoreViewNotifiedValue> _restoredNotifier = PublishNotifier();
|
||||
FolderNotificationParser? _parser;
|
||||
View view;
|
||||
ViewPB view;
|
||||
|
||||
ViewListener({
|
||||
required this.view,
|
||||
@ -62,19 +62,19 @@ class ViewListener {
|
||||
switch (ty) {
|
||||
case FolderNotification.ViewUpdated:
|
||||
result.fold(
|
||||
(payload) => _updatedViewNotifier.value = left(View.fromBuffer(payload)),
|
||||
(payload) => _updatedViewNotifier.value = left(ViewPB.fromBuffer(payload)),
|
||||
(error) => _updatedViewNotifier.value = right(error),
|
||||
);
|
||||
break;
|
||||
case FolderNotification.ViewDeleted:
|
||||
result.fold(
|
||||
(payload) => _deletedNotifier.value = left(View.fromBuffer(payload)),
|
||||
(payload) => _deletedNotifier.value = left(ViewPB.fromBuffer(payload)),
|
||||
(error) => _deletedNotifier.value = right(error),
|
||||
);
|
||||
break;
|
||||
case FolderNotification.ViewRestored:
|
||||
result.fold(
|
||||
(payload) => _restoredNotifier.value = left(View.fromBuffer(payload)),
|
||||
(payload) => _restoredNotifier.value = left(ViewPB.fromBuffer(payload)),
|
||||
(error) => _restoredNotifier.value = right(error),
|
||||
);
|
||||
break;
|
||||
|
@ -5,13 +5,13 @@ import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
|
||||
class ViewService {
|
||||
Future<Either<View, FlowyError>> readView({required String viewId}) {
|
||||
final request = ViewId(value: viewId);
|
||||
Future<Either<ViewPB, FlowyError>> readView({required String viewId}) {
|
||||
final request = ViewIdPB(value: viewId);
|
||||
return FolderEventReadView(request).send();
|
||||
}
|
||||
|
||||
Future<Either<View, FlowyError>> updateView({required String viewId, String? name, String? desc}) {
|
||||
final request = UpdateViewPayload.create()..viewId = viewId;
|
||||
Future<Either<ViewPB, FlowyError>> updateView({required String viewId, String? name, String? desc}) {
|
||||
final request = UpdateViewPayloadPB.create()..viewId = viewId;
|
||||
|
||||
if (name != null) {
|
||||
request.name = name;
|
||||
@ -25,12 +25,12 @@ class ViewService {
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> delete({required String viewId}) {
|
||||
final request = RepeatedViewId.create()..items.add(viewId);
|
||||
final request = RepeatedViewIdPB.create()..items.add(viewId);
|
||||
return FolderEventDeleteView(request).send();
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> duplicate({required String viewId}) {
|
||||
final request = ViewId(value: viewId);
|
||||
final request = ViewIdPB(value: viewId);
|
||||
return FolderEventDuplicateView(request).send();
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ class WelcomeBloc extends Bloc<WelcomeEvent, WelcomeState> {
|
||||
));
|
||||
}
|
||||
|
||||
Future<void> _openWorkspace(Workspace workspace, Emitter<WelcomeState> emit) async {
|
||||
Future<void> _openWorkspace(WorkspacePB workspace, Emitter<WelcomeState> emit) async {
|
||||
final result = await userService.openWorkspace(workspace.id);
|
||||
emit(result.fold(
|
||||
(workspaces) => state.copyWith(successOrFailure: left(unit)),
|
||||
@ -82,8 +82,8 @@ class WelcomeEvent with _$WelcomeEvent {
|
||||
const factory WelcomeEvent.initial() = Initial;
|
||||
// const factory WelcomeEvent.fetchWorkspaces() = FetchWorkspace;
|
||||
const factory WelcomeEvent.createWorkspace(String name, String desc) = CreateWorkspace;
|
||||
const factory WelcomeEvent.openWorkspace(Workspace workspace) = OpenWorkspace;
|
||||
const factory WelcomeEvent.workspacesReveived(Either<List<Workspace>, FlowyError> workspacesOrFail) =
|
||||
const factory WelcomeEvent.openWorkspace(WorkspacePB workspace) = OpenWorkspace;
|
||||
const factory WelcomeEvent.workspacesReveived(Either<List<WorkspacePB>, FlowyError> workspacesOrFail) =
|
||||
WorkspacesReceived;
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ class WelcomeEvent with _$WelcomeEvent {
|
||||
class WelcomeState with _$WelcomeState {
|
||||
const factory WelcomeState({
|
||||
required bool isLoading,
|
||||
required List<Workspace> workspaces,
|
||||
required List<WorkspacePB> workspaces,
|
||||
required Either<Unit, FlowyError> successOrFailure,
|
||||
}) = _WelcomeState;
|
||||
|
||||
|
@ -9,8 +9,8 @@ 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';
|
||||
|
||||
typedef AppListNotifyValue = Either<List<App>, FlowyError>;
|
||||
typedef WorkspaceNotifyValue = Either<Workspace, FlowyError>;
|
||||
typedef AppListNotifyValue = Either<List<AppPB>, FlowyError>;
|
||||
typedef WorkspaceNotifyValue = Either<WorkspacePB, FlowyError>;
|
||||
|
||||
class WorkspaceListener {
|
||||
PublishNotifier<AppListNotifyValue>? _appsChangedNotifier = PublishNotifier();
|
||||
@ -47,13 +47,13 @@ class WorkspaceListener {
|
||||
switch (ty) {
|
||||
case FolderNotification.WorkspaceUpdated:
|
||||
result.fold(
|
||||
(payload) => _workspaceUpdatedNotifier?.value = left(Workspace.fromBuffer(payload)),
|
||||
(payload) => _workspaceUpdatedNotifier?.value = left(WorkspacePB.fromBuffer(payload)),
|
||||
(error) => _workspaceUpdatedNotifier?.value = right(error),
|
||||
);
|
||||
break;
|
||||
case FolderNotification.WorkspaceAppsChanged:
|
||||
result.fold(
|
||||
(payload) => _appsChangedNotifier?.value = left(RepeatedApp.fromBuffer(payload).items),
|
||||
(payload) => _appsChangedNotifier?.value = left(RepeatedAppPB.fromBuffer(payload).items),
|
||||
(error) => _appsChangedNotifier?.value = right(error),
|
||||
);
|
||||
break;
|
||||
|
@ -5,7 +5,7 @@ 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/app.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart' show MoveFolderItemPayload, MoveFolderItemType;
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart' show MoveFolderItemPayloadPB, MoveFolderItemType;
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart';
|
||||
|
||||
import 'package:app_flowy/generated/locale_keys.g.dart';
|
||||
@ -15,16 +15,16 @@ class WorkspaceService {
|
||||
WorkspaceService({
|
||||
required this.workspaceId,
|
||||
});
|
||||
Future<Either<App, FlowyError>> createApp({required String name, required String desc}) {
|
||||
final payload = CreateAppPayload.create()
|
||||
Future<Either<AppPB, FlowyError>> createApp({required String name, required String desc}) {
|
||||
final payload = CreateAppPayloadPB.create()
|
||||
..name = name
|
||||
..workspaceId = workspaceId
|
||||
..desc = desc;
|
||||
return FolderEventCreateApp(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<Workspace, FlowyError>> getWorkspace() {
|
||||
final payload = WorkspaceId.create()..value = workspaceId;
|
||||
Future<Either<WorkspacePB, FlowyError>> getWorkspace() {
|
||||
final payload = WorkspaceIdPB.create()..value = workspaceId;
|
||||
return FolderEventReadWorkspaces(payload).send().then((result) {
|
||||
return result.fold(
|
||||
(workspaces) {
|
||||
@ -41,8 +41,8 @@ class WorkspaceService {
|
||||
});
|
||||
}
|
||||
|
||||
Future<Either<List<App>, FlowyError>> getApps() {
|
||||
final payload = WorkspaceId.create()..value = workspaceId;
|
||||
Future<Either<List<AppPB>, FlowyError>> getApps() {
|
||||
final payload = WorkspaceIdPB.create()..value = workspaceId;
|
||||
return FolderEventReadWorkspaceApps(payload).send().then((result) {
|
||||
return result.fold(
|
||||
(apps) => left(apps.items),
|
||||
@ -56,7 +56,7 @@ class WorkspaceService {
|
||||
required int fromIndex,
|
||||
required int toIndex,
|
||||
}) {
|
||||
final payload = MoveFolderItemPayload.create()
|
||||
final payload = MoveFolderItemPayloadPB.create()
|
||||
..itemId = appId
|
||||
..from = fromIndex
|
||||
..to = toIndex
|
||||
|
@ -19,7 +19,7 @@ import 'menu/menu.dart';
|
||||
|
||||
class HomeScreen extends StatefulWidget {
|
||||
final UserProfile user;
|
||||
final CurrentWorkspaceSetting workspaceSetting;
|
||||
final CurrentWorkspaceSettingPB workspaceSetting;
|
||||
const HomeScreen(this.user, this.workspaceSetting, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
@ -27,7 +27,7 @@ class HomeScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _HomeScreenState extends State<HomeScreen> {
|
||||
View? initialView;
|
||||
ViewPB? initialView;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -19,7 +19,7 @@ import 'add_button.dart';
|
||||
import 'right_click_action.dart';
|
||||
|
||||
class MenuAppHeader extends StatelessWidget {
|
||||
final App app;
|
||||
final AppPB app;
|
||||
const MenuAppHeader(
|
||||
this.app, {
|
||||
Key? key,
|
||||
@ -85,7 +85,7 @@ class MenuAppHeader extends StatelessWidget {
|
||||
anchorDirection: AnchorDirection.bottomWithCenterAligned,
|
||||
);
|
||||
},
|
||||
child: BlocSelector<AppBloc, AppState, App>(
|
||||
child: BlocSelector<AppBloc, AppState, AppPB>(
|
||||
selector: (state) => state.app,
|
||||
builder: (context, app) => FlowyText.medium(
|
||||
app.name,
|
||||
|
@ -10,7 +10,7 @@ import 'package:provider/provider.dart';
|
||||
import 'section/section.dart';
|
||||
|
||||
class MenuApp extends StatefulWidget {
|
||||
final App app;
|
||||
final AppPB app;
|
||||
const MenuApp(this.app, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
|
@ -21,8 +21,8 @@ import 'disclosure_action.dart';
|
||||
// ignore: must_be_immutable
|
||||
class ViewSectionItem extends StatelessWidget {
|
||||
final bool isSelected;
|
||||
final View view;
|
||||
final void Function(View) onSelected;
|
||||
final ViewPB view;
|
||||
final void Function(ViewPB) onSelected;
|
||||
|
||||
ViewSectionItem({
|
||||
Key? key,
|
||||
|
@ -33,7 +33,7 @@ import 'menu_user.dart';
|
||||
class HomeMenu extends StatelessWidget {
|
||||
final PublishNotifier<bool> _collapsedNotifier;
|
||||
final UserProfile user;
|
||||
final CurrentWorkspaceSetting workspaceSetting;
|
||||
final CurrentWorkspaceSettingPB workspaceSetting;
|
||||
|
||||
const HomeMenu({
|
||||
Key? key,
|
||||
@ -155,19 +155,19 @@ class HomeMenu extends StatelessWidget {
|
||||
}
|
||||
|
||||
class MenuSharedState {
|
||||
final ValueNotifier<View?> _latestOpenView = ValueNotifier<View?>(null);
|
||||
final ValueNotifier<ViewPB?> _latestOpenView = ValueNotifier<ViewPB?>(null);
|
||||
|
||||
MenuSharedState({View? view}) {
|
||||
MenuSharedState({ViewPB? view}) {
|
||||
_latestOpenView.value = view;
|
||||
}
|
||||
|
||||
View? get latestOpenView => _latestOpenView.value;
|
||||
ViewPB? get latestOpenView => _latestOpenView.value;
|
||||
|
||||
set latestOpenView(View? view) {
|
||||
set latestOpenView(ViewPB? view) {
|
||||
_latestOpenView.value = view;
|
||||
}
|
||||
|
||||
VoidCallback addLatestViewListener(void Function(View?) callback) {
|
||||
VoidCallback addLatestViewListener(void Function(ViewPB?) callback) {
|
||||
listener() {
|
||||
callback(_latestOpenView.value);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import 'src/board_page.dart';
|
||||
class BoardPluginBuilder implements PluginBuilder {
|
||||
@override
|
||||
Plugin build(dynamic data) {
|
||||
if (data is View) {
|
||||
if (data is ViewPB) {
|
||||
return BoardPlugin(pluginType: pluginType, view: data);
|
||||
} else {
|
||||
throw FlowyPluginException.invalidData;
|
||||
@ -32,11 +32,11 @@ class BoardPluginConfig implements PluginConfig {
|
||||
}
|
||||
|
||||
class BoardPlugin extends Plugin {
|
||||
final View _view;
|
||||
final ViewPB _view;
|
||||
final PluginType _pluginType;
|
||||
|
||||
BoardPlugin({
|
||||
required View view,
|
||||
required ViewPB view,
|
||||
required PluginType pluginType,
|
||||
}) : _pluginType = pluginType,
|
||||
_view = view;
|
||||
@ -52,8 +52,8 @@ class BoardPlugin extends Plugin {
|
||||
}
|
||||
|
||||
class GridPluginDisplay extends PluginDisplay {
|
||||
final View _view;
|
||||
GridPluginDisplay({required View view, Key? key}) : _view = view;
|
||||
final ViewPB _view;
|
||||
GridPluginDisplay({required ViewPB view, Key? key}) : _view = view;
|
||||
|
||||
@override
|
||||
Widget get leftBarItem => ViewLeftBarItem(view: _view);
|
||||
|
@ -4,9 +4,9 @@ import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BoardPage extends StatelessWidget {
|
||||
final View _view;
|
||||
final ViewPB _view;
|
||||
|
||||
const BoardPage({required View view, Key? key})
|
||||
const BoardPage({required ViewPB view, Key? key})
|
||||
: _view = view,
|
||||
super(key: key);
|
||||
|
||||
|
@ -36,7 +36,7 @@ export './src/widget/toolbar/toolbar_icon_button.dart';
|
||||
class DocumentPluginBuilder extends PluginBuilder {
|
||||
@override
|
||||
Plugin build(dynamic data) {
|
||||
if (data is View) {
|
||||
if (data is ViewPB) {
|
||||
return DocumentPlugin(pluginType: pluginType, view: data);
|
||||
} else {
|
||||
throw FlowyPluginException.invalidData;
|
||||
@ -54,11 +54,11 @@ class DocumentPluginBuilder extends PluginBuilder {
|
||||
}
|
||||
|
||||
class DocumentPlugin implements Plugin {
|
||||
late View _view;
|
||||
late ViewPB _view;
|
||||
ViewListener? _listener;
|
||||
late PluginType _pluginType;
|
||||
|
||||
DocumentPlugin({required PluginType pluginType, required View view, Key? key}) : _view = view {
|
||||
DocumentPlugin({required PluginType pluginType, required ViewPB view, Key? key}) : _view = view {
|
||||
_pluginType = pluginType;
|
||||
_listener = getIt<ViewListener>(param1: view);
|
||||
_listener?.start(onViewUpdated: (result) {
|
||||
@ -90,9 +90,9 @@ class DocumentPlugin implements Plugin {
|
||||
|
||||
class DocumentPluginDisplay extends PluginDisplay<int> with NavigationItem {
|
||||
final PublishNotifier<int> _displayNotifier = PublishNotifier<int>();
|
||||
final View _view;
|
||||
final ViewPB _view;
|
||||
|
||||
DocumentPluginDisplay({required View view, Key? key}) : _view = view;
|
||||
DocumentPluginDisplay({required ViewPB view, Key? key}) : _view = view;
|
||||
|
||||
@override
|
||||
Widget buildWidget() => DocumentPage(view: _view, key: ValueKey(_view.id));
|
||||
@ -111,7 +111,7 @@ class DocumentPluginDisplay extends PluginDisplay<int> with NavigationItem {
|
||||
}
|
||||
|
||||
class DocumentShareButton extends StatelessWidget {
|
||||
final View view;
|
||||
final ViewPB view;
|
||||
DocumentShareButton({Key? key, required this.view}) : super(key: ValueKey(view.hashCode));
|
||||
|
||||
@override
|
||||
|
@ -14,7 +14,7 @@ import 'styles.dart';
|
||||
import 'widget/banner.dart';
|
||||
|
||||
class DocumentPage extends StatefulWidget {
|
||||
final View view;
|
||||
final ViewPB view;
|
||||
|
||||
DocumentPage({Key? key, required this.view}) : super(key: ValueKey(view.id));
|
||||
|
||||
|
@ -11,7 +11,7 @@ import 'src/grid_page.dart';
|
||||
class GridPluginBuilder implements PluginBuilder {
|
||||
@override
|
||||
Plugin build(dynamic data) {
|
||||
if (data is View) {
|
||||
if (data is ViewPB) {
|
||||
return GridPlugin(pluginType: pluginType, view: data);
|
||||
} else {
|
||||
throw FlowyPluginException.invalidData;
|
||||
@ -34,11 +34,11 @@ class GridPluginConfig implements PluginConfig {
|
||||
}
|
||||
|
||||
class GridPlugin extends Plugin {
|
||||
final View _view;
|
||||
final ViewPB _view;
|
||||
final PluginType _pluginType;
|
||||
|
||||
GridPlugin({
|
||||
required View view,
|
||||
required ViewPB view,
|
||||
required PluginType pluginType,
|
||||
}) : _pluginType = pluginType,
|
||||
_view = view;
|
||||
@ -54,8 +54,8 @@ class GridPlugin extends Plugin {
|
||||
}
|
||||
|
||||
class GridPluginDisplay extends PluginDisplay {
|
||||
final View _view;
|
||||
GridPluginDisplay({required View view, Key? key}) : _view = view;
|
||||
final ViewPB _view;
|
||||
GridPluginDisplay({required ViewPB view, Key? key}) : _view = view;
|
||||
|
||||
@override
|
||||
Widget get leftBarItem => ViewLeftBarItem(view: _view);
|
||||
|
@ -19,7 +19,7 @@ import 'widgets/shortcuts.dart';
|
||||
import 'widgets/toolbar/grid_toolbar.dart';
|
||||
|
||||
class GridPage extends StatefulWidget {
|
||||
final View view;
|
||||
final ViewPB view;
|
||||
|
||||
GridPage({Key? key, required this.view}) : super(key: ValueKey(view.id));
|
||||
|
||||
|
@ -14,7 +14,7 @@ import 'sizes.dart';
|
||||
class TrashCell extends StatelessWidget {
|
||||
final VoidCallback onRestore;
|
||||
final VoidCallback onDelete;
|
||||
final Trash object;
|
||||
final TrashPB object;
|
||||
const TrashCell({required this.object, required this.onRestore, required this.onDelete, Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
|
@ -31,7 +31,7 @@ class TrashPluginBuilder extends PluginBuilder {
|
||||
}
|
||||
|
||||
@override
|
||||
String get menuName => "Trash";
|
||||
String get menuName => "TrashPB";
|
||||
|
||||
@override
|
||||
PluginType get pluginType => DefaultPlugin.trash.type();
|
||||
|
@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class ViewLeftBarItem extends StatefulWidget {
|
||||
final View view;
|
||||
final ViewPB view;
|
||||
|
||||
ViewLeftBarItem({required this.view, Key? key}) : super(key: ValueKey(view.hashCode));
|
||||
|
||||
@ -20,7 +20,7 @@ class _ViewLeftBarItemState extends State<ViewLeftBarItem> {
|
||||
final _focusNode = FocusNode();
|
||||
late ViewService _viewService;
|
||||
late ViewListener _viewListener;
|
||||
late View view;
|
||||
late ViewPB view;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -3,7 +3,7 @@ use crate::{
|
||||
app::{AppColorStyle, AppIdentify, AppName},
|
||||
workspace::WorkspaceIdentify,
|
||||
},
|
||||
entities::view::RepeatedView,
|
||||
entities::view::RepeatedViewPB,
|
||||
errors::ErrorCode,
|
||||
impl_def_and_def_mut,
|
||||
};
|
||||
@ -12,7 +12,7 @@ use flowy_folder_data_model::revision::AppRevision;
|
||||
use std::convert::TryInto;
|
||||
|
||||
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
|
||||
pub struct App {
|
||||
pub struct AppPB {
|
||||
#[pb(index = 1)]
|
||||
pub id: String,
|
||||
|
||||
@ -26,7 +26,7 @@ pub struct App {
|
||||
pub desc: String,
|
||||
|
||||
#[pb(index = 5)]
|
||||
pub belongings: RepeatedView,
|
||||
pub belongings: RepeatedViewPB,
|
||||
|
||||
#[pb(index = 6)]
|
||||
pub version: i64,
|
||||
@ -38,9 +38,9 @@ pub struct App {
|
||||
pub create_time: i64,
|
||||
}
|
||||
|
||||
impl std::convert::From<AppRevision> for App {
|
||||
impl std::convert::From<AppRevision> for AppPB {
|
||||
fn from(app_serde: AppRevision) -> Self {
|
||||
App {
|
||||
AppPB {
|
||||
id: app_serde.id,
|
||||
workspace_id: app_serde.workspace_id,
|
||||
name: app_serde.name,
|
||||
@ -53,21 +53,21 @@ impl std::convert::From<AppRevision> for App {
|
||||
}
|
||||
}
|
||||
#[derive(Eq, PartialEq, Debug, Default, ProtoBuf, Clone)]
|
||||
pub struct RepeatedApp {
|
||||
pub struct RepeatedAppPB {
|
||||
#[pb(index = 1)]
|
||||
pub items: Vec<App>,
|
||||
pub items: Vec<AppPB>,
|
||||
}
|
||||
|
||||
impl_def_and_def_mut!(RepeatedApp, App);
|
||||
impl_def_and_def_mut!(RepeatedAppPB, AppPB);
|
||||
|
||||
impl std::convert::From<Vec<AppRevision>> for RepeatedApp {
|
||||
impl std::convert::From<Vec<AppRevision>> for RepeatedAppPB {
|
||||
fn from(values: Vec<AppRevision>) -> Self {
|
||||
let items = values.into_iter().map(|value| value.into()).collect::<Vec<App>>();
|
||||
RepeatedApp { items }
|
||||
let items = values.into_iter().map(|value| value.into()).collect::<Vec<AppPB>>();
|
||||
RepeatedAppPB { items }
|
||||
}
|
||||
}
|
||||
#[derive(ProtoBuf, Default)]
|
||||
pub struct CreateAppPayload {
|
||||
pub struct CreateAppPayloadPB {
|
||||
#[pb(index = 1)]
|
||||
pub workspace_id: String,
|
||||
|
||||
@ -78,31 +78,24 @@ pub struct CreateAppPayload {
|
||||
pub desc: String,
|
||||
|
||||
#[pb(index = 4)]
|
||||
pub color_style: ColorStyle,
|
||||
pub color_style: ColorStylePB,
|
||||
}
|
||||
|
||||
#[derive(ProtoBuf, Default, Debug, Clone)]
|
||||
pub struct ColorStyle {
|
||||
pub struct ColorStylePB {
|
||||
#[pb(index = 1)]
|
||||
pub theme_color: String,
|
||||
}
|
||||
|
||||
#[derive(ProtoBuf, Default, Debug)]
|
||||
#[derive(Debug)]
|
||||
pub struct CreateAppParams {
|
||||
#[pb(index = 1)]
|
||||
pub workspace_id: String,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub name: String,
|
||||
|
||||
#[pb(index = 3)]
|
||||
pub desc: String,
|
||||
|
||||
#[pb(index = 4)]
|
||||
pub color_style: ColorStyle,
|
||||
pub color_style: ColorStylePB,
|
||||
}
|
||||
|
||||
impl TryInto<CreateAppParams> for CreateAppPayload {
|
||||
impl TryInto<CreateAppParams> for CreateAppPayloadPB {
|
||||
type Error = ErrorCode;
|
||||
|
||||
fn try_into(self) -> Result<CreateAppParams, Self::Error> {
|
||||
@ -119,21 +112,21 @@ impl TryInto<CreateAppParams> for CreateAppPayload {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<AppColorStyle> for ColorStyle {
|
||||
impl std::convert::From<AppColorStyle> for ColorStylePB {
|
||||
fn from(data: AppColorStyle) -> Self {
|
||||
ColorStyle {
|
||||
ColorStylePB {
|
||||
theme_color: data.theme_color,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(ProtoBuf, Default, Clone, Debug)]
|
||||
pub struct AppId {
|
||||
pub struct AppIdPB {
|
||||
#[pb(index = 1)]
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
impl AppId {
|
||||
impl AppIdPB {
|
||||
pub fn new(app_id: &str) -> Self {
|
||||
Self {
|
||||
value: app_id.to_string(),
|
||||
@ -142,7 +135,7 @@ impl AppId {
|
||||
}
|
||||
|
||||
#[derive(ProtoBuf, Default)]
|
||||
pub struct UpdateAppPayload {
|
||||
pub struct UpdateAppPayloadPB {
|
||||
#[pb(index = 1)]
|
||||
pub app_id: String,
|
||||
|
||||
@ -153,27 +146,22 @@ pub struct UpdateAppPayload {
|
||||
pub desc: Option<String>,
|
||||
|
||||
#[pb(index = 4, one_of)]
|
||||
pub color_style: Option<ColorStyle>,
|
||||
pub color_style: Option<ColorStylePB>,
|
||||
|
||||
#[pb(index = 5, one_of)]
|
||||
pub is_trash: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(ProtoBuf, Default, Clone, Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct UpdateAppParams {
|
||||
#[pb(index = 1)]
|
||||
pub app_id: String,
|
||||
|
||||
#[pb(index = 2, one_of)]
|
||||
pub name: Option<String>,
|
||||
|
||||
#[pb(index = 3, one_of)]
|
||||
pub desc: Option<String>,
|
||||
|
||||
#[pb(index = 4, one_of)]
|
||||
pub color_style: Option<ColorStyle>,
|
||||
pub color_style: Option<ColorStylePB>,
|
||||
|
||||
#[pb(index = 5, one_of)]
|
||||
pub is_trash: Option<bool>,
|
||||
}
|
||||
|
||||
@ -181,7 +169,10 @@ impl UpdateAppParams {
|
||||
pub fn new(app_id: &str) -> Self {
|
||||
Self {
|
||||
app_id: app_id.to_string(),
|
||||
..Default::default()
|
||||
name: None,
|
||||
desc: None,
|
||||
color_style: None,
|
||||
is_trash: None,
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,7 +192,7 @@ impl UpdateAppParams {
|
||||
}
|
||||
}
|
||||
|
||||
impl TryInto<UpdateAppParams> for UpdateAppPayload {
|
||||
impl TryInto<UpdateAppParams> for UpdateAppPayloadPB {
|
||||
type Error = ErrorCode;
|
||||
|
||||
fn try_into(self) -> Result<UpdateAppParams, Self::Error> {
|
||||
|
@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Formatter;
|
||||
|
||||
#[derive(Eq, PartialEq, ProtoBuf, Default, Debug, Clone)]
|
||||
pub struct Trash {
|
||||
pub struct TrashPB {
|
||||
#[pb(index = 1)]
|
||||
pub id: String,
|
||||
|
||||
@ -22,9 +22,9 @@ pub struct Trash {
|
||||
pub ty: TrashType,
|
||||
}
|
||||
|
||||
impl std::convert::From<TrashRevision> for Trash {
|
||||
impl std::convert::From<TrashRevision> for TrashPB {
|
||||
fn from(trash_rev: TrashRevision) -> Self {
|
||||
Trash {
|
||||
TrashPB {
|
||||
id: trash_rev.id,
|
||||
name: trash_rev.name,
|
||||
modified_time: trash_rev.modified_time,
|
||||
@ -34,8 +34,8 @@ impl std::convert::From<TrashRevision> for Trash {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<Trash> for TrashRevision {
|
||||
fn from(trash: Trash) -> Self {
|
||||
impl std::convert::From<TrashPB> for TrashRevision {
|
||||
fn from(trash: TrashPB) -> Self {
|
||||
TrashRevision {
|
||||
id: trash.id,
|
||||
name: trash.name,
|
||||
@ -46,16 +46,16 @@ impl std::convert::From<Trash> for TrashRevision {
|
||||
}
|
||||
}
|
||||
#[derive(PartialEq, Debug, Default, ProtoBuf, Clone)]
|
||||
pub struct RepeatedTrash {
|
||||
pub struct RepeatedTrashPB {
|
||||
#[pb(index = 1)]
|
||||
pub items: Vec<Trash>,
|
||||
pub items: Vec<TrashPB>,
|
||||
}
|
||||
|
||||
impl_def_and_def_mut!(RepeatedTrash, Trash);
|
||||
impl std::convert::From<Vec<TrashRevision>> for RepeatedTrash {
|
||||
impl_def_and_def_mut!(RepeatedTrashPB, TrashPB);
|
||||
impl std::convert::From<Vec<TrashRevision>> for RepeatedTrashPB {
|
||||
fn from(trash_revs: Vec<TrashRevision>) -> Self {
|
||||
let items: Vec<Trash> = trash_revs.into_iter().map(|trash_rev| trash_rev.into()).collect();
|
||||
RepeatedTrash { items }
|
||||
let items: Vec<TrashPB> = trash_revs.into_iter().map(|trash_rev| trash_rev.into()).collect();
|
||||
RepeatedTrashPB { items }
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,15 +106,15 @@ impl std::default::Default for TrashType {
|
||||
}
|
||||
|
||||
#[derive(PartialEq, ProtoBuf, Default, Debug, Clone)]
|
||||
pub struct RepeatedTrashId {
|
||||
pub struct RepeatedTrashIdPB {
|
||||
#[pb(index = 1)]
|
||||
pub items: Vec<TrashId>,
|
||||
pub items: Vec<TrashIdPB>,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub delete_all: bool,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for RepeatedTrashId {
|
||||
impl std::fmt::Display for RepeatedTrashIdPB {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_str(&format!(
|
||||
"{:?}",
|
||||
@ -123,35 +123,35 @@ impl std::fmt::Display for RepeatedTrashId {
|
||||
}
|
||||
}
|
||||
|
||||
impl RepeatedTrashId {
|
||||
pub fn all() -> RepeatedTrashId {
|
||||
RepeatedTrashId {
|
||||
impl RepeatedTrashIdPB {
|
||||
pub fn all() -> RepeatedTrashIdPB {
|
||||
RepeatedTrashIdPB {
|
||||
items: vec![],
|
||||
delete_all: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<Vec<TrashId>> for RepeatedTrashId {
|
||||
fn from(items: Vec<TrashId>) -> Self {
|
||||
RepeatedTrashId {
|
||||
impl std::convert::From<Vec<TrashIdPB>> for RepeatedTrashIdPB {
|
||||
fn from(items: Vec<TrashIdPB>) -> Self {
|
||||
RepeatedTrashIdPB {
|
||||
items,
|
||||
delete_all: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<Vec<TrashRevision>> for RepeatedTrashId {
|
||||
impl std::convert::From<Vec<TrashRevision>> for RepeatedTrashIdPB {
|
||||
fn from(trash: Vec<TrashRevision>) -> Self {
|
||||
let items = trash
|
||||
.into_iter()
|
||||
.map(|t| TrashId {
|
||||
.map(|t| TrashIdPB {
|
||||
id: t.id,
|
||||
ty: t.ty.into(),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
RepeatedTrashId {
|
||||
RepeatedTrashIdPB {
|
||||
items,
|
||||
delete_all: false,
|
||||
}
|
||||
@ -159,7 +159,7 @@ impl std::convert::From<Vec<TrashRevision>> for RepeatedTrashId {
|
||||
}
|
||||
|
||||
#[derive(PartialEq, ProtoBuf, Default, Debug, Clone)]
|
||||
pub struct TrashId {
|
||||
pub struct TrashIdPB {
|
||||
#[pb(index = 1)]
|
||||
pub id: String,
|
||||
|
||||
@ -167,15 +167,15 @@ pub struct TrashId {
|
||||
pub ty: TrashType,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for TrashId {
|
||||
impl std::fmt::Display for TrashIdPB {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_str(&format!("{:?}:{}", self.ty, self.id))
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<&TrashRevision> for TrashId {
|
||||
impl std::convert::From<&TrashRevision> for TrashIdPB {
|
||||
fn from(trash: &TrashRevision) -> Self {
|
||||
TrashId {
|
||||
TrashIdPB {
|
||||
id: trash.id.clone(),
|
||||
ty: trash.ty.clone().into(),
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ use flowy_folder_data_model::revision::{gen_view_id, ViewDataTypeRevision, ViewR
|
||||
use std::convert::TryInto;
|
||||
|
||||
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
|
||||
pub struct View {
|
||||
pub struct ViewPB {
|
||||
#[pb(index = 1)]
|
||||
pub id: String,
|
||||
|
||||
@ -34,9 +34,9 @@ pub struct View {
|
||||
pub plugin_type: i32,
|
||||
}
|
||||
|
||||
impl std::convert::From<ViewRevision> for View {
|
||||
impl std::convert::From<ViewRevision> for ViewPB {
|
||||
fn from(rev: ViewRevision) -> Self {
|
||||
View {
|
||||
ViewPB {
|
||||
id: rev.id,
|
||||
belong_to_id: rev.belong_to_id,
|
||||
name: rev.name,
|
||||
@ -79,27 +79,27 @@ impl std::convert::From<ViewDataType> for ViewDataTypeRevision {
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Debug, Default, ProtoBuf, Clone)]
|
||||
pub struct RepeatedView {
|
||||
pub struct RepeatedViewPB {
|
||||
#[pb(index = 1)]
|
||||
pub items: Vec<View>,
|
||||
pub items: Vec<ViewPB>,
|
||||
}
|
||||
|
||||
impl_def_and_def_mut!(RepeatedView, View);
|
||||
impl_def_and_def_mut!(RepeatedViewPB, ViewPB);
|
||||
|
||||
impl std::convert::From<Vec<ViewRevision>> for RepeatedView {
|
||||
impl std::convert::From<Vec<ViewRevision>> for RepeatedViewPB {
|
||||
fn from(values: Vec<ViewRevision>) -> Self {
|
||||
let items = values.into_iter().map(|value| value.into()).collect::<Vec<View>>();
|
||||
RepeatedView { items }
|
||||
let items = values.into_iter().map(|value| value.into()).collect::<Vec<ViewPB>>();
|
||||
RepeatedViewPB { items }
|
||||
}
|
||||
}
|
||||
#[derive(Default, ProtoBuf)]
|
||||
pub struct RepeatedViewId {
|
||||
pub struct RepeatedViewIdPB {
|
||||
#[pb(index = 1)]
|
||||
pub items: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, ProtoBuf)]
|
||||
pub struct CreateViewPayload {
|
||||
pub struct CreateViewPayloadPB {
|
||||
#[pb(index = 1)]
|
||||
pub belong_to_id: String,
|
||||
|
||||
@ -122,34 +122,19 @@ pub struct CreateViewPayload {
|
||||
pub data: Vec<u8>,
|
||||
}
|
||||
|
||||
#[derive(Default, ProtoBuf, Debug, Clone)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CreateViewParams {
|
||||
#[pb(index = 1)]
|
||||
pub belong_to_id: String,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub name: String,
|
||||
|
||||
#[pb(index = 3)]
|
||||
pub desc: String,
|
||||
|
||||
#[pb(index = 4)]
|
||||
pub thumbnail: String,
|
||||
|
||||
#[pb(index = 5)]
|
||||
pub data_type: ViewDataType,
|
||||
|
||||
#[pb(index = 6)]
|
||||
pub view_id: String,
|
||||
|
||||
#[pb(index = 7)]
|
||||
pub data: Vec<u8>,
|
||||
|
||||
#[pb(index = 8)]
|
||||
pub plugin_type: i32,
|
||||
}
|
||||
|
||||
impl TryInto<CreateViewParams> for CreateViewPayload {
|
||||
impl TryInto<CreateViewParams> for CreateViewPayloadPB {
|
||||
type Error = ErrorCode;
|
||||
|
||||
fn try_into(self) -> Result<CreateViewParams, Self::Error> {
|
||||
@ -175,20 +160,20 @@ impl TryInto<CreateViewParams> for CreateViewPayload {
|
||||
}
|
||||
|
||||
#[derive(Default, ProtoBuf, Clone, Debug)]
|
||||
pub struct ViewId {
|
||||
pub struct ViewIdPB {
|
||||
#[pb(index = 1)]
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
impl std::convert::From<&str> for ViewId {
|
||||
impl std::convert::From<&str> for ViewIdPB {
|
||||
fn from(value: &str) -> Self {
|
||||
ViewId {
|
||||
ViewIdPB {
|
||||
value: value.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Deref for ViewId {
|
||||
impl std::ops::Deref for ViewIdPB {
|
||||
type Target = str;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
@ -197,7 +182,7 @@ impl std::ops::Deref for ViewId {
|
||||
}
|
||||
|
||||
#[derive(Default, ProtoBuf)]
|
||||
pub struct UpdateViewPayload {
|
||||
pub struct UpdateViewPayloadPB {
|
||||
#[pb(index = 1)]
|
||||
pub view_id: String,
|
||||
|
||||
@ -211,22 +196,15 @@ pub struct UpdateViewPayload {
|
||||
pub thumbnail: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, ProtoBuf, Clone, Debug)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct UpdateViewParams {
|
||||
#[pb(index = 1)]
|
||||
pub view_id: String,
|
||||
|
||||
#[pb(index = 2, one_of)]
|
||||
pub name: Option<String>,
|
||||
|
||||
#[pb(index = 3, one_of)]
|
||||
pub desc: Option<String>,
|
||||
|
||||
#[pb(index = 4, one_of)]
|
||||
pub thumbnail: Option<String>,
|
||||
}
|
||||
|
||||
impl TryInto<UpdateViewParams> for UpdateViewPayload {
|
||||
impl TryInto<UpdateViewParams> for UpdateViewPayloadPB {
|
||||
type Error = ErrorCode;
|
||||
|
||||
fn try_into(self) -> Result<UpdateViewParams, Self::Error> {
|
||||
@ -269,7 +247,7 @@ impl std::default::Default for MoveFolderItemType {
|
||||
}
|
||||
|
||||
#[derive(Default, ProtoBuf)]
|
||||
pub struct MoveFolderItemPayload {
|
||||
pub struct MoveFolderItemPayloadPB {
|
||||
#[pb(index = 1)]
|
||||
pub item_id: String,
|
||||
|
||||
@ -290,7 +268,7 @@ pub struct MoveFolderItemParams {
|
||||
pub ty: MoveFolderItemType,
|
||||
}
|
||||
|
||||
impl TryInto<MoveFolderItemParams> for MoveFolderItemPayload {
|
||||
impl TryInto<MoveFolderItemParams> for MoveFolderItemPayloadPB {
|
||||
type Error = ErrorCode;
|
||||
|
||||
fn try_into(self) -> Result<MoveFolderItemParams, Self::Error> {
|
||||
|
@ -1,8 +1,8 @@
|
||||
use crate::entities::{RepeatedView, ViewDataType};
|
||||
use crate::entities::{RepeatedViewPB, ViewDataType};
|
||||
use flowy_derive::ProtoBuf;
|
||||
|
||||
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
|
||||
pub struct ViewInfo {
|
||||
pub struct ViewInfoPB {
|
||||
#[pb(index = 1)]
|
||||
pub id: String,
|
||||
|
||||
@ -19,7 +19,7 @@ pub struct ViewInfo {
|
||||
pub data_type: ViewDataType,
|
||||
|
||||
#[pb(index = 6)]
|
||||
pub belongings: RepeatedView,
|
||||
pub belongings: RepeatedViewPB,
|
||||
|
||||
#[pb(index = 7)]
|
||||
pub ext_data: String,
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
entities::parser::workspace::{WorkspaceDesc, WorkspaceIdentify, WorkspaceName},
|
||||
entities::{app::RepeatedApp, view::View},
|
||||
entities::{app::RepeatedAppPB, view::ViewPB},
|
||||
errors::*,
|
||||
impl_def_and_def_mut,
|
||||
};
|
||||
@ -9,7 +9,7 @@ use flowy_folder_data_model::revision::WorkspaceRevision;
|
||||
use std::convert::TryInto;
|
||||
|
||||
#[derive(Eq, PartialEq, ProtoBuf, Default, Debug, Clone)]
|
||||
pub struct Workspace {
|
||||
pub struct WorkspacePB {
|
||||
#[pb(index = 1)]
|
||||
pub id: String,
|
||||
|
||||
@ -20,7 +20,7 @@ pub struct Workspace {
|
||||
pub desc: String,
|
||||
|
||||
#[pb(index = 4)]
|
||||
pub apps: RepeatedApp,
|
||||
pub apps: RepeatedAppPB,
|
||||
|
||||
#[pb(index = 5)]
|
||||
pub modified_time: i64,
|
||||
@ -29,9 +29,9 @@ pub struct Workspace {
|
||||
pub create_time: i64,
|
||||
}
|
||||
|
||||
impl std::convert::From<WorkspaceRevision> for Workspace {
|
||||
impl std::convert::From<WorkspaceRevision> for WorkspacePB {
|
||||
fn from(workspace_serde: WorkspaceRevision) -> Self {
|
||||
Workspace {
|
||||
WorkspacePB {
|
||||
id: workspace_serde.id,
|
||||
name: workspace_serde.name,
|
||||
desc: workspace_serde.desc,
|
||||
@ -42,15 +42,15 @@ impl std::convert::From<WorkspaceRevision> for Workspace {
|
||||
}
|
||||
}
|
||||
#[derive(PartialEq, Debug, Default, ProtoBuf)]
|
||||
pub struct RepeatedWorkspace {
|
||||
pub struct RepeatedWorkspacePB {
|
||||
#[pb(index = 1)]
|
||||
pub items: Vec<Workspace>,
|
||||
pub items: Vec<WorkspacePB>,
|
||||
}
|
||||
|
||||
impl_def_and_def_mut!(RepeatedWorkspace, Workspace);
|
||||
impl_def_and_def_mut!(RepeatedWorkspacePB, WorkspacePB);
|
||||
|
||||
#[derive(ProtoBuf, Default)]
|
||||
pub struct CreateWorkspacePayload {
|
||||
pub struct CreateWorkspacePayloadPB {
|
||||
#[pb(index = 1)]
|
||||
pub name: String,
|
||||
|
||||
@ -58,16 +58,13 @@ pub struct CreateWorkspacePayload {
|
||||
pub desc: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, ProtoBuf, Default, Debug)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct CreateWorkspaceParams {
|
||||
#[pb(index = 1)]
|
||||
pub name: String,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub desc: String,
|
||||
}
|
||||
|
||||
impl TryInto<CreateWorkspaceParams> for CreateWorkspacePayload {
|
||||
impl TryInto<CreateWorkspaceParams> for CreateWorkspacePayloadPB {
|
||||
type Error = ErrorCode;
|
||||
|
||||
fn try_into(self) -> Result<CreateWorkspaceParams, Self::Error> {
|
||||
@ -83,28 +80,28 @@ impl TryInto<CreateWorkspaceParams> for CreateWorkspacePayload {
|
||||
|
||||
// Read all workspaces if the workspace_id is None
|
||||
#[derive(Clone, ProtoBuf, Default, Debug)]
|
||||
pub struct WorkspaceId {
|
||||
pub struct WorkspaceIdPB {
|
||||
#[pb(index = 1, one_of)]
|
||||
pub value: Option<String>,
|
||||
}
|
||||
|
||||
impl WorkspaceId {
|
||||
impl WorkspaceIdPB {
|
||||
pub fn new(workspace_id: Option<String>) -> Self {
|
||||
Self { value: workspace_id }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, ProtoBuf, Clone)]
|
||||
pub struct CurrentWorkspaceSetting {
|
||||
pub struct CurrentWorkspaceSettingPB {
|
||||
#[pb(index = 1)]
|
||||
pub workspace: Workspace,
|
||||
pub workspace: WorkspacePB,
|
||||
|
||||
#[pb(index = 2, one_of)]
|
||||
pub latest_view: Option<View>,
|
||||
pub latest_view: Option<ViewPB>,
|
||||
}
|
||||
|
||||
#[derive(ProtoBuf, Default)]
|
||||
pub struct UpdateWorkspaceRequest {
|
||||
pub struct UpdateWorkspacePayloadPB {
|
||||
#[pb(index = 1)]
|
||||
pub id: String,
|
||||
|
||||
@ -115,19 +112,14 @@ pub struct UpdateWorkspaceRequest {
|
||||
pub desc: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, ProtoBuf, Default, Debug)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct UpdateWorkspaceParams {
|
||||
#[pb(index = 1)]
|
||||
pub id: String,
|
||||
|
||||
#[pb(index = 2, one_of)]
|
||||
pub name: Option<String>,
|
||||
|
||||
#[pb(index = 3, one_of)]
|
||||
pub desc: Option<String>,
|
||||
}
|
||||
|
||||
impl TryInto<UpdateWorkspaceParams> for UpdateWorkspaceRequest {
|
||||
impl TryInto<UpdateWorkspaceParams> for UpdateWorkspacePayloadPB {
|
||||
type Error = ErrorCode;
|
||||
|
||||
fn try_into(self) -> Result<UpdateWorkspaceParams, Self::Error> {
|
||||
|
@ -1,9 +1,9 @@
|
||||
use crate::{
|
||||
entities::{
|
||||
app::{AppId, CreateAppParams, UpdateAppParams},
|
||||
trash::RepeatedTrashId,
|
||||
view::{CreateViewParams, RepeatedViewId, UpdateViewParams, ViewId},
|
||||
workspace::{CreateWorkspaceParams, UpdateWorkspaceParams, WorkspaceId},
|
||||
app::{AppIdPB, CreateAppParams, UpdateAppParams},
|
||||
trash::RepeatedTrashIdPB,
|
||||
view::{CreateViewParams, RepeatedViewIdPB, UpdateViewParams, ViewIdPB},
|
||||
workspace::{CreateWorkspaceParams, UpdateWorkspaceParams, WorkspaceIdPB},
|
||||
},
|
||||
errors::FlowyError,
|
||||
manager::FolderManager,
|
||||
@ -84,73 +84,73 @@ pub fn create(folder: Arc<FolderManager>) -> Module {
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
|
||||
#[event_err = "FlowyError"]
|
||||
pub enum FolderEvent {
|
||||
#[event(input = "CreateWorkspacePayload", output = "Workspace")]
|
||||
#[event(input = "CreateWorkspacePayloadPB", output = "WorkspacePB")]
|
||||
CreateWorkspace = 0,
|
||||
|
||||
#[event(output = "CurrentWorkspaceSetting")]
|
||||
#[event(output = "CurrentWorkspaceSettingPB")]
|
||||
ReadCurWorkspace = 1,
|
||||
|
||||
#[event(input = "WorkspaceId", output = "RepeatedWorkspace")]
|
||||
#[event(input = "WorkspaceIdPB", output = "RepeatedWorkspacePB")]
|
||||
ReadWorkspaces = 2,
|
||||
|
||||
#[event(input = "WorkspaceId")]
|
||||
#[event(input = "WorkspaceIdPB")]
|
||||
DeleteWorkspace = 3,
|
||||
|
||||
#[event(input = "WorkspaceId", output = "Workspace")]
|
||||
#[event(input = "WorkspaceIdPB", output = "WorkspacePB")]
|
||||
OpenWorkspace = 4,
|
||||
|
||||
#[event(input = "WorkspaceId", output = "RepeatedApp")]
|
||||
#[event(input = "WorkspaceIdPB", output = "RepeatedAppPB")]
|
||||
ReadWorkspaceApps = 5,
|
||||
|
||||
#[event(input = "CreateAppPayload", output = "App")]
|
||||
#[event(input = "CreateAppPayloadPB", output = "AppPB")]
|
||||
CreateApp = 101,
|
||||
|
||||
#[event(input = "AppId")]
|
||||
#[event(input = "AppIdPB")]
|
||||
DeleteApp = 102,
|
||||
|
||||
#[event(input = "AppId", output = "App")]
|
||||
#[event(input = "AppIdPB", output = "AppPB")]
|
||||
ReadApp = 103,
|
||||
|
||||
#[event(input = "UpdateAppPayload")]
|
||||
#[event(input = "UpdateAppPayloadPB")]
|
||||
UpdateApp = 104,
|
||||
|
||||
#[event(input = "CreateViewPayload", output = "View")]
|
||||
#[event(input = "CreateViewPayloadPB", output = "ViewPB")]
|
||||
CreateView = 201,
|
||||
|
||||
#[event(input = "ViewId", output = "View")]
|
||||
#[event(input = "ViewIdPB", output = "ViewPB")]
|
||||
ReadView = 202,
|
||||
|
||||
#[event(input = "UpdateViewPayload", output = "View")]
|
||||
#[event(input = "UpdateViewPayloadPB", output = "ViewPB")]
|
||||
UpdateView = 203,
|
||||
|
||||
#[event(input = "RepeatedViewId")]
|
||||
#[event(input = "RepeatedViewIdPB")]
|
||||
DeleteView = 204,
|
||||
|
||||
#[event(input = "ViewId")]
|
||||
#[event(input = "ViewIdPB")]
|
||||
DuplicateView = 205,
|
||||
|
||||
#[event(input = "ViewId")]
|
||||
#[event(input = "ViewIdPB")]
|
||||
CloseView = 206,
|
||||
|
||||
#[event(input = "ViewId", output = "ViewInfo")]
|
||||
#[event(input = "ViewIdPB", output = "ViewInfoPB")]
|
||||
ReadViewInfo = 207,
|
||||
|
||||
#[event()]
|
||||
CopyLink = 220,
|
||||
|
||||
#[event(input = "ViewId")]
|
||||
#[event(input = "ViewIdPB")]
|
||||
SetLatestView = 221,
|
||||
|
||||
#[event(input = "MoveFolderItemPayload")]
|
||||
#[event(input = "MoveFolderItemPayloadPB")]
|
||||
MoveFolderItem = 230,
|
||||
|
||||
#[event(output = "RepeatedTrash")]
|
||||
#[event(output = "RepeatedTrashPB")]
|
||||
ReadTrash = 300,
|
||||
|
||||
#[event(input = "TrashId")]
|
||||
#[event(input = "TrashIdPB")]
|
||||
PutbackTrash = 301,
|
||||
|
||||
#[event(input = "RepeatedTrashId")]
|
||||
#[event(input = "RepeatedTrashIdPB")]
|
||||
DeleteTrash = 302,
|
||||
|
||||
#[event()]
|
||||
@ -170,34 +170,34 @@ pub trait FolderCouldServiceV1: Send + Sync {
|
||||
params: CreateWorkspaceParams,
|
||||
) -> FutureResult<WorkspaceRevision, FlowyError>;
|
||||
|
||||
fn read_workspace(&self, token: &str, params: WorkspaceId) -> FutureResult<Vec<WorkspaceRevision>, FlowyError>;
|
||||
fn read_workspace(&self, token: &str, params: WorkspaceIdPB) -> FutureResult<Vec<WorkspaceRevision>, FlowyError>;
|
||||
|
||||
fn update_workspace(&self, token: &str, params: UpdateWorkspaceParams) -> FutureResult<(), FlowyError>;
|
||||
|
||||
fn delete_workspace(&self, token: &str, params: WorkspaceId) -> FutureResult<(), FlowyError>;
|
||||
fn delete_workspace(&self, token: &str, params: WorkspaceIdPB) -> FutureResult<(), FlowyError>;
|
||||
|
||||
// View
|
||||
fn create_view(&self, token: &str, params: CreateViewParams) -> FutureResult<ViewRevision, FlowyError>;
|
||||
|
||||
fn read_view(&self, token: &str, params: ViewId) -> FutureResult<Option<ViewRevision>, FlowyError>;
|
||||
fn read_view(&self, token: &str, params: ViewIdPB) -> FutureResult<Option<ViewRevision>, FlowyError>;
|
||||
|
||||
fn delete_view(&self, token: &str, params: RepeatedViewId) -> FutureResult<(), FlowyError>;
|
||||
fn delete_view(&self, token: &str, params: RepeatedViewIdPB) -> FutureResult<(), FlowyError>;
|
||||
|
||||
fn update_view(&self, token: &str, params: UpdateViewParams) -> FutureResult<(), FlowyError>;
|
||||
|
||||
// App
|
||||
fn create_app(&self, token: &str, params: CreateAppParams) -> FutureResult<AppRevision, FlowyError>;
|
||||
|
||||
fn read_app(&self, token: &str, params: AppId) -> FutureResult<Option<AppRevision>, FlowyError>;
|
||||
fn read_app(&self, token: &str, params: AppIdPB) -> FutureResult<Option<AppRevision>, FlowyError>;
|
||||
|
||||
fn update_app(&self, token: &str, params: UpdateAppParams) -> FutureResult<(), FlowyError>;
|
||||
|
||||
fn delete_app(&self, token: &str, params: AppId) -> FutureResult<(), FlowyError>;
|
||||
fn delete_app(&self, token: &str, params: AppIdPB) -> FutureResult<(), FlowyError>;
|
||||
|
||||
// Trash
|
||||
fn create_trash(&self, token: &str, params: RepeatedTrashId) -> FutureResult<(), FlowyError>;
|
||||
fn create_trash(&self, token: &str, params: RepeatedTrashIdPB) -> FutureResult<(), FlowyError>;
|
||||
|
||||
fn delete_trash(&self, token: &str, params: RepeatedTrashId) -> FutureResult<(), FlowyError>;
|
||||
fn delete_trash(&self, token: &str, params: RepeatedTrashIdPB) -> FutureResult<(), FlowyError>;
|
||||
|
||||
fn read_trash(&self, token: &str) -> FutureResult<Vec<TrashRevision>, FlowyError>;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::entities::view::ViewDataType;
|
||||
use crate::{
|
||||
dart_notification::{send_dart_notification, FolderNotification},
|
||||
entities::workspace::RepeatedWorkspace,
|
||||
entities::workspace::RepeatedWorkspacePB,
|
||||
errors::FlowyResult,
|
||||
event_map::{FolderCouldServiceV1, WorkspaceDatabase, WorkspaceUser},
|
||||
services::{
|
||||
@ -216,7 +216,7 @@ impl DefaultFolderBuilder {
|
||||
let folder = FolderPad::new(vec![workspace_rev.clone()], vec![])?;
|
||||
let folder_id = FolderId::new(user_id);
|
||||
let _ = persistence.save_folder(user_id, &folder_id, folder).await?;
|
||||
let repeated_workspace = RepeatedWorkspace {
|
||||
let repeated_workspace = RepeatedWorkspacePB {
|
||||
items: vec![workspace_rev.into()],
|
||||
};
|
||||
send_dart_notification(token, FolderNotification::UserCreateWorkspace)
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
dart_notification::*,
|
||||
entities::{
|
||||
app::{App, CreateAppParams, *},
|
||||
app::{AppPB, CreateAppParams, *},
|
||||
trash::TrashType,
|
||||
},
|
||||
errors::*,
|
||||
@ -44,12 +44,12 @@ impl AppController {
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self, params), fields(name = %params.name) err)]
|
||||
pub(crate) async fn create_app_from_params(&self, params: CreateAppParams) -> Result<App, FlowyError> {
|
||||
pub(crate) async fn create_app_from_params(&self, params: CreateAppParams) -> Result<AppPB, FlowyError> {
|
||||
let app = self.create_app_on_server(params).await?;
|
||||
self.create_app_on_local(app).await
|
||||
}
|
||||
|
||||
pub(crate) async fn create_app_on_local(&self, app: AppRevision) -> Result<App, FlowyError> {
|
||||
pub(crate) async fn create_app_on_local(&self, app: AppRevision) -> Result<AppPB, FlowyError> {
|
||||
let _ = self
|
||||
.persistence
|
||||
.begin_transaction(|transaction| {
|
||||
@ -61,7 +61,7 @@ impl AppController {
|
||||
Ok(app.into())
|
||||
}
|
||||
|
||||
pub(crate) async fn read_app(&self, params: AppId) -> Result<AppRevision, FlowyError> {
|
||||
pub(crate) async fn read_app(&self, params: AppIdPB) -> Result<AppRevision, FlowyError> {
|
||||
let app = self
|
||||
.persistence
|
||||
.begin_transaction(|transaction| {
|
||||
@ -81,7 +81,7 @@ impl AppController {
|
||||
let changeset = AppChangeset::new(params.clone());
|
||||
let app_id = changeset.id.clone();
|
||||
|
||||
let app: App = self
|
||||
let app: AppPB = self
|
||||
.persistence
|
||||
.begin_transaction(|transaction| {
|
||||
let _ = transaction.update_app(changeset)?;
|
||||
@ -150,7 +150,7 @@ impl AppController {
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip(self), err)]
|
||||
fn read_app_on_server(&self, params: AppId) -> Result<(), FlowyError> {
|
||||
fn read_app_on_server(&self, params: AppIdPB) -> Result<(), FlowyError> {
|
||||
let token = self.user.token()?;
|
||||
let server = self.cloud_service.clone();
|
||||
let persistence = self.persistence.clone();
|
||||
@ -162,7 +162,7 @@ impl AppController {
|
||||
.await
|
||||
{
|
||||
Ok(_) => {
|
||||
let app: App = app_rev.into();
|
||||
let app: AppPB = app_rev.into();
|
||||
send_dart_notification(&app.id, FolderNotification::AppUpdated)
|
||||
.payload(app)
|
||||
.send();
|
||||
@ -247,7 +247,7 @@ fn notify_apps_changed<'a>(
|
||||
.into_iter()
|
||||
.map(|app_rev| app_rev.into())
|
||||
.collect();
|
||||
let repeated_app = RepeatedApp { items };
|
||||
let repeated_app = RepeatedAppPB { items };
|
||||
send_dart_notification(workspace_id, FolderNotification::WorkspaceAppsChanged)
|
||||
.payload(repeated_app)
|
||||
.send();
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
entities::app::{App, AppId, CreateAppParams, CreateAppPayload, UpdateAppParams, UpdateAppPayload},
|
||||
entities::app::{AppIdPB, AppPB, CreateAppParams, CreateAppPayloadPB, UpdateAppParams, UpdateAppPayloadPB},
|
||||
errors::FlowyError,
|
||||
services::{AppController, TrashController, ViewController},
|
||||
};
|
||||
@ -8,9 +8,9 @@ use lib_dispatch::prelude::{data_result, AppData, Data, DataResult};
|
||||
use std::{convert::TryInto, sync::Arc};
|
||||
|
||||
pub(crate) async fn create_app_handler(
|
||||
data: Data<CreateAppPayload>,
|
||||
data: Data<CreateAppPayloadPB>,
|
||||
controller: AppData<Arc<AppController>>,
|
||||
) -> DataResult<App, FlowyError> {
|
||||
) -> DataResult<AppPB, FlowyError> {
|
||||
let params: CreateAppParams = data.into_inner().try_into()?;
|
||||
let detail = controller.create_app_from_params(params).await?;
|
||||
|
||||
@ -18,11 +18,11 @@ pub(crate) async fn create_app_handler(
|
||||
}
|
||||
|
||||
pub(crate) async fn delete_app_handler(
|
||||
data: Data<AppId>,
|
||||
data: Data<AppIdPB>,
|
||||
app_controller: AppData<Arc<AppController>>,
|
||||
trash_controller: AppData<Arc<TrashController>>,
|
||||
) -> Result<(), FlowyError> {
|
||||
let params: AppId = data.into_inner();
|
||||
let params: AppIdPB = data.into_inner();
|
||||
let trash = app_controller
|
||||
.read_local_apps(vec![params.value])
|
||||
.await?
|
||||
@ -36,7 +36,7 @@ pub(crate) async fn delete_app_handler(
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, controller))]
|
||||
pub(crate) async fn update_app_handler(
|
||||
data: Data<UpdateAppPayload>,
|
||||
data: Data<UpdateAppPayloadPB>,
|
||||
controller: AppData<Arc<AppController>>,
|
||||
) -> Result<(), FlowyError> {
|
||||
let params: UpdateAppParams = data.into_inner().try_into()?;
|
||||
@ -46,11 +46,11 @@ pub(crate) async fn update_app_handler(
|
||||
|
||||
#[tracing::instrument(level = "trace", skip(data, app_controller, view_controller))]
|
||||
pub(crate) async fn read_app_handler(
|
||||
data: Data<AppId>,
|
||||
data: Data<AppIdPB>,
|
||||
app_controller: AppData<Arc<AppController>>,
|
||||
view_controller: AppData<Arc<ViewController>>,
|
||||
) -> DataResult<App, FlowyError> {
|
||||
let params: AppId = data.into_inner();
|
||||
) -> DataResult<AppPB, FlowyError> {
|
||||
let params: AppIdPB = data.into_inner();
|
||||
let mut app_rev = app_controller.read_app(params.clone()).await?;
|
||||
app_rev.belongings = view_controller.read_views_belong_to(¶ms.value).await?;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::entities::{
|
||||
app::UpdateAppParams,
|
||||
trash::{Trash, TrashType},
|
||||
trash::{TrashPB, TrashType},
|
||||
};
|
||||
use crate::{errors::FlowyError, services::persistence::version_1::workspace_sql::WorkspaceTable};
|
||||
use flowy_database::{
|
||||
@ -107,9 +107,9 @@ impl AppTable {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<AppTable> for Trash {
|
||||
impl std::convert::From<AppTable> for TrashPB {
|
||||
fn from(table: AppTable) -> Self {
|
||||
Trash {
|
||||
TrashPB {
|
||||
id: table.id,
|
||||
name: table.name,
|
||||
modified_time: table.modified_time,
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
entities::{
|
||||
trash::{Trash, TrashType},
|
||||
trash::{TrashPB, TrashType},
|
||||
view::UpdateViewParams,
|
||||
},
|
||||
errors::FlowyError,
|
||||
@ -133,9 +133,9 @@ impl std::convert::From<ViewTable> for ViewRevision {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<ViewTable> for Trash {
|
||||
impl std::convert::From<ViewTable> for TrashPB {
|
||||
fn from(table: ViewTable) -> Self {
|
||||
Trash {
|
||||
TrashPB {
|
||||
id: table.id,
|
||||
name: table.name,
|
||||
modified_time: table.modified_time,
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
dart_notification::{send_anonymous_dart_notification, FolderNotification},
|
||||
entities::trash::{RepeatedTrash, RepeatedTrashId, Trash, TrashId, TrashType},
|
||||
entities::trash::{RepeatedTrashIdPB, RepeatedTrashPB, TrashIdPB, TrashPB, TrashType},
|
||||
errors::{FlowyError, FlowyResult},
|
||||
event_map::{FolderCouldServiceV1, WorkspaceUser},
|
||||
services::persistence::{FolderPersistence, FolderPersistenceTransaction},
|
||||
@ -49,12 +49,12 @@ impl TrashController {
|
||||
})
|
||||
.await?;
|
||||
|
||||
let identifier = TrashId {
|
||||
let identifier = TrashIdPB {
|
||||
id: trash.id,
|
||||
ty: trash.ty.into(),
|
||||
};
|
||||
|
||||
let _ = self.delete_trash_on_server(RepeatedTrashId {
|
||||
let _ = self.delete_trash_on_server(RepeatedTrashIdPB {
|
||||
items: vec![identifier.clone()],
|
||||
delete_all: false,
|
||||
})?;
|
||||
@ -67,7 +67,7 @@ impl TrashController {
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self) err)]
|
||||
pub async fn restore_all_trash(&self) -> FlowyResult<()> {
|
||||
let trash_identifier: RepeatedTrashId = self
|
||||
let trash_identifier: RepeatedTrashIdPB = self
|
||||
.persistence
|
||||
.begin_transaction(|transaction| {
|
||||
let trash = transaction.read_trash(None);
|
||||
@ -81,14 +81,14 @@ impl TrashController {
|
||||
let _ = self.notify.send(TrashEvent::Putback(trash_identifier, tx));
|
||||
let _ = rx.recv().await;
|
||||
|
||||
notify_trash_changed(RepeatedTrash { items: vec![] });
|
||||
notify_trash_changed(RepeatedTrashPB { items: vec![] });
|
||||
let _ = self.delete_all_trash_on_server().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self), err)]
|
||||
pub async fn delete_all_trash(&self) -> FlowyResult<()> {
|
||||
let all_trash_identifiers: RepeatedTrashId = self
|
||||
let all_trash_identifiers: RepeatedTrashIdPB = self
|
||||
.persistence
|
||||
.begin_transaction(|transaction| transaction.read_trash(None))
|
||||
.await?
|
||||
@ -96,13 +96,13 @@ impl TrashController {
|
||||
|
||||
let _ = self.delete_with_identifiers(all_trash_identifiers).await?;
|
||||
|
||||
notify_trash_changed(RepeatedTrash { items: vec![] });
|
||||
notify_trash_changed(RepeatedTrashPB { items: vec![] });
|
||||
let _ = self.delete_all_trash_on_server().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self), err)]
|
||||
pub async fn delete(&self, trash_identifiers: RepeatedTrashId) -> FlowyResult<()> {
|
||||
pub async fn delete(&self, trash_identifiers: RepeatedTrashIdPB) -> FlowyResult<()> {
|
||||
let _ = self.delete_with_identifiers(trash_identifiers.clone()).await?;
|
||||
let trash_revs = self
|
||||
.persistence
|
||||
@ -116,7 +116,7 @@ impl TrashController {
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self), fields(delete_trash_ids), err)]
|
||||
pub async fn delete_with_identifiers(&self, trash_identifiers: RepeatedTrashId) -> FlowyResult<()> {
|
||||
pub async fn delete_with_identifiers(&self, trash_identifiers: RepeatedTrashIdPB) -> FlowyResult<()> {
|
||||
let (tx, mut rx) = mpsc::channel::<FlowyResult<()>>(1);
|
||||
tracing::Span::current().record("delete_trash_ids", &format!("{}", trash_identifiers).as_str());
|
||||
let _ = self.notify.send(TrashEvent::Delete(trash_identifiers.clone(), tx));
|
||||
@ -153,7 +153,7 @@ impl TrashController {
|
||||
pub async fn add<T: Into<TrashRevision>>(&self, trash: Vec<T>) -> Result<(), FlowyError> {
|
||||
let (tx, mut rx) = mpsc::channel::<FlowyResult<()>>(1);
|
||||
let trash_revs: Vec<TrashRevision> = trash.into_iter().map(|t| t.into()).collect();
|
||||
let identifiers = trash_revs.iter().map(|t| t.into()).collect::<Vec<TrashId>>();
|
||||
let identifiers = trash_revs.iter().map(|t| t.into()).collect::<Vec<TrashIdPB>>();
|
||||
|
||||
tracing::Span::current().record(
|
||||
"trash_ids",
|
||||
@ -187,8 +187,8 @@ impl TrashController {
|
||||
self.notify.subscribe()
|
||||
}
|
||||
|
||||
pub async fn read_trash(&self) -> Result<RepeatedTrash, FlowyError> {
|
||||
let items: Vec<Trash> = self
|
||||
pub async fn read_trash(&self) -> Result<RepeatedTrashPB, FlowyError> {
|
||||
let items: Vec<TrashPB> = self
|
||||
.persistence
|
||||
.begin_transaction(|transaction| transaction.read_trash(None))
|
||||
.await?
|
||||
@ -197,7 +197,7 @@ impl TrashController {
|
||||
.collect();
|
||||
|
||||
let _ = self.read_trash_on_server()?;
|
||||
Ok(RepeatedTrash { items })
|
||||
Ok(RepeatedTrashPB { items })
|
||||
}
|
||||
|
||||
pub fn read_trash_ids<'a>(
|
||||
@ -215,7 +215,7 @@ impl TrashController {
|
||||
|
||||
impl TrashController {
|
||||
#[tracing::instrument(level = "trace", skip(self, trash), err)]
|
||||
fn create_trash_on_server<T: Into<RepeatedTrashId>>(&self, trash: T) -> FlowyResult<()> {
|
||||
fn create_trash_on_server<T: Into<RepeatedTrashIdPB>>(&self, trash: T) -> FlowyResult<()> {
|
||||
let token = self.user.token()?;
|
||||
let trash_identifiers = trash.into();
|
||||
let server = self.cloud_service.clone();
|
||||
@ -230,7 +230,7 @@ impl TrashController {
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip(self, trash), err)]
|
||||
fn delete_trash_on_server<T: Into<RepeatedTrashId>>(&self, trash: T) -> FlowyResult<()> {
|
||||
fn delete_trash_on_server<T: Into<RepeatedTrashIdPB>>(&self, trash: T) -> FlowyResult<()> {
|
||||
let token = self.user.token()?;
|
||||
let trash_identifiers = trash.into();
|
||||
let server = self.cloud_service.clone();
|
||||
@ -277,12 +277,12 @@ impl TrashController {
|
||||
async fn delete_all_trash_on_server(&self) -> FlowyResult<()> {
|
||||
let token = self.user.token()?;
|
||||
let server = self.cloud_service.clone();
|
||||
server.delete_trash(&token, RepeatedTrashId::all()).await
|
||||
server.delete_trash(&token, RepeatedTrashIdPB::all()).await
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(repeated_trash), fields(n_trash))]
|
||||
fn notify_trash_changed<T: Into<RepeatedTrash>>(repeated_trash: T) {
|
||||
fn notify_trash_changed<T: Into<RepeatedTrashPB>>(repeated_trash: T) {
|
||||
let repeated_trash = repeated_trash.into();
|
||||
tracing::Span::current().record("n_trash", &repeated_trash.len());
|
||||
send_anonymous_dart_notification(FolderNotification::TrashUpdated)
|
||||
@ -292,9 +292,9 @@ fn notify_trash_changed<T: Into<RepeatedTrash>>(repeated_trash: T) {
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum TrashEvent {
|
||||
NewTrash(RepeatedTrashId, mpsc::Sender<FlowyResult<()>>),
|
||||
Putback(RepeatedTrashId, mpsc::Sender<FlowyResult<()>>),
|
||||
Delete(RepeatedTrashId, mpsc::Sender<FlowyResult<()>>),
|
||||
NewTrash(RepeatedTrashIdPB, mpsc::Sender<FlowyResult<()>>),
|
||||
Putback(RepeatedTrashIdPB, mpsc::Sender<FlowyResult<()>>),
|
||||
Delete(RepeatedTrashIdPB, mpsc::Sender<FlowyResult<()>>),
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for TrashEvent {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
entities::trash::{RepeatedTrash, RepeatedTrashId, TrashId},
|
||||
entities::trash::{RepeatedTrashIdPB, RepeatedTrashPB, TrashIdPB},
|
||||
errors::FlowyError,
|
||||
services::TrashController,
|
||||
};
|
||||
@ -9,14 +9,14 @@ use std::sync::Arc;
|
||||
#[tracing::instrument(level = "debug", skip(controller), err)]
|
||||
pub(crate) async fn read_trash_handler(
|
||||
controller: AppData<Arc<TrashController>>,
|
||||
) -> DataResult<RepeatedTrash, FlowyError> {
|
||||
) -> DataResult<RepeatedTrashPB, FlowyError> {
|
||||
let repeated_trash = controller.read_trash().await?;
|
||||
data_result(repeated_trash)
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(identifier, controller), err)]
|
||||
pub(crate) async fn putback_trash_handler(
|
||||
identifier: Data<TrashId>,
|
||||
identifier: Data<TrashIdPB>,
|
||||
controller: AppData<Arc<TrashController>>,
|
||||
) -> Result<(), FlowyError> {
|
||||
let _ = controller.putback(&identifier.id).await?;
|
||||
@ -25,7 +25,7 @@ pub(crate) async fn putback_trash_handler(
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(identifiers, controller), err)]
|
||||
pub(crate) async fn delete_trash_handler(
|
||||
identifiers: Data<RepeatedTrashId>,
|
||||
identifiers: Data<RepeatedTrashIdPB>,
|
||||
controller: AppData<Arc<TrashController>>,
|
||||
) -> Result<(), FlowyError> {
|
||||
let _ = controller.delete(identifiers.into_inner()).await?;
|
||||
|
@ -1,11 +1,11 @@
|
||||
pub use crate::entities::view::ViewDataType;
|
||||
use crate::entities::ViewInfo;
|
||||
use crate::entities::ViewInfoPB;
|
||||
use crate::manager::{ViewDataProcessor, ViewDataProcessorMap};
|
||||
use crate::{
|
||||
dart_notification::{send_dart_notification, FolderNotification},
|
||||
entities::{
|
||||
trash::{RepeatedTrashId, TrashType},
|
||||
view::{CreateViewParams, RepeatedView, UpdateViewParams, View, ViewId},
|
||||
trash::{RepeatedTrashIdPB, TrashType},
|
||||
view::{CreateViewParams, RepeatedViewPB, UpdateViewParams, ViewIdPB, ViewPB},
|
||||
},
|
||||
errors::{FlowyError, FlowyResult},
|
||||
event_map::{FolderCouldServiceV1, WorkspaceUser},
|
||||
@ -106,7 +106,7 @@ impl ViewController {
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self, view_id), fields(view_id = %view_id.value), err)]
|
||||
pub(crate) async fn read_view(&self, view_id: ViewId) -> Result<ViewRevision, FlowyError> {
|
||||
pub(crate) async fn read_view(&self, view_id: ViewIdPB) -> Result<ViewRevision, FlowyError> {
|
||||
let view_rev = self
|
||||
.persistence
|
||||
.begin_transaction(|transaction| {
|
||||
@ -123,25 +123,25 @@ impl ViewController {
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self, view_id), fields(view_id = %view_id.value), err)]
|
||||
pub(crate) async fn read_view_info(&self, view_id: ViewId) -> Result<ViewInfo, FlowyError> {
|
||||
pub(crate) async fn read_view_info(&self, view_id: ViewIdPB) -> Result<ViewInfoPB, FlowyError> {
|
||||
let view_info = self
|
||||
.persistence
|
||||
.begin_transaction(|transaction| {
|
||||
let view_rev = transaction.read_view(&view_id.value)?;
|
||||
|
||||
let items: Vec<View> = view_rev
|
||||
let items: Vec<ViewPB> = view_rev
|
||||
.belongings
|
||||
.into_iter()
|
||||
.map(|view_rev| view_rev.into())
|
||||
.collect();
|
||||
|
||||
let view_info = ViewInfo {
|
||||
let view_info = ViewInfoPB {
|
||||
id: view_rev.id,
|
||||
belong_to_id: view_rev.belong_to_id,
|
||||
name: view_rev.name,
|
||||
desc: view_rev.desc,
|
||||
data_type: view_rev.data_type.into(),
|
||||
belongings: RepeatedView { items },
|
||||
belongings: RepeatedViewPB { items },
|
||||
ext_data: view_rev.ext_data,
|
||||
};
|
||||
Ok(view_info)
|
||||
@ -245,7 +245,7 @@ impl ViewController {
|
||||
.begin_transaction(|transaction| {
|
||||
let _ = transaction.update_view(changeset)?;
|
||||
let view_rev = transaction.read_view(&view_id)?;
|
||||
let view: View = view_rev.clone().into();
|
||||
let view: ViewPB = view_rev.clone().into();
|
||||
send_dart_notification(&view_id, FolderNotification::ViewUpdated)
|
||||
.payload(view)
|
||||
.send();
|
||||
@ -297,7 +297,7 @@ impl ViewController {
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self), err)]
|
||||
fn read_view_on_server(&self, params: ViewId) -> Result<(), FlowyError> {
|
||||
fn read_view_on_server(&self, params: ViewIdPB) -> Result<(), FlowyError> {
|
||||
let token = self.user.token()?;
|
||||
let server = self.cloud_service.clone();
|
||||
let persistence = self.persistence.clone();
|
||||
@ -310,7 +310,7 @@ impl ViewController {
|
||||
.await
|
||||
{
|
||||
Ok(_) => {
|
||||
let view: View = view_rev.into();
|
||||
let view: ViewPB = view_rev.into();
|
||||
send_dart_notification(&view.id, FolderNotification::ViewUpdated)
|
||||
.payload(view)
|
||||
.send();
|
||||
@ -464,7 +464,7 @@ fn get_data_processor(
|
||||
}
|
||||
|
||||
fn read_local_views_with_transaction<'a>(
|
||||
identifiers: RepeatedTrashId,
|
||||
identifiers: RepeatedTrashIdPB,
|
||||
transaction: &'a (dyn FolderPersistenceTransaction + 'a),
|
||||
) -> Result<Vec<ViewRevision>, FlowyError> {
|
||||
let mut view_revs = vec![];
|
||||
@ -474,7 +474,7 @@ fn read_local_views_with_transaction<'a>(
|
||||
Ok(view_revs)
|
||||
}
|
||||
|
||||
fn notify_dart(view: View, notification: FolderNotification) {
|
||||
fn notify_dart(view: ViewPB, notification: FolderNotification) {
|
||||
send_dart_notification(&view.id, notification).payload(view).send();
|
||||
}
|
||||
|
||||
@ -489,13 +489,13 @@ fn notify_views_changed<'a>(
|
||||
trash_controller: Arc<TrashController>,
|
||||
transaction: &'a (dyn FolderPersistenceTransaction + 'a),
|
||||
) -> FlowyResult<()> {
|
||||
let items: Vec<View> = read_belonging_views_on_local(belong_to_id, trash_controller.clone(), transaction)?
|
||||
let items: Vec<ViewPB> = read_belonging_views_on_local(belong_to_id, trash_controller.clone(), transaction)?
|
||||
.into_iter()
|
||||
.map(|view_rev| view_rev.into())
|
||||
.collect();
|
||||
tracing::Span::current().record("view_count", &format!("{}", items.len()).as_str());
|
||||
|
||||
let repeated_view = RepeatedView { items };
|
||||
let repeated_view = RepeatedViewPB { items };
|
||||
send_dart_notification(belong_to_id, FolderNotification::AppViewsChanged)
|
||||
.payload(repeated_view)
|
||||
.send();
|
||||
|
@ -1,12 +1,13 @@
|
||||
use crate::entities::view::{MoveFolderItemParams, MoveFolderItemPayload, MoveFolderItemType};
|
||||
use crate::entities::ViewInfo;
|
||||
use crate::entities::view::{MoveFolderItemParams, MoveFolderItemPayloadPB, MoveFolderItemType};
|
||||
use crate::entities::ViewInfoPB;
|
||||
use crate::manager::FolderManager;
|
||||
use crate::services::{notify_workspace_setting_did_change, AppController};
|
||||
use crate::{
|
||||
entities::{
|
||||
trash::Trash,
|
||||
trash::TrashPB,
|
||||
view::{
|
||||
CreateViewParams, CreateViewPayload, RepeatedViewId, UpdateViewParams, UpdateViewPayload, View, ViewId,
|
||||
CreateViewParams, CreateViewPayloadPB, RepeatedViewIdPB, UpdateViewParams, UpdateViewPayloadPB, ViewIdPB,
|
||||
ViewPB,
|
||||
},
|
||||
},
|
||||
errors::FlowyError,
|
||||
@ -17,35 +18,35 @@ use lib_dispatch::prelude::{data_result, AppData, Data, DataResult};
|
||||
use std::{convert::TryInto, sync::Arc};
|
||||
|
||||
pub(crate) async fn create_view_handler(
|
||||
data: Data<CreateViewPayload>,
|
||||
data: Data<CreateViewPayloadPB>,
|
||||
controller: AppData<Arc<ViewController>>,
|
||||
) -> DataResult<View, FlowyError> {
|
||||
) -> DataResult<ViewPB, FlowyError> {
|
||||
let params: CreateViewParams = data.into_inner().try_into()?;
|
||||
let view_rev = controller.create_view_from_params(params).await?;
|
||||
data_result(view_rev.into())
|
||||
}
|
||||
|
||||
pub(crate) async fn read_view_handler(
|
||||
data: Data<ViewId>,
|
||||
data: Data<ViewIdPB>,
|
||||
controller: AppData<Arc<ViewController>>,
|
||||
) -> DataResult<View, FlowyError> {
|
||||
let view_id: ViewId = data.into_inner();
|
||||
) -> DataResult<ViewPB, FlowyError> {
|
||||
let view_id: ViewIdPB = data.into_inner();
|
||||
let view_rev = controller.read_view(view_id.clone()).await?;
|
||||
data_result(view_rev.into())
|
||||
}
|
||||
|
||||
pub(crate) async fn read_view_info_handler(
|
||||
data: Data<ViewId>,
|
||||
data: Data<ViewIdPB>,
|
||||
controller: AppData<Arc<ViewController>>,
|
||||
) -> DataResult<ViewInfo, FlowyError> {
|
||||
let view_id: ViewId = data.into_inner();
|
||||
) -> DataResult<ViewInfoPB, FlowyError> {
|
||||
let view_id: ViewIdPB = data.into_inner();
|
||||
let view_info = controller.read_view_info(view_id.clone()).await?;
|
||||
data_result(view_info)
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, controller), err)]
|
||||
pub(crate) async fn update_view_handler(
|
||||
data: Data<UpdateViewPayload>,
|
||||
data: Data<UpdateViewPayloadPB>,
|
||||
controller: AppData<Arc<ViewController>>,
|
||||
) -> Result<(), FlowyError> {
|
||||
let params: UpdateViewParams = data.into_inner().try_into()?;
|
||||
@ -55,11 +56,11 @@ pub(crate) async fn update_view_handler(
|
||||
}
|
||||
|
||||
pub(crate) async fn delete_view_handler(
|
||||
data: Data<RepeatedViewId>,
|
||||
data: Data<RepeatedViewIdPB>,
|
||||
view_controller: AppData<Arc<ViewController>>,
|
||||
trash_controller: AppData<Arc<TrashController>>,
|
||||
) -> Result<(), FlowyError> {
|
||||
let params: RepeatedViewId = data.into_inner();
|
||||
let params: RepeatedViewIdPB = data.into_inner();
|
||||
for view_id in ¶ms.items {
|
||||
let _ = view_controller.delete_view(view_id.into()).await;
|
||||
}
|
||||
@ -72,35 +73,35 @@ pub(crate) async fn delete_view_handler(
|
||||
let trash_rev: TrashRevision = view.into();
|
||||
trash_rev.into()
|
||||
})
|
||||
.collect::<Vec<Trash>>();
|
||||
.collect::<Vec<TrashPB>>();
|
||||
|
||||
let _ = trash_controller.add(trash).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn set_latest_view_handler(
|
||||
data: Data<ViewId>,
|
||||
data: Data<ViewIdPB>,
|
||||
folder: AppData<Arc<FolderManager>>,
|
||||
controller: AppData<Arc<ViewController>>,
|
||||
) -> Result<(), FlowyError> {
|
||||
let view_id: ViewId = data.into_inner();
|
||||
let view_id: ViewIdPB = data.into_inner();
|
||||
let _ = controller.set_latest_view(&view_id.value)?;
|
||||
let _ = notify_workspace_setting_did_change(&folder, &view_id).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn close_view_handler(
|
||||
data: Data<ViewId>,
|
||||
data: Data<ViewIdPB>,
|
||||
controller: AppData<Arc<ViewController>>,
|
||||
) -> Result<(), FlowyError> {
|
||||
let view_id: ViewId = data.into_inner();
|
||||
let view_id: ViewIdPB = data.into_inner();
|
||||
let _ = controller.close_view(&view_id.value).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip_all, err)]
|
||||
pub(crate) async fn move_item_handler(
|
||||
data: Data<MoveFolderItemPayload>,
|
||||
data: Data<MoveFolderItemPayloadPB>,
|
||||
view_controller: AppData<Arc<ViewController>>,
|
||||
app_controller: AppData<Arc<AppController>>,
|
||||
) -> Result<(), FlowyError> {
|
||||
@ -120,10 +121,10 @@ pub(crate) async fn move_item_handler(
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, controller), err)]
|
||||
pub(crate) async fn duplicate_view_handler(
|
||||
data: Data<ViewId>,
|
||||
data: Data<ViewIdPB>,
|
||||
controller: AppData<Arc<ViewController>>,
|
||||
) -> Result<(), FlowyError> {
|
||||
let view_id: ViewId = data.into_inner();
|
||||
let view_id: ViewIdPB = data.into_inner();
|
||||
let _ = controller.duplicate_view(&view_id.value).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ impl WorkspaceController {
|
||||
.into_iter()
|
||||
.map(|workspace_rev| workspace_rev.into())
|
||||
.collect();
|
||||
let repeated_workspace = RepeatedWorkspace { items: workspaces };
|
||||
let repeated_workspace = RepeatedWorkspacePB { items: workspaces };
|
||||
send_dart_notification(&token, FolderNotification::UserCreateWorkspace)
|
||||
.payload(repeated_workspace)
|
||||
.send();
|
||||
@ -99,7 +99,7 @@ impl WorkspaceController {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn open_workspace(&self, params: WorkspaceId) -> Result<Workspace, FlowyError> {
|
||||
pub(crate) async fn open_workspace(&self, params: WorkspaceIdPB) -> Result<WorkspacePB, FlowyError> {
|
||||
let user_id = self.user.user_id()?;
|
||||
if let Some(workspace_id) = params.value {
|
||||
let workspace = self
|
||||
@ -131,14 +131,14 @@ impl WorkspaceController {
|
||||
workspace_id: Option<String>,
|
||||
user_id: &str,
|
||||
transaction: &'a (dyn FolderPersistenceTransaction + 'a),
|
||||
) -> Result<RepeatedWorkspace, FlowyError> {
|
||||
) -> Result<RepeatedWorkspacePB, FlowyError> {
|
||||
let workspace_id = workspace_id.to_owned();
|
||||
let workspaces = transaction
|
||||
.read_workspaces(user_id, workspace_id)?
|
||||
.into_iter()
|
||||
.map(|workspace_rev| workspace_rev.into())
|
||||
.collect();
|
||||
Ok(RepeatedWorkspace { items: workspaces })
|
||||
Ok(RepeatedWorkspacePB { items: workspaces })
|
||||
}
|
||||
|
||||
pub(crate) fn read_local_workspace<'a>(
|
||||
@ -146,7 +146,7 @@ impl WorkspaceController {
|
||||
workspace_id: String,
|
||||
user_id: &str,
|
||||
transaction: &'a (dyn FolderPersistenceTransaction + 'a),
|
||||
) -> Result<Workspace, FlowyError> {
|
||||
) -> Result<WorkspacePB, FlowyError> {
|
||||
let mut workspace_revs = transaction.read_workspaces(user_id, Some(workspace_id.clone()))?;
|
||||
if workspace_revs.is_empty() {
|
||||
return Err(FlowyError::record_not_found().context(format!("{} workspace not found", workspace_id)));
|
||||
@ -155,7 +155,7 @@ impl WorkspaceController {
|
||||
let workspace = workspace_revs
|
||||
.drain(..1)
|
||||
.map(|workspace_rev| workspace_rev.into())
|
||||
.collect::<Vec<Workspace>>()
|
||||
.collect::<Vec<WorkspacePB>>()
|
||||
.pop()
|
||||
.unwrap();
|
||||
Ok(workspace)
|
||||
@ -186,7 +186,7 @@ impl WorkspaceController {
|
||||
|
||||
#[tracing::instrument(level = "trace", skip(self), err)]
|
||||
fn delete_workspace_on_server(&self, workspace_id: &str) -> Result<(), FlowyError> {
|
||||
let params = WorkspaceId {
|
||||
let params = WorkspaceIdPB {
|
||||
value: Some(workspace_id.to_string()),
|
||||
};
|
||||
let (token, server) = (self.user.token()?, self.cloud_service.clone());
|
||||
@ -221,11 +221,11 @@ pub async fn notify_workspace_setting_did_change(
|
||||
)?;
|
||||
|
||||
let setting = match transaction.read_view(view_id) {
|
||||
Ok(latest_view) => CurrentWorkspaceSetting {
|
||||
Ok(latest_view) => CurrentWorkspaceSettingPB {
|
||||
workspace,
|
||||
latest_view: Some(latest_view.into()),
|
||||
},
|
||||
Err(_) => CurrentWorkspaceSetting {
|
||||
Err(_) => CurrentWorkspaceSettingPB {
|
||||
workspace,
|
||||
latest_view: None,
|
||||
},
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::entities::{
|
||||
app::RepeatedApp,
|
||||
view::View,
|
||||
workspace::{CurrentWorkspaceSetting, RepeatedWorkspace, WorkspaceId, *},
|
||||
app::RepeatedAppPB,
|
||||
view::ViewPB,
|
||||
workspace::{CurrentWorkspaceSettingPB, RepeatedWorkspacePB, WorkspaceIdPB, *},
|
||||
};
|
||||
use crate::{
|
||||
dart_notification::{send_dart_notification, FolderNotification},
|
||||
@ -14,9 +14,9 @@ use std::{convert::TryInto, sync::Arc};
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, controller), err)]
|
||||
pub(crate) async fn create_workspace_handler(
|
||||
data: Data<CreateWorkspacePayload>,
|
||||
data: Data<CreateWorkspacePayloadPB>,
|
||||
controller: AppData<Arc<WorkspaceController>>,
|
||||
) -> DataResult<Workspace, FlowyError> {
|
||||
) -> DataResult<WorkspacePB, FlowyError> {
|
||||
let controller = controller.get_ref().clone();
|
||||
let params: CreateWorkspaceParams = data.into_inner().try_into()?;
|
||||
let workspace_rev = controller.create_workspace_from_params(params).await?;
|
||||
@ -26,33 +26,33 @@ pub(crate) async fn create_workspace_handler(
|
||||
#[tracing::instrument(level = "debug", skip(controller), err)]
|
||||
pub(crate) async fn read_workspace_apps_handler(
|
||||
controller: AppData<Arc<WorkspaceController>>,
|
||||
) -> DataResult<RepeatedApp, FlowyError> {
|
||||
) -> DataResult<RepeatedAppPB, FlowyError> {
|
||||
let items = controller
|
||||
.read_current_workspace_apps()
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(|app_rev| app_rev.into())
|
||||
.collect();
|
||||
let repeated_app = RepeatedApp { items };
|
||||
let repeated_app = RepeatedAppPB { items };
|
||||
data_result(repeated_app)
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, controller), err)]
|
||||
pub(crate) async fn open_workspace_handler(
|
||||
data: Data<WorkspaceId>,
|
||||
data: Data<WorkspaceIdPB>,
|
||||
controller: AppData<Arc<WorkspaceController>>,
|
||||
) -> DataResult<Workspace, FlowyError> {
|
||||
let params: WorkspaceId = data.into_inner();
|
||||
) -> DataResult<WorkspacePB, FlowyError> {
|
||||
let params: WorkspaceIdPB = data.into_inner();
|
||||
let workspaces = controller.open_workspace(params).await?;
|
||||
data_result(workspaces)
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, folder), err)]
|
||||
pub(crate) async fn read_workspaces_handler(
|
||||
data: Data<WorkspaceId>,
|
||||
data: Data<WorkspaceIdPB>,
|
||||
folder: AppData<Arc<FolderManager>>,
|
||||
) -> DataResult<RepeatedWorkspace, FlowyError> {
|
||||
let params: WorkspaceId = data.into_inner();
|
||||
) -> DataResult<RepeatedWorkspacePB, FlowyError> {
|
||||
let params: WorkspaceIdPB = data.into_inner();
|
||||
let user_id = folder.user.user_id()?;
|
||||
let workspace_controller = folder.workspace_controller.clone();
|
||||
|
||||
@ -79,10 +79,10 @@ pub(crate) async fn read_workspaces_handler(
|
||||
#[tracing::instrument(level = "debug", skip(folder), err)]
|
||||
pub async fn read_cur_workspace_handler(
|
||||
folder: AppData<Arc<FolderManager>>,
|
||||
) -> DataResult<CurrentWorkspaceSetting, FlowyError> {
|
||||
) -> DataResult<CurrentWorkspaceSettingPB, FlowyError> {
|
||||
let workspace_id = get_current_workspace()?;
|
||||
let user_id = folder.user.user_id()?;
|
||||
let params = WorkspaceId {
|
||||
let params = WorkspaceIdPB {
|
||||
value: Some(workspace_id.clone()),
|
||||
};
|
||||
|
||||
@ -95,13 +95,13 @@ pub async fn read_cur_workspace_handler(
|
||||
})
|
||||
.await?;
|
||||
|
||||
let latest_view: Option<View> = folder
|
||||
let latest_view: Option<ViewPB> = folder
|
||||
.view_controller
|
||||
.latest_visit_view()
|
||||
.await
|
||||
.unwrap_or(None)
|
||||
.map(|view_rev| view_rev.into());
|
||||
let setting = CurrentWorkspaceSetting { workspace, latest_view };
|
||||
let setting = CurrentWorkspaceSettingPB { workspace, latest_view };
|
||||
let _ = read_workspaces_on_server(folder, user_id, params);
|
||||
data_result(setting)
|
||||
}
|
||||
@ -110,7 +110,7 @@ pub async fn read_cur_workspace_handler(
|
||||
fn read_workspaces_on_server(
|
||||
folder_manager: AppData<Arc<FolderManager>>,
|
||||
user_id: String,
|
||||
params: WorkspaceId,
|
||||
params: WorkspaceIdPB,
|
||||
) -> Result<(), FlowyError> {
|
||||
let (token, server) = (folder_manager.user.token()?, folder_manager.cloud_service.clone());
|
||||
let persistence = folder_manager.persistence.clone();
|
||||
@ -145,7 +145,7 @@ fn read_workspaces_on_server(
|
||||
})
|
||||
.await?;
|
||||
|
||||
let repeated_workspace = RepeatedWorkspace {
|
||||
let repeated_workspace = RepeatedWorkspacePB {
|
||||
items: workspace_revs
|
||||
.into_iter()
|
||||
.map(|workspace_rev| workspace_rev.into())
|
||||
|
@ -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::entities::workspace::CreateWorkspacePayloadPB;
|
||||
|
||||
use flowy_revision::disk::RevisionState;
|
||||
use flowy_test::{event_builder::*, FlowySDKTest};
|
||||
@ -63,7 +63,7 @@ async fn workspace_create_with_apps() {
|
||||
async fn workspace_create_with_invalid_name() {
|
||||
for (name, code) in invalid_workspace_name_test_case() {
|
||||
let sdk = FlowySDKTest::default();
|
||||
let request = CreateWorkspacePayload {
|
||||
let request = CreateWorkspacePayloadPB {
|
||||
name,
|
||||
desc: "".to_owned(),
|
||||
};
|
||||
|
@ -1,16 +1,16 @@
|
||||
use flowy_folder::entities::view::{RepeatedViewId, ViewId};
|
||||
use flowy_folder::entities::workspace::WorkspaceId;
|
||||
use flowy_folder::entities::view::{RepeatedViewIdPB, ViewIdPB};
|
||||
use flowy_folder::entities::workspace::WorkspaceIdPB;
|
||||
use flowy_folder::entities::{
|
||||
app::{App, RepeatedApp},
|
||||
trash::Trash,
|
||||
view::{RepeatedView, View, ViewDataType},
|
||||
workspace::Workspace,
|
||||
app::{AppIdPB, CreateAppPayloadPB, UpdateAppPayloadPB},
|
||||
trash::{RepeatedTrashPB, TrashIdPB, TrashType},
|
||||
view::{CreateViewPayloadPB, UpdateViewPayloadPB},
|
||||
workspace::{CreateWorkspacePayloadPB, RepeatedWorkspacePB},
|
||||
};
|
||||
use flowy_folder::entities::{
|
||||
app::{AppId, CreateAppPayload, UpdateAppPayload},
|
||||
trash::{RepeatedTrash, TrashId, TrashType},
|
||||
view::{CreateViewPayload, UpdateViewPayload},
|
||||
workspace::{CreateWorkspacePayload, RepeatedWorkspace},
|
||||
app::{AppPB, RepeatedAppPB},
|
||||
trash::TrashPB,
|
||||
view::{RepeatedViewPB, ViewDataType, ViewPB},
|
||||
workspace::WorkspacePB,
|
||||
};
|
||||
use flowy_folder::event_map::FolderEvent::*;
|
||||
use flowy_folder::{errors::ErrorCode, services::folder_editor::FolderEditor};
|
||||
@ -30,7 +30,7 @@ pub enum FolderScript {
|
||||
desc: String,
|
||||
},
|
||||
// AssertWorkspaceRevisionJson(String),
|
||||
AssertWorkspace(Workspace),
|
||||
AssertWorkspace(WorkspacePB),
|
||||
ReadWorkspace(Option<String>),
|
||||
|
||||
// App
|
||||
@ -39,7 +39,7 @@ pub enum FolderScript {
|
||||
desc: String,
|
||||
},
|
||||
// AssertAppRevisionJson(String),
|
||||
AssertApp(App),
|
||||
AssertApp(AppPB),
|
||||
ReadApp(String),
|
||||
UpdateApp {
|
||||
name: Option<String>,
|
||||
@ -53,7 +53,7 @@ pub enum FolderScript {
|
||||
desc: String,
|
||||
data_type: ViewDataType,
|
||||
},
|
||||
AssertView(View),
|
||||
AssertView(ViewPB),
|
||||
ReadView(String),
|
||||
UpdateView {
|
||||
name: Option<String>,
|
||||
@ -79,11 +79,11 @@ pub enum FolderScript {
|
||||
|
||||
pub struct FolderTest {
|
||||
pub sdk: FlowySDKTest,
|
||||
pub all_workspace: Vec<Workspace>,
|
||||
pub workspace: Workspace,
|
||||
pub app: App,
|
||||
pub view: View,
|
||||
pub trash: Vec<Trash>,
|
||||
pub all_workspace: Vec<WorkspacePB>,
|
||||
pub workspace: WorkspacePB,
|
||||
pub app: AppPB,
|
||||
pub view: ViewPB,
|
||||
pub trash: Vec<TrashPB>,
|
||||
// pub folder_editor:
|
||||
}
|
||||
|
||||
@ -101,11 +101,11 @@ impl FolderTest {
|
||||
ViewDataType::TextBlock,
|
||||
)
|
||||
.await;
|
||||
app.belongings = RepeatedView {
|
||||
app.belongings = RepeatedViewPB {
|
||||
items: vec![view.clone()],
|
||||
};
|
||||
|
||||
workspace.apps = RepeatedApp {
|
||||
workspace.apps = RepeatedAppPB {
|
||||
items: vec![app.clone()],
|
||||
};
|
||||
Self {
|
||||
@ -247,8 +247,8 @@ pub fn invalid_workspace_name_test_case() -> Vec<(String, ErrorCode)> {
|
||||
]
|
||||
}
|
||||
|
||||
pub async fn create_workspace(sdk: &FlowySDKTest, name: &str, desc: &str) -> Workspace {
|
||||
let request = CreateWorkspacePayload {
|
||||
pub async fn create_workspace(sdk: &FlowySDKTest, name: &str, desc: &str) -> WorkspacePB {
|
||||
let request = CreateWorkspacePayloadPB {
|
||||
name: name.to_owned(),
|
||||
desc: desc.to_owned(),
|
||||
};
|
||||
@ -258,18 +258,18 @@ pub async fn create_workspace(sdk: &FlowySDKTest, name: &str, desc: &str) -> Wor
|
||||
.payload(request)
|
||||
.async_send()
|
||||
.await
|
||||
.parse::<Workspace>();
|
||||
.parse::<WorkspacePB>();
|
||||
workspace
|
||||
}
|
||||
|
||||
pub async fn read_workspace(sdk: &FlowySDKTest, workspace_id: Option<String>) -> Vec<Workspace> {
|
||||
let request = WorkspaceId { value: workspace_id };
|
||||
pub async fn read_workspace(sdk: &FlowySDKTest, workspace_id: Option<String>) -> Vec<WorkspacePB> {
|
||||
let request = WorkspaceIdPB { value: workspace_id };
|
||||
let mut repeated_workspace = FolderEventBuilder::new(sdk.clone())
|
||||
.event(ReadWorkspaces)
|
||||
.payload(request.clone())
|
||||
.async_send()
|
||||
.await
|
||||
.parse::<RepeatedWorkspace>();
|
||||
.parse::<RepeatedWorkspacePB>();
|
||||
|
||||
let workspaces;
|
||||
if let Some(workspace_id) = &request.value {
|
||||
@ -277,7 +277,7 @@ pub async fn read_workspace(sdk: &FlowySDKTest, workspace_id: Option<String>) ->
|
||||
.into_inner()
|
||||
.into_iter()
|
||||
.filter(|workspace| &workspace.id == workspace_id)
|
||||
.collect::<Vec<Workspace>>();
|
||||
.collect::<Vec<WorkspacePB>>();
|
||||
debug_assert_eq!(workspaces.len(), 1);
|
||||
} else {
|
||||
workspaces = repeated_workspace.items;
|
||||
@ -286,8 +286,8 @@ pub async fn read_workspace(sdk: &FlowySDKTest, workspace_id: Option<String>) ->
|
||||
workspaces
|
||||
}
|
||||
|
||||
pub async fn create_app(sdk: &FlowySDKTest, workspace_id: &str, name: &str, desc: &str) -> App {
|
||||
let create_app_request = CreateAppPayload {
|
||||
pub async fn create_app(sdk: &FlowySDKTest, workspace_id: &str, name: &str, desc: &str) -> AppPB {
|
||||
let create_app_request = CreateAppPayloadPB {
|
||||
workspace_id: workspace_id.to_owned(),
|
||||
name: name.to_string(),
|
||||
desc: desc.to_string(),
|
||||
@ -299,12 +299,12 @@ pub async fn create_app(sdk: &FlowySDKTest, workspace_id: &str, name: &str, desc
|
||||
.payload(create_app_request)
|
||||
.async_send()
|
||||
.await
|
||||
.parse::<App>();
|
||||
.parse::<AppPB>();
|
||||
app
|
||||
}
|
||||
|
||||
pub async fn read_app(sdk: &FlowySDKTest, app_id: &str) -> App {
|
||||
let request = AppId {
|
||||
pub async fn read_app(sdk: &FlowySDKTest, app_id: &str) -> AppPB {
|
||||
let request = AppIdPB {
|
||||
value: app_id.to_owned(),
|
||||
};
|
||||
|
||||
@ -313,13 +313,13 @@ pub async fn read_app(sdk: &FlowySDKTest, app_id: &str) -> App {
|
||||
.payload(request)
|
||||
.async_send()
|
||||
.await
|
||||
.parse::<App>();
|
||||
.parse::<AppPB>();
|
||||
|
||||
app
|
||||
}
|
||||
|
||||
pub async fn update_app(sdk: &FlowySDKTest, app_id: &str, name: Option<String>, desc: Option<String>) {
|
||||
let request = UpdateAppPayload {
|
||||
let request = UpdateAppPayloadPB {
|
||||
app_id: app_id.to_string(),
|
||||
name,
|
||||
desc,
|
||||
@ -335,7 +335,7 @@ pub async fn update_app(sdk: &FlowySDKTest, app_id: &str, name: Option<String>,
|
||||
}
|
||||
|
||||
pub async fn delete_app(sdk: &FlowySDKTest, app_id: &str) {
|
||||
let request = AppId {
|
||||
let request = AppIdPB {
|
||||
value: app_id.to_string(),
|
||||
};
|
||||
|
||||
@ -346,8 +346,8 @@ pub async fn delete_app(sdk: &FlowySDKTest, app_id: &str) {
|
||||
.await;
|
||||
}
|
||||
|
||||
pub async fn create_view(sdk: &FlowySDKTest, app_id: &str, name: &str, desc: &str, data_type: ViewDataType) -> View {
|
||||
let request = CreateViewPayload {
|
||||
pub async fn create_view(sdk: &FlowySDKTest, app_id: &str, name: &str, desc: &str, data_type: ViewDataType) -> ViewPB {
|
||||
let request = CreateViewPayloadPB {
|
||||
belong_to_id: app_id.to_string(),
|
||||
name: name.to_string(),
|
||||
desc: desc.to_string(),
|
||||
@ -361,22 +361,22 @@ pub async fn create_view(sdk: &FlowySDKTest, app_id: &str, name: &str, desc: &st
|
||||
.payload(request)
|
||||
.async_send()
|
||||
.await
|
||||
.parse::<View>();
|
||||
.parse::<ViewPB>();
|
||||
view
|
||||
}
|
||||
|
||||
pub async fn read_view(sdk: &FlowySDKTest, view_id: &str) -> View {
|
||||
let view_id: ViewId = view_id.into();
|
||||
pub async fn read_view(sdk: &FlowySDKTest, view_id: &str) -> ViewPB {
|
||||
let view_id: ViewIdPB = view_id.into();
|
||||
FolderEventBuilder::new(sdk.clone())
|
||||
.event(ReadView)
|
||||
.payload(view_id)
|
||||
.async_send()
|
||||
.await
|
||||
.parse::<View>()
|
||||
.parse::<ViewPB>()
|
||||
}
|
||||
|
||||
pub async fn update_view(sdk: &FlowySDKTest, view_id: &str, name: Option<String>, desc: Option<String>) {
|
||||
let request = UpdateViewPayload {
|
||||
let request = UpdateViewPayloadPB {
|
||||
view_id: view_id.to_string(),
|
||||
name,
|
||||
desc,
|
||||
@ -390,7 +390,7 @@ pub async fn update_view(sdk: &FlowySDKTest, view_id: &str, name: Option<String>
|
||||
}
|
||||
|
||||
pub async fn delete_view(sdk: &FlowySDKTest, view_ids: Vec<String>) {
|
||||
let request = RepeatedViewId { items: view_ids };
|
||||
let request = RepeatedViewIdPB { items: view_ids };
|
||||
FolderEventBuilder::new(sdk.clone())
|
||||
.event(DeleteView)
|
||||
.payload(request)
|
||||
@ -400,7 +400,7 @@ pub async fn delete_view(sdk: &FlowySDKTest, view_ids: Vec<String>) {
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub async fn set_latest_view(sdk: &FlowySDKTest, view_id: &str) -> DocumentPB {
|
||||
let view_id: ViewId = view_id.into();
|
||||
let view_id: ViewIdPB = view_id.into();
|
||||
FolderEventBuilder::new(sdk.clone())
|
||||
.event(SetLatestView)
|
||||
.payload(view_id)
|
||||
@ -409,16 +409,16 @@ pub async fn set_latest_view(sdk: &FlowySDKTest, view_id: &str) -> DocumentPB {
|
||||
.parse::<DocumentPB>()
|
||||
}
|
||||
|
||||
pub async fn read_trash(sdk: &FlowySDKTest) -> RepeatedTrash {
|
||||
pub async fn read_trash(sdk: &FlowySDKTest) -> RepeatedTrashPB {
|
||||
FolderEventBuilder::new(sdk.clone())
|
||||
.event(ReadTrash)
|
||||
.async_send()
|
||||
.await
|
||||
.parse::<RepeatedTrash>()
|
||||
.parse::<RepeatedTrashPB>()
|
||||
}
|
||||
|
||||
pub async fn restore_app_from_trash(sdk: &FlowySDKTest, app_id: &str) {
|
||||
let id = TrashId {
|
||||
let id = TrashIdPB {
|
||||
id: app_id.to_owned(),
|
||||
ty: TrashType::TrashApp,
|
||||
};
|
||||
@ -430,7 +430,7 @@ pub async fn restore_app_from_trash(sdk: &FlowySDKTest, app_id: &str) {
|
||||
}
|
||||
|
||||
pub async fn restore_view_from_trash(sdk: &FlowySDKTest, view_id: &str) {
|
||||
let id = TrashId {
|
||||
let id = TrashIdPB {
|
||||
id: view_id.to_owned(),
|
||||
ty: TrashType::TrashView,
|
||||
};
|
||||
|
@ -1,15 +1,14 @@
|
||||
use crate::{
|
||||
configuration::{ClientServerConfiguration, HEADER_TOKEN},
|
||||
configuration::ClientServerConfiguration,
|
||||
request::{HttpRequestBuilder, ResponseMiddleware},
|
||||
};
|
||||
use flowy_error::FlowyError;
|
||||
use flowy_folder::entities::{
|
||||
trash::RepeatedTrashId,
|
||||
view::{CreateViewParams, RepeatedViewId, UpdateViewParams, ViewId},
|
||||
workspace::{CreateWorkspaceParams, UpdateWorkspaceParams, WorkspaceId},
|
||||
{AppId, CreateAppParams, UpdateAppParams},
|
||||
trash::RepeatedTrashIdPB,
|
||||
view::{CreateViewParams, RepeatedViewIdPB, UpdateViewParams, ViewIdPB},
|
||||
workspace::{CreateWorkspaceParams, UpdateWorkspaceParams, WorkspaceIdPB},
|
||||
{AppIdPB, CreateAppParams, UpdateAppParams},
|
||||
};
|
||||
|
||||
use flowy_folder::event_map::FolderCouldServiceV1;
|
||||
use flowy_folder_data_model::revision::{AppRevision, TrashRevision, ViewRevision, WorkspaceRevision};
|
||||
use http_flowy::errors::ServerError;
|
||||
@ -45,7 +44,7 @@ impl FolderCouldServiceV1 for FolderHttpCloudService {
|
||||
})
|
||||
}
|
||||
|
||||
fn read_workspace(&self, token: &str, params: WorkspaceId) -> FutureResult<Vec<WorkspaceRevision>, FlowyError> {
|
||||
fn read_workspace(&self, token: &str, params: WorkspaceIdPB) -> FutureResult<Vec<WorkspaceRevision>, FlowyError> {
|
||||
let token = token.to_owned();
|
||||
let url = self.config.workspace_url();
|
||||
FutureResult::new(async move {
|
||||
@ -63,7 +62,7 @@ impl FolderCouldServiceV1 for FolderHttpCloudService {
|
||||
})
|
||||
}
|
||||
|
||||
fn delete_workspace(&self, token: &str, params: WorkspaceId) -> FutureResult<(), FlowyError> {
|
||||
fn delete_workspace(&self, token: &str, params: WorkspaceIdPB) -> FutureResult<(), FlowyError> {
|
||||
let token = token.to_owned();
|
||||
let url = self.config.workspace_url();
|
||||
FutureResult::new(async move {
|
||||
@ -81,7 +80,7 @@ impl FolderCouldServiceV1 for FolderHttpCloudService {
|
||||
})
|
||||
}
|
||||
|
||||
fn read_view(&self, token: &str, params: ViewId) -> FutureResult<Option<ViewRevision>, FlowyError> {
|
||||
fn read_view(&self, token: &str, params: ViewIdPB) -> FutureResult<Option<ViewRevision>, FlowyError> {
|
||||
let token = token.to_owned();
|
||||
let url = self.config.view_url();
|
||||
FutureResult::new(async move {
|
||||
@ -90,7 +89,7 @@ impl FolderCouldServiceV1 for FolderHttpCloudService {
|
||||
})
|
||||
}
|
||||
|
||||
fn delete_view(&self, token: &str, params: RepeatedViewId) -> FutureResult<(), FlowyError> {
|
||||
fn delete_view(&self, token: &str, params: RepeatedViewIdPB) -> FutureResult<(), FlowyError> {
|
||||
let token = token.to_owned();
|
||||
let url = self.config.view_url();
|
||||
FutureResult::new(async move {
|
||||
@ -117,7 +116,7 @@ impl FolderCouldServiceV1 for FolderHttpCloudService {
|
||||
})
|
||||
}
|
||||
|
||||
fn read_app(&self, token: &str, params: AppId) -> FutureResult<Option<AppRevision>, FlowyError> {
|
||||
fn read_app(&self, token: &str, params: AppIdPB) -> FutureResult<Option<AppRevision>, FlowyError> {
|
||||
let token = token.to_owned();
|
||||
let url = self.config.app_url();
|
||||
FutureResult::new(async move {
|
||||
@ -135,7 +134,7 @@ impl FolderCouldServiceV1 for FolderHttpCloudService {
|
||||
})
|
||||
}
|
||||
|
||||
fn delete_app(&self, token: &str, params: AppId) -> FutureResult<(), FlowyError> {
|
||||
fn delete_app(&self, token: &str, params: AppIdPB) -> FutureResult<(), FlowyError> {
|
||||
let token = token.to_owned();
|
||||
let url = self.config.app_url();
|
||||
FutureResult::new(async move {
|
||||
@ -144,7 +143,7 @@ impl FolderCouldServiceV1 for FolderHttpCloudService {
|
||||
})
|
||||
}
|
||||
|
||||
fn create_trash(&self, token: &str, params: RepeatedTrashId) -> FutureResult<(), FlowyError> {
|
||||
fn create_trash(&self, token: &str, params: RepeatedTrashIdPB) -> FutureResult<(), FlowyError> {
|
||||
let token = token.to_owned();
|
||||
let url = self.config.trash_url();
|
||||
FutureResult::new(async move {
|
||||
@ -153,7 +152,7 @@ impl FolderCouldServiceV1 for FolderHttpCloudService {
|
||||
})
|
||||
}
|
||||
|
||||
fn delete_trash(&self, token: &str, params: RepeatedTrashId) -> FutureResult<(), FlowyError> {
|
||||
fn delete_trash(&self, token: &str, params: RepeatedTrashIdPB) -> FutureResult<(), FlowyError> {
|
||||
let token = token.to_owned();
|
||||
let url = self.config.trash_url();
|
||||
FutureResult::new(async move {
|
||||
@ -172,6 +171,7 @@ impl FolderCouldServiceV1 for FolderHttpCloudService {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn request_builder() -> HttpRequestBuilder {
|
||||
HttpRequestBuilder::new().middleware(MIDDLEWARE.clone())
|
||||
}
|
||||
@ -193,7 +193,7 @@ pub async fn create_workspace_request(
|
||||
|
||||
pub async fn read_workspaces_request(
|
||||
_token: &str,
|
||||
_params: WorkspaceId,
|
||||
_params: WorkspaceIdPB,
|
||||
_url: &str,
|
||||
) -> Result<Vec<WorkspaceRevision>, ServerError> {
|
||||
// let repeated_workspace = request_builder()
|
||||
@ -208,26 +208,26 @@ pub async fn read_workspaces_request(
|
||||
}
|
||||
|
||||
pub async fn update_workspace_request(
|
||||
token: &str,
|
||||
params: UpdateWorkspaceParams,
|
||||
url: &str,
|
||||
_token: &str,
|
||||
_params: UpdateWorkspaceParams,
|
||||
_url: &str,
|
||||
) -> Result<(), ServerError> {
|
||||
let _ = request_builder()
|
||||
.patch(&url.to_owned())
|
||||
.header(HEADER_TOKEN, token)
|
||||
.protobuf(params)?
|
||||
.send()
|
||||
.await?;
|
||||
// let _ = request_builder()
|
||||
// .patch(&url.to_owned())
|
||||
// .header(HEADER_TOKEN, token)
|
||||
// .protobuf(params)?
|
||||
// .send()
|
||||
// .await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn delete_workspace_request(token: &str, params: WorkspaceId, url: &str) -> Result<(), ServerError> {
|
||||
let _ = request_builder()
|
||||
.delete(url)
|
||||
.header(HEADER_TOKEN, token)
|
||||
.protobuf(params)?
|
||||
.send()
|
||||
.await?;
|
||||
pub async fn delete_workspace_request(_token: &str, _params: WorkspaceIdPB, _url: &str) -> Result<(), ServerError> {
|
||||
// let _ = request_builder()
|
||||
// .delete(url)
|
||||
// .header(HEADER_TOKEN, token)
|
||||
// .protobuf(params)?
|
||||
// .send()
|
||||
// .await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -247,7 +247,7 @@ pub async fn create_app_request(
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub async fn read_app_request(_token: &str, _params: AppId, _url: &str) -> Result<Option<AppRevision>, ServerError> {
|
||||
pub async fn read_app_request(_token: &str, _params: AppIdPB, _url: &str) -> Result<Option<AppRevision>, ServerError> {
|
||||
// let app = request_builder()
|
||||
// .get(&url.to_owned())
|
||||
// .header(HEADER_TOKEN, token)
|
||||
@ -259,23 +259,23 @@ pub async fn read_app_request(_token: &str, _params: AppId, _url: &str) -> Resul
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub async fn update_app_request(token: &str, params: UpdateAppParams, url: &str) -> Result<(), ServerError> {
|
||||
let _ = request_builder()
|
||||
.patch(&url.to_owned())
|
||||
.header(HEADER_TOKEN, token)
|
||||
.protobuf(params)?
|
||||
.send()
|
||||
.await?;
|
||||
pub async fn update_app_request(_token: &str, _params: UpdateAppParams, _url: &str) -> Result<(), ServerError> {
|
||||
// let _ = request_builder()
|
||||
// .patch(&url.to_owned())
|
||||
// .header(HEADER_TOKEN, token)
|
||||
// .protobuf(params)?
|
||||
// .send()
|
||||
// .await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn delete_app_request(token: &str, params: AppId, url: &str) -> Result<(), ServerError> {
|
||||
let _ = request_builder()
|
||||
.delete(&url.to_owned())
|
||||
.header(HEADER_TOKEN, token)
|
||||
.protobuf(params)?
|
||||
.send()
|
||||
.await?;
|
||||
pub async fn delete_app_request(_token: &str, _params: AppIdPB, _url: &str) -> Result<(), ServerError> {
|
||||
// let _ = request_builder()
|
||||
// .delete(&url.to_owned())
|
||||
// .header(HEADER_TOKEN, token)
|
||||
// .protobuf(params)?
|
||||
// .send()
|
||||
// .await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -295,7 +295,11 @@ pub async fn create_view_request(
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub async fn read_view_request(_token: &str, _params: ViewId, _url: &str) -> Result<Option<ViewRevision>, ServerError> {
|
||||
pub async fn read_view_request(
|
||||
_token: &str,
|
||||
_params: ViewIdPB,
|
||||
_url: &str,
|
||||
) -> Result<Option<ViewRevision>, ServerError> {
|
||||
// let view = request_builder()
|
||||
// .get(&url.to_owned())
|
||||
// .header(HEADER_TOKEN, token)
|
||||
@ -307,43 +311,43 @@ pub async fn read_view_request(_token: &str, _params: ViewId, _url: &str) -> Res
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub async fn update_view_request(token: &str, params: UpdateViewParams, url: &str) -> Result<(), ServerError> {
|
||||
let _ = request_builder()
|
||||
.patch(&url.to_owned())
|
||||
.header(HEADER_TOKEN, token)
|
||||
.protobuf(params)?
|
||||
.send()
|
||||
.await?;
|
||||
pub async fn update_view_request(_token: &str, _params: UpdateViewParams, _url: &str) -> Result<(), ServerError> {
|
||||
// let _ = request_builder()
|
||||
// .patch(&url.to_owned())
|
||||
// .header(HEADER_TOKEN, token)
|
||||
// .protobuf(params)?
|
||||
// .send()
|
||||
// .await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn delete_view_request(token: &str, params: RepeatedViewId, url: &str) -> Result<(), ServerError> {
|
||||
let _ = request_builder()
|
||||
.delete(&url.to_owned())
|
||||
.header(HEADER_TOKEN, token)
|
||||
.protobuf(params)?
|
||||
.send()
|
||||
.await?;
|
||||
pub async fn delete_view_request(_token: &str, _params: RepeatedViewIdPB, _url: &str) -> Result<(), ServerError> {
|
||||
// let _ = request_builder()
|
||||
// .delete(&url.to_owned())
|
||||
// .header(HEADER_TOKEN, token)
|
||||
// .protobuf(params)?
|
||||
// .send()
|
||||
// .await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn create_trash_request(token: &str, params: RepeatedTrashId, url: &str) -> Result<(), ServerError> {
|
||||
let _ = request_builder()
|
||||
.post(&url.to_owned())
|
||||
.header(HEADER_TOKEN, token)
|
||||
.protobuf(params)?
|
||||
.send()
|
||||
.await?;
|
||||
pub async fn create_trash_request(_token: &str, _params: RepeatedTrashIdPB, _url: &str) -> Result<(), ServerError> {
|
||||
// let _ = request_builder()
|
||||
// .post(&url.to_owned())
|
||||
// .header(HEADER_TOKEN, token)
|
||||
// .protobuf(params)?
|
||||
// .send()
|
||||
// .await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn delete_trash_request(token: &str, params: RepeatedTrashId, url: &str) -> Result<(), ServerError> {
|
||||
let _ = request_builder()
|
||||
.delete(&url.to_owned())
|
||||
.header(HEADER_TOKEN, token)
|
||||
.protobuf(params)?
|
||||
.send()
|
||||
.await?;
|
||||
pub async fn delete_trash_request(_token: &str, _params: RepeatedTrashIdPB, _url: &str) -> Result<(), ServerError> {
|
||||
// let _ = request_builder()
|
||||
// .delete(&url.to_owned())
|
||||
// .header(HEADER_TOKEN, token)
|
||||
// .protobuf(params)?
|
||||
// .send()
|
||||
// .await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -253,10 +253,10 @@ impl RevisionUser for LocalRevisionUser {
|
||||
}
|
||||
|
||||
use flowy_folder::entities::{
|
||||
app::{AppId, CreateAppParams, UpdateAppParams},
|
||||
trash::RepeatedTrashId,
|
||||
view::{CreateViewParams, RepeatedViewId, UpdateViewParams, ViewId},
|
||||
workspace::{CreateWorkspaceParams, UpdateWorkspaceParams, WorkspaceId},
|
||||
app::{AppIdPB, CreateAppParams, UpdateAppParams},
|
||||
trash::RepeatedTrashIdPB,
|
||||
view::{CreateViewParams, RepeatedViewIdPB, UpdateViewParams, ViewIdPB},
|
||||
workspace::{CreateWorkspaceParams, UpdateWorkspaceParams, WorkspaceIdPB},
|
||||
};
|
||||
use flowy_folder_data_model::revision::{
|
||||
gen_app_id, gen_workspace_id, AppRevision, TrashRevision, ViewRevision, WorkspaceRevision,
|
||||
@ -289,7 +289,7 @@ impl FolderCouldServiceV1 for LocalServer {
|
||||
FutureResult::new(async { Ok(workspace) })
|
||||
}
|
||||
|
||||
fn read_workspace(&self, _token: &str, _params: WorkspaceId) -> FutureResult<Vec<WorkspaceRevision>, FlowyError> {
|
||||
fn read_workspace(&self, _token: &str, _params: WorkspaceIdPB) -> FutureResult<Vec<WorkspaceRevision>, FlowyError> {
|
||||
FutureResult::new(async { Ok(vec![]) })
|
||||
}
|
||||
|
||||
@ -297,7 +297,7 @@ impl FolderCouldServiceV1 for LocalServer {
|
||||
FutureResult::new(async { Ok(()) })
|
||||
}
|
||||
|
||||
fn delete_workspace(&self, _token: &str, _params: WorkspaceId) -> FutureResult<(), FlowyError> {
|
||||
fn delete_workspace(&self, _token: &str, _params: WorkspaceIdPB) -> FutureResult<(), FlowyError> {
|
||||
FutureResult::new(async { Ok(()) })
|
||||
}
|
||||
|
||||
@ -320,11 +320,11 @@ impl FolderCouldServiceV1 for LocalServer {
|
||||
FutureResult::new(async { Ok(view) })
|
||||
}
|
||||
|
||||
fn read_view(&self, _token: &str, _params: ViewId) -> FutureResult<Option<ViewRevision>, FlowyError> {
|
||||
fn read_view(&self, _token: &str, _params: ViewIdPB) -> FutureResult<Option<ViewRevision>, FlowyError> {
|
||||
FutureResult::new(async { Ok(None) })
|
||||
}
|
||||
|
||||
fn delete_view(&self, _token: &str, _params: RepeatedViewId) -> FutureResult<(), FlowyError> {
|
||||
fn delete_view(&self, _token: &str, _params: RepeatedViewIdPB) -> FutureResult<(), FlowyError> {
|
||||
FutureResult::new(async { Ok(()) })
|
||||
}
|
||||
|
||||
@ -347,7 +347,7 @@ impl FolderCouldServiceV1 for LocalServer {
|
||||
FutureResult::new(async { Ok(app) })
|
||||
}
|
||||
|
||||
fn read_app(&self, _token: &str, _params: AppId) -> FutureResult<Option<AppRevision>, FlowyError> {
|
||||
fn read_app(&self, _token: &str, _params: AppIdPB) -> FutureResult<Option<AppRevision>, FlowyError> {
|
||||
FutureResult::new(async { Ok(None) })
|
||||
}
|
||||
|
||||
@ -355,15 +355,15 @@ impl FolderCouldServiceV1 for LocalServer {
|
||||
FutureResult::new(async { Ok(()) })
|
||||
}
|
||||
|
||||
fn delete_app(&self, _token: &str, _params: AppId) -> FutureResult<(), FlowyError> {
|
||||
fn delete_app(&self, _token: &str, _params: AppIdPB) -> FutureResult<(), FlowyError> {
|
||||
FutureResult::new(async { Ok(()) })
|
||||
}
|
||||
|
||||
fn create_trash(&self, _token: &str, _params: RepeatedTrashId) -> FutureResult<(), FlowyError> {
|
||||
fn create_trash(&self, _token: &str, _params: RepeatedTrashIdPB) -> FutureResult<(), FlowyError> {
|
||||
FutureResult::new(async { Ok(()) })
|
||||
}
|
||||
|
||||
fn delete_trash(&self, _token: &str, _params: RepeatedTrashId) -> FutureResult<(), FlowyError> {
|
||||
fn delete_trash(&self, _token: &str, _params: RepeatedTrashIdPB) -> FutureResult<(), FlowyError> {
|
||||
FutureResult::new(async { Ok(()) })
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
use crate::prelude::*;
|
||||
use flowy_folder::entities::WorkspaceId;
|
||||
use flowy_folder::entities::WorkspaceIdPB;
|
||||
use flowy_folder::{
|
||||
entities::{
|
||||
app::*,
|
||||
view::*,
|
||||
workspace::{CreateWorkspacePayload, Workspace},
|
||||
workspace::{CreateWorkspacePayloadPB, WorkspacePB},
|
||||
},
|
||||
event_map::FolderEvent::{CreateWorkspace, OpenWorkspace, *},
|
||||
};
|
||||
@ -18,9 +18,9 @@ use std::{fs, path::PathBuf, sync::Arc};
|
||||
|
||||
pub struct ViewTest {
|
||||
pub sdk: FlowySDKTest,
|
||||
pub workspace: Workspace,
|
||||
pub app: App,
|
||||
pub view: View,
|
||||
pub workspace: WorkspacePB,
|
||||
pub app: AppPB,
|
||||
pub view: ViewPB,
|
||||
}
|
||||
|
||||
impl ViewTest {
|
||||
@ -47,8 +47,8 @@ impl ViewTest {
|
||||
}
|
||||
}
|
||||
|
||||
async fn create_workspace(sdk: &FlowySDKTest, name: &str, desc: &str) -> Workspace {
|
||||
let request = CreateWorkspacePayload {
|
||||
async fn create_workspace(sdk: &FlowySDKTest, name: &str, desc: &str) -> WorkspacePB {
|
||||
let request = CreateWorkspacePayloadPB {
|
||||
name: name.to_owned(),
|
||||
desc: desc.to_owned(),
|
||||
};
|
||||
@ -58,12 +58,12 @@ async fn create_workspace(sdk: &FlowySDKTest, name: &str, desc: &str) -> Workspa
|
||||
.payload(request)
|
||||
.async_send()
|
||||
.await
|
||||
.parse::<Workspace>();
|
||||
.parse::<WorkspacePB>();
|
||||
workspace
|
||||
}
|
||||
|
||||
async fn open_workspace(sdk: &FlowySDKTest, workspace_id: &str) {
|
||||
let payload = WorkspaceId {
|
||||
let payload = WorkspaceIdPB {
|
||||
value: Some(workspace_id.to_owned()),
|
||||
};
|
||||
let _ = FolderEventBuilder::new(sdk.clone())
|
||||
@ -73,8 +73,8 @@ async fn open_workspace(sdk: &FlowySDKTest, workspace_id: &str) {
|
||||
.await;
|
||||
}
|
||||
|
||||
async fn create_app(sdk: &FlowySDKTest, name: &str, desc: &str, workspace_id: &str) -> App {
|
||||
let create_app_request = CreateAppPayload {
|
||||
async fn create_app(sdk: &FlowySDKTest, name: &str, desc: &str, workspace_id: &str) -> AppPB {
|
||||
let create_app_request = CreateAppPayloadPB {
|
||||
workspace_id: workspace_id.to_owned(),
|
||||
name: name.to_string(),
|
||||
desc: desc.to_string(),
|
||||
@ -86,12 +86,12 @@ async fn create_app(sdk: &FlowySDKTest, name: &str, desc: &str, workspace_id: &s
|
||||
.payload(create_app_request)
|
||||
.async_send()
|
||||
.await
|
||||
.parse::<App>();
|
||||
.parse::<AppPB>();
|
||||
app
|
||||
}
|
||||
|
||||
async fn create_view(sdk: &FlowySDKTest, app_id: &str, data_type: ViewDataType, data: Vec<u8>) -> View {
|
||||
let request = CreateViewPayload {
|
||||
async fn create_view(sdk: &FlowySDKTest, app_id: &str, data_type: ViewDataType, data: Vec<u8>) -> ViewPB {
|
||||
let request = CreateViewPayloadPB {
|
||||
belong_to_id: app_id.to_string(),
|
||||
name: "View A".to_string(),
|
||||
desc: "".to_string(),
|
||||
@ -106,7 +106,7 @@ async fn create_view(sdk: &FlowySDKTest, app_id: &str, data_type: ViewDataType,
|
||||
.payload(request)
|
||||
.async_send()
|
||||
.await
|
||||
.parse::<View>();
|
||||
.parse::<ViewPB>();
|
||||
view
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user