feat: Pick share keys with

This commit is contained in:
Krille 2025-02-04 15:07:07 +01:00
commit 9f9f52fa02
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652
7 changed files with 67 additions and 7 deletions

View file

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