Merge pull request #1731 from krille-chan/krille/migrate-more-config-options
refactor: Migrate more config options to config viewer
This commit is contained in:
commit
77bc62e38a
5 changed files with 22 additions and 18 deletions
|
|
@ -32,11 +32,6 @@ abstract class SettingKeys {
|
||||||
'chat.fluffy.swipeRightToLeftToReply';
|
'chat.fluffy.swipeRightToLeftToReply';
|
||||||
static const String experimentalVoip = 'chat.fluffy.experimental_voip';
|
static const String experimentalVoip = 'chat.fluffy.experimental_voip';
|
||||||
static const String showPresences = 'chat.fluffy.show_presences';
|
static const String showPresences = 'chat.fluffy.show_presences';
|
||||||
static const String displayChatDetailsColumn =
|
|
||||||
'chat.fluffy.display_chat_details_column';
|
|
||||||
static const String noEncryptionWarningShown =
|
|
||||||
'chat.fluffy.no_encryption_warning_shown';
|
|
||||||
static const String shareKeysWith = 'chat.fluffy.share_keys_with_2';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum AppSettings<T> {
|
enum AppSettings<T> {
|
||||||
|
|
@ -53,6 +48,15 @@ enum AppSettings<T> {
|
||||||
pushNotificationsPusherFormat<String>(
|
pushNotificationsPusherFormat<String>(
|
||||||
'pushNotificationsPusherFormat',
|
'pushNotificationsPusherFormat',
|
||||||
'event_id_only',
|
'event_id_only',
|
||||||
|
),
|
||||||
|
shareKeysWith<String>('chat.fluffy.share_keys_with_2', 'all'),
|
||||||
|
noEncryptionWarningShown<bool>(
|
||||||
|
'chat.fluffy.no_encryption_warning_shown',
|
||||||
|
false,
|
||||||
|
),
|
||||||
|
displayChatDetailsColumn(
|
||||||
|
'chat.fluffy.display_chat_details_column',
|
||||||
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
final String key;
|
final String key;
|
||||||
|
|
|
||||||
|
|
@ -302,8 +302,7 @@ class ChatController extends State<ChatPageWithRoom>
|
||||||
WidgetsBinding.instance.addPostFrameCallback(_shareItems);
|
WidgetsBinding.instance.addPostFrameCallback(_shareItems);
|
||||||
super.initState();
|
super.initState();
|
||||||
_displayChatDetailsColumn = ValueNotifier(
|
_displayChatDetailsColumn = ValueNotifier(
|
||||||
Matrix.of(context).store.getBool(SettingKeys.displayChatDetailsColumn) ??
|
AppSettings.displayChatDetailsColumn.getItem(Matrix.of(context).store),
|
||||||
false,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
sendingClient = Matrix.of(context).client;
|
sendingClient = Matrix.of(context).client;
|
||||||
|
|
@ -1297,10 +1296,10 @@ class ChatController extends State<ChatPageWithRoom>
|
||||||
late final ValueNotifier<bool> _displayChatDetailsColumn;
|
late final ValueNotifier<bool> _displayChatDetailsColumn;
|
||||||
|
|
||||||
void toggleDisplayChatDetailsColumn() async {
|
void toggleDisplayChatDetailsColumn() async {
|
||||||
await Matrix.of(context).store.setBool(
|
await AppSettings.displayChatDetailsColumn.setItem(
|
||||||
SettingKeys.displayChatDetailsColumn,
|
Matrix.of(context).store,
|
||||||
!_displayChatDetailsColumn.value,
|
!_displayChatDetailsColumn.value,
|
||||||
);
|
);
|
||||||
_displayChatDetailsColumn.value = !_displayChatDetailsColumn.value;
|
_displayChatDetailsColumn.value = !_displayChatDetailsColumn.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,10 +111,10 @@ class SettingsSecurityController extends State<SettingsSecurity> {
|
||||||
|
|
||||||
void changeShareKeysWith(ShareKeysWith? shareKeysWith) async {
|
void changeShareKeysWith(ShareKeysWith? shareKeysWith) async {
|
||||||
if (shareKeysWith == null) return;
|
if (shareKeysWith == null) return;
|
||||||
Matrix.of(context).store.setString(
|
AppSettings.shareKeysWith.setItem(
|
||||||
SettingKeys.shareKeysWith,
|
Matrix.of(context).store,
|
||||||
shareKeysWith.name,
|
shareKeysWith.name,
|
||||||
);
|
);
|
||||||
Matrix.of(context).client.shareKeysWith = shareKeysWith;
|
Matrix.of(context).client.shareKeysWith = shareKeysWith;
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import 'matrix_sdk_extensions/flutter_matrix_dart_sdk_database/builder.dart';
|
||||||
|
|
||||||
abstract class ClientManager {
|
abstract class ClientManager {
|
||||||
static const String clientNamespace = 'im.fluffychat.store.clients';
|
static const String clientNamespace = 'im.fluffychat.store.clients';
|
||||||
|
|
||||||
static Future<List<Client>> getClients({
|
static Future<List<Client>> getClients({
|
||||||
bool initialize = true,
|
bool initialize = true,
|
||||||
required SharedPreferences store,
|
required SharedPreferences store,
|
||||||
|
|
@ -101,7 +102,7 @@ abstract class ClientManager {
|
||||||
: NativeImplementationsIsolate(compute);
|
: NativeImplementationsIsolate(compute);
|
||||||
|
|
||||||
static Client createClient(String clientName, SharedPreferences store) {
|
static Client createClient(String clientName, SharedPreferences store) {
|
||||||
final shareKeysWith = store.getString(SettingKeys.shareKeysWith) ?? 'all';
|
final shareKeysWith = AppSettings.shareKeysWith.getItem(store);
|
||||||
|
|
||||||
return Client(
|
return Client(
|
||||||
clientName,
|
clientName,
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ Future<String?> getDatabaseCipher() async {
|
||||||
|
|
||||||
void _sendNoEncryptionWarning(Object exception) async {
|
void _sendNoEncryptionWarning(Object exception) async {
|
||||||
final store = await SharedPreferences.getInstance();
|
final store = await SharedPreferences.getInstance();
|
||||||
final isStored = store.getBool(SettingKeys.noEncryptionWarningShown);
|
final isStored = AppSettings.noEncryptionWarningShown.getItem(store);
|
||||||
|
|
||||||
if (isStored == true) return;
|
if (isStored == true) return;
|
||||||
|
|
||||||
|
|
@ -63,5 +63,5 @@ void _sendNoEncryptionWarning(Object exception) async {
|
||||||
exception.toString(),
|
exception.toString(),
|
||||||
);
|
);
|
||||||
|
|
||||||
await store.setBool(SettingKeys.noEncryptionWarningShown, true);
|
await AppSettings.noEncryptionWarningShown.setItem(store, true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue