mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-30 16:29:30 +01:00
refactor: Minor chatlist refactoring
This commit is contained in:
parent
47075a72d7
commit
f8555342ec
@ -1,9 +1,8 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:flutter_app_lock/flutter_app_lock.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:universal_html/html.dart' as html;
|
||||||
|
|
||||||
import 'package:fluffychat/utils/client_manager.dart';
|
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
|
// To make sure that the parts of flutter needed are started up already, we need to ensure that the
|
||||||
// widget bindings are initialized already.
|
// widget bindings are initialized already.
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
FlutterError.onError =
|
|
||||||
(FlutterErrorDetails details) => Zone.current.handleUncaughtError(
|
|
||||||
details.exception,
|
|
||||||
details.stack ?? StackTrace.current,
|
|
||||||
);
|
|
||||||
|
|
||||||
|
Logs().nativeColors = !PlatformInfos.isIOS;
|
||||||
final clients = await ClientManager.getClients();
|
final clients = await ClientManager.getClients();
|
||||||
|
|
||||||
if (PlatformInfos.isMobile) {
|
if (PlatformInfos.isMobile) {
|
||||||
|
@ -268,8 +268,10 @@ class ChatListController extends State<ChatList>
|
|||||||
|
|
||||||
void editSpace(BuildContext context, String spaceId) async {
|
void editSpace(BuildContext context, String spaceId) async {
|
||||||
await Matrix.of(context).client.getRoomById(spaceId)!.postLoad();
|
await Matrix.of(context).client.getRoomById(spaceId)!.postLoad();
|
||||||
|
if (mounted) {
|
||||||
VRouter.of(context).toSegments(['spaces', spaceId]);
|
VRouter.of(context).toSegments(['spaces', spaceId]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Needs to match GroupsSpacesEntry for 'separate group' checking.
|
// Needs to match GroupsSpacesEntry for 'separate group' checking.
|
||||||
List<Room> get spaces =>
|
List<Room> get spaces =>
|
||||||
@ -512,6 +514,7 @@ class ChatListController extends State<ChatList>
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (result.error == null) {
|
if (result.error == null) {
|
||||||
|
if (!mounted) return;
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text(L10n.of(context)!.chatHasBeenAddedToThisSpace),
|
content: Text(L10n.of(context)!.chatHasBeenAddedToThisSpace),
|
||||||
@ -545,14 +548,16 @@ class ChatListController extends State<ChatList>
|
|||||||
if (client.encryption?.keyManager.enabled == true) {
|
if (client.encryption?.keyManager.enabled == true) {
|
||||||
if (await client.encryption?.keyManager.isCached() == false ||
|
if (await client.encryption?.keyManager.isCached() == false ||
|
||||||
await client.encryption?.crossSigning.isCached() == false ||
|
await client.encryption?.crossSigning.isCached() == false ||
|
||||||
client.isUnknownSession) {
|
client.isUnknownSession && !mounted) {
|
||||||
await BootstrapDialog(client: client).show(context);
|
await BootstrapDialog(client: client).show(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
waitForFirstSync = true;
|
waitForFirstSync = true;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,6 +597,7 @@ class ChatListController extends State<ChatList>
|
|||||||
}
|
}
|
||||||
|
|
||||||
void editBundlesForAccount(String? userId, String? activeBundle) async {
|
void editBundlesForAccount(String? userId, String? activeBundle) async {
|
||||||
|
final l10n = L10n.of(context)!;
|
||||||
final client = Matrix.of(context)
|
final client = Matrix.of(context)
|
||||||
.widget
|
.widget
|
||||||
.clients[Matrix.of(context).getClientIndexByMatrixId(userId!)];
|
.clients[Matrix.of(context).getClientIndexByMatrixId(userId!)];
|
||||||
@ -615,10 +621,8 @@ class ChatListController extends State<ChatList>
|
|||||||
case EditBundleAction.addToBundle:
|
case EditBundleAction.addToBundle:
|
||||||
final bundle = await showTextInputDialog(
|
final bundle = await showTextInputDialog(
|
||||||
context: context,
|
context: context,
|
||||||
title: L10n.of(context)!.bundleName,
|
title: l10n.bundleName,
|
||||||
textFields: [
|
textFields: [DialogTextField(hintText: l10n.bundleName)]);
|
||||||
DialogTextField(hintText: L10n.of(context)!.bundleName)
|
|
||||||
]);
|
|
||||||
if (bundle == null || bundle.isEmpty || bundle.single.isEmpty) return;
|
if (bundle == null || bundle.isEmpty || bundle.single.isEmpty) return;
|
||||||
await showFutureLoadingDialog(
|
await showFutureLoadingDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
Loading…
Reference in New Issue
Block a user