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
feat: optimize error page in database row page and remove unused code (#6193)
Lucas.Xu08e2be367c48
diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/row/row_document.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/row/row_document.dartindex 4d58d6fc32..415e741ad1 100644--- a/frontend/appflowy_flutter/lib/plugins/database/widgets/row/row_document.dart+++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/row/row_document.dart@@ -1,15 +1,14 @@-import 'package:flutter/material.dart';-import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/plugins/database/grid/application/row/row_document_bloc.dart';import 'package:appflowy/plugins/document/application/document_bloc.dart';import 'package:appflowy/plugins/document/presentation/editor_page.dart';import 'package:appflowy/plugins/document/presentation/editor_style.dart';+import 'package:appflowy/shared/flowy_error_page.dart';import 'package:appflowy/workspace/application/view_info/view_info_bloc.dart';import 'package:appflowy_backend/log.dart';import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';import 'package:easy_localization/easy_localization.dart';-import 'package:flowy_infra_ui/widget/error_page.dart';+import 'package:flutter/material.dart';import 'package:flutter_bloc/flutter_bloc.dart';class RowDocument extends StatelessWidget {@@ -27,17 +26,22 @@ class RowDocument extends StatelessWidget {return BlocProvider<RowDocumentBloc>(create: (context) => RowDocumentBloc(viewId: viewId, rowId: rowId)..add(const RowDocumentEvent.initial()),- child: BlocBuilder<RowDocumentBloc, RowDocumentState>(+ child: BlocConsumer<RowDocumentBloc, RowDocumentState>(+ listener: (_, state) => state.loadingState.maybeWhen(+ error: (error) => Log.error('RowDocument error: $error'),+ orElse: () => null,+ ),builder: (context, state) {return state.loadingState.when(loading: () => const Center(child: CircularProgressIndicator.adaptive(),),- error: (error) => FlowyErrorPage.message(- error.toString(),- howToFix: LocaleKeys.errorDialog_howToFixFallback.tr(),+ error: (error) => Center(+ child: AppFlowyErrorPage(+ error: error,+ ),),- finish: () => RowEditor(+ finish: () => _RowEditor(viewPB: state.viewPB!,onIsEmptyChanged: (isEmpty) => context.read<RowDocumentBloc>()@@ -50,9 +54,8 @@ class RowDocument extends StatelessWidget {}}-class RowEditor extends StatefulWidget {- const RowEditor({- super.key,+class _RowEditor extends StatelessWidget {+ const _RowEditor({required this.viewPB,this.onIsEmptyChanged,});@@ -60,36 +63,23 @@ class RowEditor extends StatefulWidget {final ViewPB viewPB;final void Function(bool)? onIsEmptyChanged;- @override- State<RowEditor> createState() => _RowEditorState();-}--class _RowEditorState extends State<RowEditor> {- late final DocumentBloc documentBloc;-- @override- void initState() {- super.initState();- documentBloc = DocumentBloc(documentId: widget.viewPB.id)- ..add(const DocumentEvent.initial());- }-- @override- void dispose() {- documentBloc.close();- super.dispose();- }-@overrideWidget build(BuildContext context) {- return MultiBlocProvider(- providers: [BlocProvider.value(value: documentBloc)],+ return BlocProvider(+ create: (context) => DocumentBloc(documentId: viewPB.id)+ ..add(const DocumentEvent.initial()),child: BlocListener<DocumentBloc, DocumentState>(listenWhen: (previous, current) =>previous.isDocumentEmpty != current.isDocumentEmpty,- listener: (context, state) {+ listener: (_, state) {if (state.isDocumentEmpty != null) {- widget.onIsEmptyChanged?.call(state.isDocumentEmpty!);+ onIsEmptyChanged?.call(state.isDocumentEmpty!);+ }+ if (state.error != null) {+ Log.error('RowEditor error: ${state.error}');+ }+ if (state.editorState == null) {+ Log.error('RowEditor unable to get editorState');}},child: BlocBuilder<DocumentBloc, DocumentState>(@@ -101,18 +91,18 @@ class _RowEditorState extends State<RowEditor> {final editorState = state.editorState;final error = state.error;if (error != null || editorState == null) {- Log.error(error);- return FlowyErrorPage.message(- error.toString(),- howToFix: LocaleKeys.errorDialog_howToFixFallback.tr(),+ return Center(+ child: AppFlowyErrorPage(+ error: error,+ ),);}- return IntrinsicHeight(- child: Container(- constraints: const BoxConstraints(minHeight: 300),- child: BlocProvider<ViewInfoBloc>(- create: (context) => ViewInfoBloc(view: widget.viewPB),+ return BlocProvider<ViewInfoBloc>(+ create: (context) => ViewInfoBloc(view: viewPB),+ child: IntrinsicHeight(+ child: Container(+ constraints: const BoxConstraints(minHeight: 300),child: AppFlowyEditorPage(shrinkWrap: true,autoFocus: false,diff --git a/frontend/appflowy_flutter/lib/plugins/database_document/database_document_page.dart b/frontend/appflowy_flutter/lib/plugins/database_document/database_document_page.dartindex c08b32d9ec..65b6542d4f 100644--- a/frontend/appflowy_flutter/lib/plugins/database_document/database_document_page.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_document/database_document_page.dart@@ -1,4 +1,3 @@-import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/plugins/database/application/row/related_row_detail_bloc.dart';import 'package:appflowy/plugins/database/grid/application/row/row_detail_bloc.dart';import 'package:appflowy/plugins/database/grid/presentation/widgets/common/type_option_separator.dart';@@ -9,14 +8,13 @@ import 'package:appflowy/plugins/document/presentation/banner.dart';import 'package:appflowy/plugins/document/presentation/editor_notification.dart';import 'package:appflowy/plugins/document/presentation/editor_page.dart';import 'package:appflowy/plugins/document/presentation/editor_style.dart';+import 'package:appflowy/shared/flowy_error_page.dart';import 'package:appflowy/startup/startup.dart';import 'package:appflowy/workspace/application/action_navigation/action_navigation_bloc.dart';import 'package:appflowy/workspace/application/action_navigation/navigation_action.dart';import 'package:appflowy_backend/log.dart';import 'package:appflowy_backend/protobuf/flowy-folder/protobuf.dart';import 'package:appflowy_editor/appflowy_editor.dart' hide Log;-import 'package:easy_localization/easy_localization.dart';-import 'package:flowy_infra_ui/widget/error_page.dart';import 'package:flutter/material.dart';import 'package:flutter_bloc/flutter_bloc.dart';@@ -83,9 +81,10 @@ class _DatabaseDocumentPageState extends State<DatabaseDocumentPage> {final error = state.error;if (error != null || editorState == null) {Log.error(error);- return FlowyErrorPage.message(- error.toString(),- howToFix: LocaleKeys.errorDialog_howToFixFallback.tr(),+ return Center(+ child: AppFlowyErrorPage(+ error: error,+ ),);}