diff --git a/frontend/appflowy_flutter/lib/plugins/document/application/workspace_overview/workspace_overview_bloc.dart b/frontend/appflowy_flutter/lib/plugins/document/application/workspace_overview/workspace_overview_bloc.dart index 20ba0fa67fc0..644da6045283 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/application/workspace_overview/workspace_overview_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/application/workspace_overview/workspace_overview_bloc.dart @@ -3,7 +3,6 @@ import 'package:appflowy/workspace/application/view/view_service.dart'; import 'package:appflowy/workspace/application/workspace/overview/overview_listener.dart'; import 'package:appflowy_backend/log.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; -import 'package:dartz/dartz.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; @@ -69,18 +68,18 @@ class WorkspaceOverviewBloc if (update.deleteChildViews.isNotEmpty) { final res = update.parentViewId == state.view.id - ? Tuple2(state.view, 0) + ? (state.view, 0) : _getView(update.parentViewId, state.view); if (res != null) { - final ViewPB view = res.value1; - final int idx = res.value2; + final ViewPB view = res.$1; + final int idx = res.$2; ViewPB? parentView; if (view.id != state.view.id && view.hasParentViewId()) { parentView = view.parentViewId == state.view.id ? state.view - : _getView(view.parentViewId, state.view)?.value1; + : _getView(view.parentViewId, state.view)?.$1; } final childViews = [...view.childViews]; @@ -103,7 +102,7 @@ class WorkspaceOverviewBloc // Retrieve the view specified in `update.parentViewId` from the cached views // stored in this state to determine if a rebuild is necessary. if (update.updateChildViews.isNotEmpty) { - final view = _getView(update.parentViewId, state.view)?.value1; + final view = _getView(update.parentViewId, state.view)?.$1; final childViews = view != null ? view.childViews : []; if (_isRebuildRequired(childViews, update.updateChildViews)) { @@ -142,11 +141,11 @@ class WorkspaceOverviewBloc return false; } - Tuple2? _getView(String viewId, ViewPB view) { + (ViewPB, int)? _getView(String viewId, ViewPB view) { for (int i = 0; i < view.childViews.length; i++) { final child = view.childViews[i]; if (child.id == viewId) { - return Tuple2(child, i); + return (child, i); } final result = _getView(viewId, child); diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/overview/workspace_overview_block_component.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/overview/workspace_overview_block_component.dart index 054b7ba014bd..96c3a6413d65 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/overview/workspace_overview_block_component.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/overview/workspace_overview_block_component.dart @@ -15,8 +15,8 @@ import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/icon.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:appflowy_editor/appflowy_editor.dart' hide Log; +import 'package:appflowy_result/appflowy_result.dart'; import 'package:collection/collection.dart'; -import 'package:dartz/dartz.dart' hide State; import 'package:easy_localization/easy_localization.dart' hide TextDirection; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flowy_infra_ui/style_widget/hover.dart'; @@ -104,7 +104,7 @@ class _OverviewBlockWidgetState extends State late final Animation _curvedAnimationExpansionController; static const _expansionAnimationDuration = Duration(milliseconds: 400); - late Future>? _future; + late Future>? _future; @override void initState() { @@ -129,13 +129,13 @@ class _OverviewBlockWidgetState extends State @override Widget build(BuildContext context) { - return FutureBuilder>( + return FutureBuilder>( future: _future, builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.done && snapshot.hasData && snapshot.data != null) { - final view = snapshot.data!.getLeftOrNull(); + final view = snapshot.data!.toNullable(); if (view == null) return _buildErrorWidget(viewId); return BlocProvider( @@ -397,7 +397,7 @@ class OverviewItemWidget extends StatelessWidget { Future _fetchView(String id) async { final view = await ViewBackendService.getView(id).then( - (value) => value.swap().toOption().toNullable(), + (value) => value.toNullable(), ); if (view == null) { diff --git a/frontend/appflowy_flutter/lib/workspace/application/view/view_service.dart b/frontend/appflowy_flutter/lib/workspace/application/view/view_service.dart index 3a100de9c2cb..ab5515f0ffe8 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/view/view_service.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/view/view_service.dart @@ -250,7 +250,7 @@ class ViewBackendService { return result; } - static Future> getAllLevelOfViews( + static Future> getAllLevelOfViews( String viewID, ) async { final payload = ViewIdPB.create()..value = viewID; diff --git a/frontend/appflowy_flutter/lib/workspace/application/workspace/overview/overview_listener.dart b/frontend/appflowy_flutter/lib/workspace/application/workspace/overview/overview_listener.dart index 1ca0e101a601..cdedbc046aa3 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/workspace/overview/overview_listener.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/workspace/overview/overview_listener.dart @@ -9,7 +9,7 @@ import 'package:appflowy_backend/protobuf/flowy-folder/notification.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-notification/subject.pb.dart'; import 'package:appflowy_backend/rust_stream.dart'; -import 'package:dartz/dartz.dart'; +import 'package:appflowy_result/appflowy_result.dart'; // parent view of overview block updated typedef ParentViewUpdateNotifier = void Function(ViewPB); @@ -55,7 +55,7 @@ class WorkspaceOverviewListener { void _handleObservableType( FolderNotification ty, - Either result, + FlowyResult result, ) { switch (ty) { case FolderNotification.DidUpdateWorkspaceOverviewParentView: @@ -84,12 +84,12 @@ class WorkspaceOverviewListener { /// Registers an overview block listener Id in the backend, allowing us to receive /// notifications of [FolderNotification.DidUpdateWorkspaceOverviewChildViews] from /// all levels of child views to the specified parent view Id listener. - static Future> addListenerId(String viewId) { + static Future> addListenerId(String viewId) { final payload = ViewIdPB.create()..value = viewId; return FolderEventRegisterWorkspaceOverviewListenerId(payload).send(); } - static Future> removeListener(String viewId) { + static Future> removeListener(String viewId) { final payload = ViewIdPB.create()..value = viewId; return FolderEventRemoveWorkspaceOverviewListenerId(payload).send(); }