refactor: Minor chatlist refactoring

This commit is contained in:
Christian Pauly 2022-11-02 09:57:06 +01:00
parent 47075a72d7
commit f8555342ec
2 changed files with 15 additions and 16 deletions

View File

@ -1,9 +1,8 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app_lock/flutter_app_lock.dart';
import 'package:matrix/matrix.dart';
import 'package:universal_html/html.dart' as html;
import 'package:fluffychat/utils/client_manager.dart';
@ -17,12 +16,8 @@ void main() async {
// To make sure that the parts of flutter needed are started up already, we need to ensure that the
// widget bindings are initialized already.
WidgetsFlutterBinding.ensureInitialized();
FlutterError.onError =
(FlutterErrorDetails details) => Zone.current.handleUncaughtError(
details.exception,
details.stack ?? StackTrace.current,
);
Logs().nativeColors = !PlatformInfos.isIOS;
final clients = await ClientManager.getClients();
if (PlatformInfos.isMobile) {

View File

@ -268,7 +268,9 @@ class ChatListController extends State<ChatList>
void editSpace(BuildContext context, String spaceId) async {
await Matrix.of(context).client.getRoomById(spaceId)!.postLoad();
VRouter.of(context).toSegments(['spaces', spaceId]);
if (mounted) {
VRouter.of(context).toSegments(['spaces', spaceId]);
}
}
// Needs to match GroupsSpacesEntry for 'separate group' checking.
@ -512,6 +514,7 @@ class ChatListController extends State<ChatList>
},
);
if (result.error == null) {
if (!mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(L10n.of(context)!.chatHasBeenAddedToThisSpace),
@ -545,14 +548,16 @@ class ChatListController extends State<ChatList>
if (client.encryption?.keyManager.enabled == true) {
if (await client.encryption?.keyManager.isCached() == false ||
await client.encryption?.crossSigning.isCached() == false ||
client.isUnknownSession) {
client.isUnknownSession && !mounted) {
await BootstrapDialog(client: client).show(context);
}
}
}
setState(() {
waitForFirstSync = true;
});
if (mounted) {
setState(() {
waitForFirstSync = true;
});
}
return;
}
@ -592,6 +597,7 @@ class ChatListController extends State<ChatList>
}
void editBundlesForAccount(String? userId, String? activeBundle) async {
final l10n = L10n.of(context)!;
final client = Matrix.of(context)
.widget
.clients[Matrix.of(context).getClientIndexByMatrixId(userId!)];
@ -615,10 +621,8 @@ class ChatListController extends State<ChatList>
case EditBundleAction.addToBundle:
final bundle = await showTextInputDialog(
context: context,
title: L10n.of(context)!.bundleName,
textFields: [
DialogTextField(hintText: L10n.of(context)!.bundleName)
]);
title: l10n.bundleName,
textFields: [DialogTextField(hintText: l10n.bundleName)]);
if (bundle == null || bundle.isEmpty || bundle.single.isEmpty) return;
await showFutureLoadingDialog(
context: context,