fix: Chat list flickering

This commit is contained in:
Krille Fear 2021-11-09 17:30:04 +01:00
parent bda4727490
commit 3342071acf
2 changed files with 6 additions and 3 deletions

View File

@ -166,9 +166,10 @@ class ChatListController extends State<ChatList> {
void initState() { void initState() {
_initReceiveSharingIntent(); _initReceiveSharingIntent();
WidgetsBinding.instance.addPostFrameCallback( WidgetsBinding.instance.addPostFrameCallback(
(_) => waitForFirstSync().then((_) => checkBootstrap()), (_) => waitForFirstSync.then((_) => checkBootstrap()),
); );
scrollController.addListener(_onScroll); scrollController.addListener(_onScroll);
waitForFirstSync = _waitForFirstSync();
super.initState(); super.initState();
} }
@ -384,7 +385,9 @@ class ChatListController extends State<ChatList> {
setState(() => selectedRoomIds.clear()); setState(() => selectedRoomIds.clear());
} }
Future<void> waitForFirstSync() async { Future<void> waitForFirstSync;
Future<void> _waitForFirstSync() async {
final client = Matrix.of(context).client; final client = Matrix.of(context).client;
await client.roomsLoading; await client.roomsLoading;
await client.accountDataLoading; await client.accountDataLoading;

View File

@ -430,7 +430,7 @@ class _ChatListViewBody extends StatelessWidget {
.rateLimit(const Duration(seconds: 1)), .rateLimit(const Duration(seconds: 1)),
builder: (context, snapshot) { builder: (context, snapshot) {
return FutureBuilder<void>( return FutureBuilder<void>(
future: controller.waitForFirstSync(), future: controller.waitForFirstSync,
builder: (BuildContext context, snapshot) { builder: (BuildContext context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) { if (snapshot.connectionState == ConnectionState.done) {
final rooms = Matrix.of(context) final rooms = Matrix.of(context)