|
|
@ -2,6 +2,7 @@ import 'dart:io';
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:collection/collection.dart';
|
|
|
|
import 'package:desktop_notifications/desktop_notifications.dart';
|
|
|
|
import 'package:desktop_notifications/desktop_notifications.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
|
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
|
|
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
|
|
@ -13,6 +14,7 @@ import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'package:universal_html/html.dart' as html;
|
|
|
|
import 'package:universal_html/html.dart' as html;
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:fluffychat/config/app_config.dart';
|
|
|
|
import 'package:fluffychat/config/app_config.dart';
|
|
|
|
|
|
|
|
import 'package:fluffychat/config/setting_keys.dart';
|
|
|
|
import 'package:fluffychat/utils/custom_http_client.dart';
|
|
|
|
import 'package:fluffychat/utils/custom_http_client.dart';
|
|
|
|
import 'package:fluffychat/utils/custom_image_resizer.dart';
|
|
|
|
import 'package:fluffychat/utils/custom_image_resizer.dart';
|
|
|
|
import 'package:fluffychat/utils/init_with_restore.dart';
|
|
|
|
import 'package:fluffychat/utils/init_with_restore.dart';
|
|
|
@ -43,7 +45,8 @@ abstract class ClientManager {
|
|
|
|
clientNames.add(PlatformInfos.clientName);
|
|
|
|
clientNames.add(PlatformInfos.clientName);
|
|
|
|
await store.setStringList(clientNamespace, clientNames.toList());
|
|
|
|
await store.setStringList(clientNamespace, clientNames.toList());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
final clients = clientNames.map(createClient).toList();
|
|
|
|
final clients =
|
|
|
|
|
|
|
|
clientNames.map((name) => createClient(name, store)).toList();
|
|
|
|
if (initialize) {
|
|
|
|
if (initialize) {
|
|
|
|
await Future.wait(
|
|
|
|
await Future.wait(
|
|
|
|
clients.map(
|
|
|
|
clients.map(
|
|
|
@ -97,7 +100,9 @@ abstract class ClientManager {
|
|
|
|
? const NativeImplementationsDummy()
|
|
|
|
? const NativeImplementationsDummy()
|
|
|
|
: NativeImplementationsIsolate(compute);
|
|
|
|
: NativeImplementationsIsolate(compute);
|
|
|
|
|
|
|
|
|
|
|
|
static Client createClient(String clientName) {
|
|
|
|
static Client createClient(String clientName, SharedPreferences store) {
|
|
|
|
|
|
|
|
final shareKeysWith = store.getString(SettingKeys.shareKeysWith) ?? 'all';
|
|
|
|
|
|
|
|
|
|
|
|
return Client(
|
|
|
|
return Client(
|
|
|
|
clientName,
|
|
|
|
clientName,
|
|
|
|
httpClient:
|
|
|
|
httpClient:
|
|
|
@ -122,6 +127,9 @@ abstract class ClientManager {
|
|
|
|
customImageResizer: PlatformInfos.isMobile ? customImageResizer : null,
|
|
|
|
customImageResizer: PlatformInfos.isMobile ? customImageResizer : null,
|
|
|
|
defaultNetworkRequestTimeout: const Duration(minutes: 30),
|
|
|
|
defaultNetworkRequestTimeout: const Duration(minutes: 30),
|
|
|
|
enableDehydratedDevices: true,
|
|
|
|
enableDehydratedDevices: true,
|
|
|
|
|
|
|
|
shareKeysWith: ShareKeysWith.values
|
|
|
|
|
|
|
|
.singleWhereOrNull((share) => share.name == shareKeysWith) ??
|
|
|
|
|
|
|
|
ShareKeysWith.all,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|