From 5d89f05676108a18325c524e7b9d49bf82b308a9 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Sun, 13 Nov 2022 12:40:10 +0100 Subject: [PATCH] chore: Better load first client --- lib/main.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index aeb1c9ae..8721d773 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:collection/collection.dart'; import 'package:flutter_app_lock/flutter_app_lock.dart'; import 'package:matrix/matrix.dart'; import 'package:universal_html/html.dart' as html; @@ -19,8 +20,11 @@ void main() async { Logs().nativeColors = !PlatformInfos.isIOS; final clients = await ClientManager.getClients(); - await clients.first.roomsLoading; - await clients.first.accountDataLoading; + + // Preload first client + final firstClient = clients.firstOrNull; + await firstClient?.roomsLoading; + await firstClient?.accountDataLoading; if (PlatformInfos.isMobile) { BackgroundPush.clientOnly(clients.first);