From da3fd117378053dee1195f7618dd3d8eb8fcece6 Mon Sep 17 00:00:00 2001 From: appflowy Date: Wed, 20 Jul 2022 20:08:42 +0800 Subject: [PATCH] fix: open the latest view when AppFlowy launch. --- .../lib/workspace/presentation/home/home_screen.dart | 5 ++++- .../app_flowy/lib/workspace/presentation/home/menu/menu.dart | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart b/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart index f3a9f6773a..d1d5321848 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart @@ -122,7 +122,10 @@ class _HomeScreenState extends State { ); final latestView = workspaceSetting.hasLatestView() ? workspaceSetting.latestView : null; - getIt().latestOpenView = latestView; + if (getIt().latestOpenView == null) { + /// AppFlowy will open the view that the last time the user opened it. The _buildHomeMenu will get called when AppFlowy's screen resizes. So we only set the latestOpenView when it's null. + getIt().latestOpenView = latestView; + } return FocusTraversalGroup(child: RepaintBoundary(child: homeMenu)); } diff --git a/frontend/app_flowy/lib/workspace/presentation/home/menu/menu.dart b/frontend/app_flowy/lib/workspace/presentation/home/menu/menu.dart index ef5e20bb6b..3976598b7b 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/menu/menu.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/menu/menu.dart @@ -164,7 +164,9 @@ class MenuSharedState { ViewPB? get latestOpenView => _latestOpenView.value; set latestOpenView(ViewPB? view) { - _latestOpenView.value = view; + if (_latestOpenView.value != view) { + _latestOpenView.value = view; + } } VoidCallback addLatestViewListener(void Function(ViewPB?) callback) {