Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

remove workspace interface

appflowyaaca3ba90dff
diff --git a/frontend/app_flowy/lib/workspace/application/menu/menu_bloc.dart b/frontend/app_flowy/lib/workspace/application/menu/menu_bloc.dart
index 79d94a020b..fb1e9dc7c9 100644
--- a/frontend/app_flowy/lib/workspace/application/menu/menu_bloc.dart
+++ b/frontend/app_flowy/lib/workspace/application/menu/menu_bloc.dart
@@ -1,6 +1,6 @@
import 'dart:async';
-import 'package:app_flowy/workspace/domain/i_workspace.dart';
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
+import 'package:app_flowy/workspace/infrastructure/repos/workspace_repo.dart';
import 'package:app_flowy/workspace/presentation/stack_page/blank/blank_page.dart';
import 'package:dartz/dartz.dart';
import 'package:flowy_log/flowy_log.dart';
@@ -12,9 +12,9 @@ import 'package:flutter_bloc/flutter_bloc.dart';
part 'menu_bloc.freezed.dart';
class MenuBloc extends Bloc<MenuEvent, MenuState> {
- final IWorkspace workspaceManager;
- final IWorkspaceListener listener;
- MenuBloc({required this.workspaceManager, required this.listener}) : super(MenuState.initial()) {
+ final WorkspaceRepo repo;
+ final WorkspaceListener listener;
+ MenuBloc({required this.repo, required this.listener}) : super(MenuState.initial()) {
on<MenuEvent>((event, emit) async {
await event.map(
initial: (e) async {
@@ -48,7 +48,7 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> {
}
Future<void> _performActionOnCreateApp(CreateApp event, Emitter<MenuState> emit) async {
- final result = await workspaceManager.createApp(name: event.name, desc: event.desc);
+ final result = await repo.createApp(event.name, event.desc ?? "");
result.fold(
(app) => {},
(error) {
@@ -60,7 +60,7 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> {
// ignore: unused_element
Future<void> _fetchApps(Emitter<MenuState> emit) async {
- final appsOrFail = await workspaceManager.getApps();
+ final appsOrFail = await repo.getApps();
emit(appsOrFail.fold(
(apps) => state.copyWith(apps: some(apps)),
(error) {
diff --git a/frontend/app_flowy/lib/workspace/domain/i_workspace.dart b/frontend/app_flowy/lib/workspace/domain/i_workspace.dart
deleted file mode 100644
index 6e0393a1cf..0000000000
--- a/frontend/app_flowy/lib/workspace/domain/i_workspace.dart
+++ /dev/null
@@ -1,19 +0,0 @@
-import 'package:flowy_sdk/protobuf/flowy-folder-data-model/protobuf.dart';
-import 'package:dartz/dartz.dart';
-import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
-
-typedef WorkspaceAppsChangedCallback = void Function(Either<List<App>, FlowyError> appsOrFail);
-
-typedef WorkspaceUpdatedCallback = void Function(String name, String desc);
-
-abstract class IWorkspace {
- Future<Either<App, FlowyError>> createApp({required String name, String? desc});
-
- Future<Either<List<App>, FlowyError>> getApps();
-}
-
-abstract class IWorkspaceListener {
- void start({WorkspaceAppsChangedCallback? addAppCallback, WorkspaceUpdatedCallback? updatedCallback});
-
- Future<void> stop();
-}
diff --git a/frontend/app_flowy/lib/workspace/infrastructure/deps_resolver.dart b/frontend/app_flowy/lib/workspace/infrastructure/deps_resolver.dart
index 626a2483f5..5b481f9421 100644
--- a/frontend/app_flowy/lib/workspace/infrastructure/deps_resolver.dart
+++ b/frontend/app_flowy/lib/workspace/infrastructure/deps_resolver.dart
@@ -14,7 +14,6 @@ import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
import 'package:app_flowy/workspace/infrastructure/i_app_impl.dart';
import 'package:app_flowy/workspace/infrastructure/i_doc_impl.dart';
import 'package:app_flowy/workspace/infrastructure/i_trash_impl.dart';
-import 'package:app_flowy/workspace/infrastructure/i_workspace_impl.dart';
import 'package:app_flowy/workspace/infrastructure/repos/app_repo.dart';
import 'package:app_flowy/workspace/infrastructure/repos/doc_repo.dart';
import 'package:app_flowy/workspace/infrastructure/repos/trash_repo.dart';
@@ -46,10 +45,8 @@ class HomeDepsResolver {
(appId, _) => IAppListenerhImpl(repo: AppListenerRepository(appId: appId)));
//workspace
- getIt.registerFactoryParam<IWorkspace, UserProfile, String>(
- (user, workspaceId) => IWorkspaceImpl(repo: WorkspaceRepo(user: user, workspaceId: workspaceId)));
- getIt.registerFactoryParam<IWorkspaceListener, UserProfile, String>((user, workspaceId) =>
- IWorkspaceListenerImpl(repo: WorkspaceListenerRepo(user: user, workspaceId: workspaceId)));
+ getIt.registerFactoryParam<WorkspaceListener, UserProfile, String>(
+ (user, workspaceId) => WorkspaceListener(repo: WorkspaceListenerRepo(user: user, workspaceId: workspaceId)));
// View
getIt.registerFactoryParam<IView, View, void>((view, _) => IViewImpl(repo: ViewRepository(view: view)));
@@ -72,8 +69,8 @@ class HomeDepsResolver {
//Menu Bloc
getIt.registerFactoryParam<MenuBloc, UserProfile, String>(
(user, workspaceId) => MenuBloc(
- workspaceManager: getIt<IWorkspace>(param1: user, param2: workspaceId),
- listener: getIt<IWorkspaceListener>(param1: user, param2: workspaceId),
+ repo: WorkspaceRepo(user: user, workspaceId: workspaceId),
+ listener: getIt<WorkspaceListener>(param1: user, param2: workspaceId),
),
);
diff --git a/frontend/app_flowy/lib/workspace/infrastructure/i_workspace_impl.dart b/frontend/app_flowy/lib/workspace/infrastructure/i_workspace_impl.dart
deleted file mode 100644
index ef1d35fe96..0000000000
--- a/frontend/app_flowy/lib/workspace/infrastructure/i_workspace_impl.dart
+++ /dev/null
@@ -1,46 +0,0 @@
-import 'package:app_flowy/workspace/domain/i_workspace.dart';
-import 'package:app_flowy/workspace/infrastructure/repos/workspace_repo.dart';
-import 'package:dartz/dartz.dart';
-import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
-import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
-
-export 'package:app_flowy/workspace/domain/i_workspace.dart';
-
-class IWorkspaceImpl extends IWorkspace {
- WorkspaceRepo repo;
- IWorkspaceImpl({
- required this.repo,
- });
-
- @override
- Future<Either<App, FlowyError>> createApp({required String name, String? desc}) {
- return repo.createApp(name, desc ?? "");
- }
-
- @override
- Future<Either<List<App>, FlowyError>> getApps() {
- return repo.getApps().then((result) {
- return result.fold(
- (apps) => left(apps),
- (error) => right(error),
- );
- });
- }
-}
-
-class IWorkspaceListenerImpl extends IWorkspaceListener {
- WorkspaceListenerRepo repo;
- IWorkspaceListenerImpl({
- required this.repo,
- });
-
- @override
- void start({WorkspaceAppsChangedCallback? addAppCallback, WorkspaceUpdatedCallback? updatedCallback}) {
- repo.startListening(appsChanged: addAppCallback, update: updatedCallback);
- }
-
- @override
- Future<void> stop() async {
- await repo.close();
- }
-}
diff --git a/frontend/app_flowy/lib/workspace/infrastructure/repos/workspace_repo.dart b/frontend/app_flowy/lib/workspace/infrastructure/repos/workspace_repo.dart
index 8e981fc085..8bba568fc3 100644
--- a/frontend/app_flowy/lib/workspace/infrastructure/repos/workspace_repo.dart
+++ b/frontend/app_flowy/lib/workspace/infrastructure/repos/workspace_repo.dart
@@ -12,9 +12,7 @@ import 'package:flowy_sdk/protobuf/flowy-folder-data-model/workspace.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-folder/dart_notification.pb.dart';
import 'package:flowy_sdk/rust_stream.dart';
-
import 'package:app_flowy/generated/locale_keys.g.dart';
-import 'package:app_flowy/workspace/domain/i_workspace.dart';
import 'helper.dart';
@@ -26,9 +24,9 @@ class WorkspaceRepo {
required this.workspaceId,
});
- Future<Either<App, FlowyError>> createApp(String appName, String desc) {
+ Future<Either<App, FlowyError>> createApp(String name, String desc) {
final request = CreateAppRequest.create()
- ..name = appName
+ ..name = name
..workspaceId = workspaceId
..desc = desc;
return FolderEventCreateApp(request).send();
@@ -127,3 +125,22 @@ class WorkspaceListenerRepo {
// _update = null;
}
}
+
+typedef WorkspaceAppsChangedCallback = void Function(Either<List<App>, FlowyError> appsOrFail);
+
+typedef WorkspaceUpdatedCallback = void Function(String name, String desc);
+
+class WorkspaceListener {
+ WorkspaceListenerRepo repo;
+ WorkspaceListener({
+ required this.repo,
+ });
+
+ void start({WorkspaceAppsChangedCallback? addAppCallback, WorkspaceUpdatedCallback? updatedCallback}) {
+ repo.startListening(appsChanged: addAppCallback, update: updatedCallback);
+ }
+
+ Future<void> stop() async {
+ await repo.close();
+ }
+}