Skip to content

Commit 02fd2bc

Browse files
authored
Merge pull request #1161 from Poly-Pixel/trash-resize-fix
fix: only open the last opened view if plugin is blank
2 parents 7037378 + 510fd11 commit 02fd2bc

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,24 @@ class _HomeScreenState extends State<HomeScreen> {
144144
collapsedNotifier: getIt<HomeStackManager>().collapsedNotifier,
145145
);
146146

147-
final latestView =
148-
workspaceSetting.hasLatestView() ? workspaceSetting.latestView : null;
149-
if (getIt<MenuSharedState>().latestOpenView == null) {
150-
/// 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.
151-
getIt<MenuSharedState>().latestOpenView = latestView;
147+
// Only open the last opened view if the [HomeStackManager] current opened
148+
// plugin is blank and the last opened view is not null.
149+
//
150+
// All opened widgets that display on the home screen are in the form
151+
// of plugins. There is a list of built-in plugins defined in the
152+
// [PluginType] enum, including board, grid and trash.
153+
154+
if (getIt<HomeStackManager>().plugin.ty == PluginType.blank) {
155+
// Open the last opened view.
156+
if (workspaceSetting.hasLatestView()) {
157+
final view = workspaceSetting.latestView;
158+
final plugin = makePlugin(
159+
pluginType: view.pluginType,
160+
data: view,
161+
);
162+
getIt<HomeStackManager>().setPlugin(plugin);
163+
getIt<MenuSharedState>().latestOpenView = view;
164+
}
152165
}
153166

154167
return FocusTraversalGroup(child: RepaintBoundary(child: homeMenu));

frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ class HomeStackManager {
144144
}
145145

146146
PublishNotifier<bool> get collapsedNotifier => _notifier.collapsedNotifier;
147+
Plugin get plugin => _notifier.plugin;
147148

148149
void setPlugin(Plugin newPlugin) {
149150
_notifier.plugin = newPlugin;

0 commit comments

Comments
 (0)