From b0c2b04a2da4c1238e36699c7c73282b9ea2abeb Mon Sep 17 00:00:00 2001 From: Nathan Date: Mon, 21 Apr 2025 22:10:52 +0800 Subject: [PATCH] fix: empty view id --- .../lib/mobile/presentation/home/mobile_home_page.dart | 2 +- frontend/appflowy_flutter/lib/plugins/blank/blank.dart | 2 +- .../lib/workspace/application/view/view_bloc.dart | 2 +- .../lib/workspace/application/view/view_service.dart | 9 +++++++++ .../lib/workspace/presentation/home/home_stack.dart | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/home/mobile_home_page.dart b/frontend/appflowy_flutter/lib/mobile/presentation/home/mobile_home_page.dart index fdea8322c3..345a4591d1 100644 --- a/frontend/appflowy_flutter/lib/mobile/presentation/home/mobile_home_page.dart +++ b/frontend/appflowy_flutter/lib/mobile/presentation/home/mobile_home_page.dart @@ -145,7 +145,7 @@ class _MobileHomePageState extends State { void _onLatestViewChange() async { final id = getIt().latestOpenView?.id; - if (id == null) { + if (id == null || id.isEmpty) { return; } await FolderEventSetLatestView(ViewIdPB(value: id)).send(); diff --git a/frontend/appflowy_flutter/lib/plugins/blank/blank.dart b/frontend/appflowy_flutter/lib/plugins/blank/blank.dart index b25bb5af06..ebda487515 100644 --- a/frontend/appflowy_flutter/lib/plugins/blank/blank.dart +++ b/frontend/appflowy_flutter/lib/plugins/blank/blank.dart @@ -36,7 +36,7 @@ class BlankPagePlugin extends Plugin { PluginWidgetBuilder get widgetBuilder => BlankPagePluginWidgetBuilder(); @override - PluginId get id => "BlankStack"; + PluginId get id => ""; @override PluginType get pluginType => PluginType.blank; diff --git a/frontend/appflowy_flutter/lib/workspace/application/view/view_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/view/view_bloc.dart index 7c2a4d9b64..553317f4e4 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/view/view_bloc.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/view/view_bloc.dart @@ -404,7 +404,7 @@ class ViewBloc extends Bloc { }); } - if (update.updateChildViews.isNotEmpty) { + if (update.updateChildViews.isNotEmpty && update.parentViewId.isNotEmpty) { final view = await ViewBackendService.getView(update.parentViewId); final childViews = view.fold((l) => l.childViews, (r) => []); bool isSameOrder = true; 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 709515f1b3..ea74f1861e 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/view/view_service.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/view/view_service.dart @@ -111,6 +111,12 @@ class ViewBackendService { static Future, FlowyError>> getChildViews({ required String viewId, }) { + if (viewId.isEmpty) { + return Future.value( + FlowyResult, FlowyError>.success([]), + ); + } + final payload = ViewIdPB.create()..value = viewId; return FolderEventGetView(payload).send().then((result) { @@ -262,6 +268,9 @@ class ViewBackendService { static Future> getView( String viewId, ) async { + if (viewId.isEmpty) { + Log.error('ViewId is empty'); + } final payload = ViewIdPB.create()..value = viewId; return FolderEventGetView(payload).send(); } diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart index ae3b92a702..464394cd39 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart @@ -631,7 +631,7 @@ class PageNotifier extends ChangeNotifier { } // Set the plugin view as the latest view. - if (setLatest) { + if (setLatest && newPlugin.id.isNotEmpty) { FolderEventSetLatestView(ViewIdPB(value: newPlugin.id)).send(); }