Merge pull request #659 from AppFlowy-IO/fix/resize_window_issue

fix: open the latest view when AppFlowy launch.
This commit is contained in:
Nathan.fooo 2022-07-20 20:36:05 +08:00 committed by GitHub
commit 5cf1ede6f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -122,7 +122,10 @@ class _HomeScreenState extends State<HomeScreen> {
);
final latestView = workspaceSetting.hasLatestView() ? workspaceSetting.latestView : null;
getIt<MenuSharedState>().latestOpenView = latestView;
if (getIt<MenuSharedState>().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<MenuSharedState>().latestOpenView = latestView;
}
return FocusTraversalGroup(child: RepaintBoundary(child: homeMenu));
}

View File

@ -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) {