refactor: Remove FluffyClient and make it no longer static
This commit is contained in:
parent
6d4af6be05
commit
2320f6b707
8 changed files with 71 additions and 67 deletions
|
|
@ -37,7 +37,6 @@ import 'platform_infos.dart';
|
|||
import '../config/app_config.dart';
|
||||
import '../config/setting_keys.dart';
|
||||
import 'famedlysdk_store.dart';
|
||||
import 'matrix_sdk_extensions.dart/fluffy_client.dart';
|
||||
import 'matrix_sdk_extensions.dart/matrix_locals.dart';
|
||||
|
||||
class NoTokenException implements Exception {
|
||||
|
|
@ -48,7 +47,7 @@ class BackgroundPush {
|
|||
static BackgroundPush _instance;
|
||||
final FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin =
|
||||
FlutterLocalNotificationsPlugin();
|
||||
FluffyClient client;
|
||||
Client client;
|
||||
BuildContext context;
|
||||
GlobalKey<VRouterState> router;
|
||||
String _fcmToken;
|
||||
|
|
@ -89,13 +88,13 @@ class BackgroundPush {
|
|||
}
|
||||
}
|
||||
|
||||
factory BackgroundPush.clientOnly(FluffyClient client) {
|
||||
factory BackgroundPush.clientOnly(Client client) {
|
||||
_instance ??= BackgroundPush._(client);
|
||||
return _instance;
|
||||
}
|
||||
|
||||
factory BackgroundPush(FluffyClient _client, BuildContext _context,
|
||||
GlobalKey<VRouterState> router,
|
||||
factory BackgroundPush(
|
||||
Client _client, BuildContext _context, GlobalKey<VRouterState> router,
|
||||
{final void Function(String errorMsg) onFcmError}) {
|
||||
final instance = BackgroundPush.clientOnly(_client);
|
||||
instance.context = _context;
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
import 'package:matrix/matrix.dart';
|
||||
import 'package:matrix/encryption.dart';
|
||||
import 'package:fluffychat/utils/database/flutter_famedly_sdk_hive_database.dart';
|
||||
import 'package:matrix_api_lite/fake_matrix_api.dart';
|
||||
import '../platform_infos.dart';
|
||||
import '../famedlysdk_store.dart';
|
||||
|
||||
class FluffyClient extends Client {
|
||||
static FluffyClient _instance;
|
||||
|
||||
factory FluffyClient({testMode = false}) {
|
||||
Logs().level = Level.verbose;
|
||||
_instance ??= FluffyClient._internal(testMode: testMode);
|
||||
return _instance;
|
||||
}
|
||||
|
||||
FluffyClient._internal({testMode = false})
|
||||
: super(
|
||||
testMode ? 'FluffyChat Widget Tests' : PlatformInfos.clientName,
|
||||
httpClient: testMode ? FakeMatrixApi() : null,
|
||||
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: testMode
|
||||
? null
|
||||
: FlutterFamedlySdkHiveDatabase.hiveDatabaseBuilder,
|
||||
legacyDatabaseBuilder: testMode ? null : getDatabase,
|
||||
supportedLoginTypes: {
|
||||
AuthenticationTypes.password,
|
||||
if (PlatformInfos.isMobile || PlatformInfos.isWeb)
|
||||
AuthenticationTypes.sso
|
||||
},
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue