mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-02-23 09:40:40 +01:00
49 lines
1.7 KiB
Dart
49 lines
1.7 KiB
Dart
![]() |
import 'dart:convert';
|
||
|
|
||
|
import 'package:fluffychat/utils/platform_infos.dart';
|
||
|
import 'package:flutter/foundation.dart';
|
||
|
import 'package:matrix/encryption/utils/key_verification.dart';
|
||
|
import 'package:matrix/matrix.dart';
|
||
|
|
||
|
import 'famedlysdk_store.dart';
|
||
|
import 'matrix_sdk_extensions.dart/flutter_matrix_hive_database.dart';
|
||
|
|
||
|
abstract class ClientManager {
|
||
|
static const String clientNamespace = 'im.fluffychat.store.clients';
|
||
|
static Future<List<Client>> getClients() async {
|
||
|
final store = Store();
|
||
|
final clientNames = <String>{PlatformInfos.clientName};
|
||
|
try {
|
||
|
final rawClientNames = await store.getItem(clientNamespace);
|
||
|
if (rawClientNames != null) {
|
||
|
final clientNamesList =
|
||
|
(jsonDecode(rawClientNames) as List).cast<String>();
|
||
|
clientNames.addAll(clientNamesList);
|
||
|
}
|
||
|
} catch (e, s) {
|
||
|
Logs().w('Client names in store are corrupted', e, s);
|
||
|
}
|
||
|
return clientNames
|
||
|
.map((clientName) => Client(
|
||
|
clientName,
|
||
|
enableE2eeRecovery: true,
|
||
|
verificationMethods: {
|
||
|
KeyVerificationMethod.numbers,
|
||
|
if (PlatformInfos.isMobile || PlatformInfos.isLinux)
|
||
|
KeyVerificationMethod.emoji,
|
||
|
},
|
||
|
importantStateEvents: <String>{
|
||
|
'im.ponies.room_emotes', // we want emotes to work properly
|
||
|
},
|
||
|
databaseBuilder: FlutterMatrixHiveStore.hiveDatabaseBuilder,
|
||
|
supportedLoginTypes: {
|
||
|
AuthenticationTypes.password,
|
||
|
if (PlatformInfos.isMobile || PlatformInfos.isWeb)
|
||
|
AuthenticationTypes.sso
|
||
|
},
|
||
|
compute: compute,
|
||
|
))
|
||
|
.toList();
|
||
|
}
|
||
|
}
|