fix: filter out the space when opening new tab (#7152)

* fix: filter out the space when opening tab

* test: filter out the space when opening tab
This commit is contained in:
Lucas 2025-01-06 17:10:18 +08:00 committed by GitHub
parent 91236006d4
commit a33cf1f488
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import 'package:appflowy/env/cloud_env.dart';
import 'package:appflowy/plugins/document/presentation/editor_page.dart';
import 'package:appflowy/shared/loading.dart';
import 'package:appflowy/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_menu.dart';
import 'package:appflowy/workspace/presentation/home/tabs/flowy_tab.dart';
@ -71,5 +72,16 @@ void main() {
expect(find.byType(FlowyTab), findsNothing);
});
testWidgets('the space view should not be opened', (tester) async {
await tester.initializeAppFlowy(
cloudType: AuthenticatorType.appflowyCloudSelfHost,
);
await tester.tapGoogleLoginInButton();
await tester.expectToSeeHomePageWithGetStartedPage();
expect(find.byType(AppFlowyEditorPage), findsNothing);
expect(find.text('Blank page'), findsOne);
});
});
}

View File

@ -1,4 +1,5 @@
import 'package:appflowy/user/application/user_listener.dart';
import 'package:appflowy/workspace/application/view/view_ext.dart';
import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/workspace.pb.dart'
@ -48,10 +49,17 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
emit(state.copyWith(isLoading: e.isLoading));
},
didReceiveWorkspaceSetting: (_DidReceiveWorkspaceSetting value) {
// the latest view is shared across all the members of the workspace.
final latestView = value.setting.hasLatestView()
? value.setting.latestView
: state.latestView;
if (latestView != null && latestView.isSpace) {
// If the latest view is a space, we don't need to open it.
return;
}
emit(
state.copyWith(
workspaceSetting: value.setting,

View File

@ -70,6 +70,10 @@ class TabsBloc extends Bloc<TabsEvent, TabsState> {
..setSecondaryPlugin(BlankPagePlugin());
emit(state.openPlugin(plugin: plugin, setLatest: setLatest));
if (setLatest) {
// the space view should be filtered out.
if (view != null && view.isSpace) {
return;
}
_setLatestOpenView(view);
}
},