Skip to content

Commit 05628ca

Browse files
app: Query initial-account-id while handling initial routes
This avoids a potential race if the queried account is logged out between the invocation of this Builder callback and `MaterialApp.onGenerateInitialRoutes` (if such a race is possible).
1 parent 6765f66 commit 05628ca

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/widgets/app.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,6 @@ class _ZulipAppState extends State<ZulipApp> with WidgetsBindingObserver {
178178
return GlobalStoreWidget(
179179
child: Builder(builder: (context) {
180180
final globalStore = GlobalStoreWidget.of(context);
181-
// TODO(#524) choose initial account as last one used
182-
final initialAccountId = globalStore.accounts.firstOrNull?.id;
183181
return MaterialApp(
184182
onGenerateTitle: (BuildContext context) {
185183
return ZulipLocalizations.of(context).zulipAppTitle;
@@ -209,6 +207,8 @@ class _ZulipAppState extends State<ZulipApp> with WidgetsBindingObserver {
209207
onGenerateRoute: (_) => null,
210208

211209
onGenerateInitialRoutes: (_) {
210+
// TODO(#524) choose initial account as last one used
211+
final initialAccountId = globalStore.accounts.firstOrNull?.id;
212212
return [
213213
if (initialAccountId == null)
214214
MaterialWidgetRoute(page: const ChooseAccountPage())

0 commit comments

Comments
 (0)