Skip to content

Commit

Permalink
nav: Make HomePage the only initial route with an initial account
Browse files Browse the repository at this point in the history
Signed-off-by: Zixuan James Li <[email protected]>
  • Loading branch information
PIG208 committed Dec 4, 2024
1 parent 4b4aad6 commit 36e48c4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
8 changes: 3 additions & 5 deletions lib/widgets/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import 'about_zulip.dart';
import 'actions.dart';
import 'dialog.dart';
import 'home.dart';
import 'inbox.dart';
import 'login.dart';
import 'page.dart';
import 'store.dart';
Expand Down Expand Up @@ -209,11 +208,10 @@ class _ZulipAppState extends State<ZulipApp> with WidgetsBindingObserver {

onGenerateInitialRoutes: (_) {
return [
MaterialWidgetRoute(page: const ChooseAccountPage()),
if (initialAccountId != null) ...[
if (initialAccountId != null)
HomePage.buildRoute(accountId: initialAccountId),
InboxPage.buildRoute(accountId: initialAccountId),
],
if (initialAccountId == null)
MaterialWidgetRoute(page: const ChooseAccountPage()),
];
});
}));
Expand Down
7 changes: 2 additions & 5 deletions test/notifications/display_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import 'package:zulip/notifications/receive.dart';
import 'package:zulip/widgets/app.dart';
import 'package:zulip/widgets/color.dart';
import 'package:zulip/widgets/home.dart';
import 'package:zulip/widgets/inbox.dart';
import 'package:zulip/widgets/message_list.dart';
import 'package:zulip/widgets/page.dart';
import 'package:zulip/widgets/theme.dart';
Expand Down Expand Up @@ -930,15 +929,13 @@ void main() {

void takeStartingRoutes({bool withAccount = true}) {
final expected = <Condition<Object?>>[
(it) => it.isA<WidgetRoute>().page.isA<ChooseAccountPage>(),
if (withAccount) ...[
(it) => it.isA<MaterialAccountWidgetRoute>()
..accountId.equals(eg.selfAccount.id)
..page.isA<HomePage>(),
(it) => it.isA<MaterialAccountWidgetRoute>()
..accountId.equals(eg.selfAccount.id)
..page.isA<InboxPage>(),
],
if (!withAccount)
(it) => it.isA<WidgetRoute>().page.isA<ChooseAccountPage>(),
];
check(pushedRoutes.take(expected.length)).deepEquals(expected);
pushedRoutes.removeRange(0, expected.length);
Expand Down
7 changes: 1 addition & 6 deletions test/widgets/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:zulip/log.dart';
import 'package:zulip/model/database.dart';
import 'package:zulip/widgets/app.dart';
import 'package:zulip/widgets/home.dart';
import 'package:zulip/widgets/inbox.dart';
import 'package:zulip/widgets/page.dart';

import '../example_data.dart' as eg;
Expand Down Expand Up @@ -40,7 +39,7 @@ void main() {
]);
});

testWidgets('when have accounts, go to inbox for first account', (tester) async {
testWidgets('when have accounts, go to home page for first account', (tester) async {
addTearDown(testBinding.reset);

// We'll need per-account data for the account that a page will be opened
Expand All @@ -49,13 +48,9 @@ void main() {
await testBinding.globalStore.insertAccount(eg.otherAccount.toCompanion(false));

check(await initialRoutes(tester)).deepEquals(<Condition<Object?>>[
(it) => it.isA<WidgetRoute>().page.isA<ChooseAccountPage>(),
(it) => it.isA<MaterialAccountWidgetRoute>()
..accountId.equals(eg.selfAccount.id)
..page.isA<HomePage>(),
(it) => it.isA<MaterialAccountWidgetRoute>()
..accountId.equals(eg.selfAccount.id)
..page.isA<InboxPage>(),
]);
});
});
Expand Down

0 comments on commit 36e48c4

Please sign in to comment.