Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
remove app interface
appflowy99cadf98d205
diff --git a/frontend/app_flowy/lib/workspace/application/app/app_bloc.dart b/frontend/app_flowy/lib/workspace/application/app/app_bloc.dartindex 438941fe2f..4be21331b7 100644--- a/frontend/app_flowy/lib/workspace/application/app/app_bloc.dart+++ b/frontend/app_flowy/lib/workspace/application/app/app_bloc.dart@@ -1,4 +1,4 @@-import 'package:app_flowy/workspace/domain/i_app.dart';+import 'package:app_flowy/workspace/infrastructure/repos/app_repo.dart';import 'package:flowy_log/flowy_log.dart';import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';@@ -10,18 +10,18 @@ import 'package:dartz/dartz.dart';part 'app_bloc.freezed.dart';class AppBloc extends Bloc<AppEvent, AppState> {- final IApp appManager;- final IAppListenr listener;- AppBloc({required App app, required this.appManager, required this.listener}) : super(AppState.initial(app)) {+ final AppRepository repo;+ final AppListenerRepository listener;+ AppBloc({required App app, required this.repo, required this.listener}) : super(AppState.initial(app)) {on<AppEvent>((event, emit) async {await event.map(initial: (e) async {- listener.start(- viewsChangeCallback: _handleViewsChanged,- updatedCallback: (app) => add(AppEvent.appDidUpdate(app)),+ listener.startListening(+ viewsChanged: _handleViewsChanged,+ appUpdated: (app) => add(AppEvent.appDidUpdate(app)),);await _fetchViews(emit);}, createView: (CreateView value) async {- final viewOrFailed = await appManager.createView(name: value.name, desc: value.desc, viewType: value.viewType);+ final viewOrFailed = await repo.createView(name: value.name, desc: value.desc, viewType: value.viewType);viewOrFailed.fold((view) => emit(state.copyWith(latestCreatedView: view,@@ -35,13 +35,13 @@ class AppBloc extends Bloc<AppEvent, AppState> {}, didReceiveViews: (e) async {await handleDidReceiveViews(e.views, emit);}, delete: (e) async {- final result = await appManager.delete();+ final result = await repo.delete();result.fold((unit) => emit(state.copyWith(successOrFailure: left(unit))),(error) => emit(state.copyWith(successOrFailure: right(error))),);}, rename: (e) async {- final result = await appManager.rename(e.newName);+ final result = await repo.updateApp(name: e.newName);result.fold((l) => emit(state.copyWith(successOrFailure: left(unit))),(error) => emit(state.copyWith(successOrFailure: right(error))),@@ -54,7 +54,7 @@ class AppBloc extends Bloc<AppEvent, AppState> {@overrideFuture<void> close() async {- await listener.stop();+ await listener.close();return super.close();}@@ -81,7 +81,7 @@ class AppBloc extends Bloc<AppEvent, AppState> {}Future<void> _fetchViews(Emitter<AppState> emit) async {- final viewsOrFailed = await appManager.getViews();+ final viewsOrFailed = await repo.getViews();viewsOrFailed.fold((apps) => emit(state.copyWith(views: apps)),(error) {diff --git a/frontend/app_flowy/lib/workspace/domain/i_app.dart b/frontend/app_flowy/lib/workspace/domain/i_app.dartdeleted file mode 100644index a276c71a0a..0000000000--- a/frontend/app_flowy/lib/workspace/domain/i_app.dart+++ /dev/null@@ -1,22 +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 AppUpdatedCallback = void Function(App app);-typedef AppViewsChangeCallback = void Function(Either<List<View>, FlowyError> viewsOrFailed);--abstract class IApp {- Future<Either<List<View>, FlowyError>> getViews();-- Future<Either<View, FlowyError>> createView({required String name, String? desc, required ViewType viewType});-- Future<Either<Unit, FlowyError>> delete();-- Future<Either<Unit, FlowyError>> rename(String newName);-}--abstract class IAppListenr {- void start({AppViewsChangeCallback? viewsChangeCallback, AppUpdatedCallback? 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.dartindex 5b481f9421..7c067a3d14 100644--- a/frontend/app_flowy/lib/workspace/infrastructure/deps_resolver.dart+++ b/frontend/app_flowy/lib/workspace/infrastructure/deps_resolver.dart@@ -11,7 +11,6 @@ import 'package:app_flowy/workspace/domain/i_share.dart';import 'package:app_flowy/workspace/domain/i_trash.dart';import 'package:app_flowy/workspace/domain/i_view.dart';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/repos/app_repo.dart';@@ -39,11 +38,6 @@ class HomeDepsResolver {),);- //App- getIt.registerFactoryParam<IApp, String, void>((appId, _) => IAppImpl(repo: AppRepository(appId: appId)));- getIt.registerFactoryParam<IAppListenr, String, void>(- (appId, _) => IAppListenerhImpl(repo: AppListenerRepository(appId: appId)));-//workspacegetIt.registerFactoryParam<WorkspaceListener, UserProfile, String>((user, workspaceId) => WorkspaceListener(repo: WorkspaceListenerRepo(user: user, workspaceId: workspaceId)));@@ -81,8 +75,8 @@ class HomeDepsResolver {getIt.registerFactoryParam<AppBloc, App, void>((app, _) => AppBloc(app: app,- appManager: getIt<IApp>(param1: app.id),- listener: getIt<IAppListenr>(param1: app.id),+ repo: AppRepository(appId: app.id),+ listener: AppListenerRepository(appId: app.id),),);diff --git a/frontend/app_flowy/lib/workspace/infrastructure/i_app_impl.dart b/frontend/app_flowy/lib/workspace/infrastructure/i_app_impl.dartdeleted file mode 100644index cfb92287df..0000000000--- a/frontend/app_flowy/lib/workspace/infrastructure/i_app_impl.dart+++ /dev/null@@ -1,55 +0,0 @@-import 'package:app_flowy/workspace/infrastructure/repos/app_repo.dart';-import 'package:dartz/dartz.dart';-import 'package:app_flowy/workspace/domain/i_app.dart';-import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';-import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';-export 'package:app_flowy/workspace/domain/i_app.dart';--class IAppImpl extends IApp {- AppRepository repo;- IAppImpl({- required this.repo,- });-- @override- Future<Either<List<View>, FlowyError>> getViews() {- return repo.getViews();- }-- @override- Future<Either<View, FlowyError>> createView({required String name, String? desc, required ViewType viewType}) {- return repo.createView(name, desc ?? "", viewType).then((result) {- return result.fold(- (view) => left(view),- (r) => right(r),- );- });- }-- @override- Future<Either<Unit, FlowyError>> delete() {- return repo.delete();- }-- @override- Future<Either<Unit, FlowyError>> rename(String newName) {- return repo.updateApp(name: newName);- }-}--class IAppListenerhImpl extends IAppListenr {- AppListenerRepository repo;- IAppListenerhImpl({- required this.repo,- });-- @override- Future<void> stop() async {- await repo.close();- }-- @override- void start({AppViewsChangeCallback? viewsChangeCallback, AppUpdatedCallback? updatedCallback}) {- repo.startListening(viewsChanged: viewsChangeCallback, update: updatedCallback);- }-}diff --git a/frontend/app_flowy/lib/workspace/infrastructure/repos/app_repo.dart b/frontend/app_flowy/lib/workspace/infrastructure/repos/app_repo.dartindex e3dc00cf6b..0077f718eb 100644--- a/frontend/app_flowy/lib/workspace/infrastructure/repos/app_repo.dart+++ b/frontend/app_flowy/lib/workspace/infrastructure/repos/app_repo.dart@@ -1,6 +1,5 @@import 'dart:async';import 'dart:typed_data';-import 'package:app_flowy/workspace/domain/i_app.dart';import 'package:dartz/dartz.dart';import 'package:flowy_log/flowy_log.dart';import 'package:flowy_sdk/dispatch/dispatch.dart';@@ -24,7 +23,11 @@ class AppRepository {return FolderEventReadApp(request).send();}- Future<Either<View, FlowyError>> createView(String name, String desc, ViewType viewType) {+ Future<Either<View, FlowyError>> createView({+ required String name,+ required String desc,+ required ViewType viewType,+ }) {final request = CreateViewRequest.create()..belongToId = appId..name = name@@ -60,10 +63,13 @@ class AppRepository {}}+typedef AppDidUpdateCallback = void Function(App app);+typedef ViewsDidChangeCallback = void Function(Either<List<View>, FlowyError> viewsOrFailed);+class AppListenerRepository {StreamSubscription<SubscribeObject>? _subscription;- AppViewsChangeCallback? _viewsChanged;- AppUpdatedCallback? _update;+ ViewsDidChangeCallback? _viewsChanged;+ AppDidUpdateCallback? _updated;late FolderNotificationParser _parser;String appId;@@ -71,9 +77,9 @@ class AppListenerRepository {required this.appId,});- void startListening({AppViewsChangeCallback? viewsChanged, AppUpdatedCallback? update}) {+ void startListening({ViewsDidChangeCallback? viewsChanged, AppDidUpdateCallback? appUpdated}) {_viewsChanged = viewsChanged;- _update = update;+ _updated = appUpdated;_parser = FolderNotificationParser(id: appId, callback: _bservableCallback);_subscription = RustStreamReceiver.listen((observable) => _parser.parse(observable));}@@ -92,11 +98,11 @@ class AppListenerRepository {}break;case FolderNotification.AppUpdated:- if (_update != null) {+ if (_updated != null) {result.fold((payload) {final app = App.fromBuffer(payload);- _update!(app);+ _updated!(app);},(error) => Log.error(error),);@@ -110,6 +116,6 @@ class AppListenerRepository {Future<void> close() async {await _subscription?.cancel();_viewsChanged = null;- _update = null;+ _updated = null;}}