Add Contact and Channelsettings to explicitly enable Picture preview.

This commit is contained in:
ericz committed 2026-08-10 22:21:10 +02:00
1 parent b137dd8fe1
commit d920449cbb
31 files changed
+421 -56

No files matched your search

+22
View File
@@ -4,6 +4,7 @@ import 'prefs_manager.dart';
class ChannelSettingsStore {
static const String _keyPrefix = 'channel_smaz_';
static const String _cyr2latKeyPrefix = 'channel_cyr2lat_';
static const String _imagesKeyPrefix = 'channel_images_';
String publicKeyHex = '';
set setPublicKeyHex(String value) =>
@@ -11,6 +12,7 @@ class ChannelSettingsStore {
String get keyFor => '$_keyPrefix$publicKeyHex';
String get keyForCyr2Lat => '$_cyr2latKeyPrefix$publicKeyHex';
String get keyForImages => '$_imagesKeyPrefix$publicKeyHex';
Future<bool> loadSmazEnabled(int channelIndex) async {
if (publicKeyHex.isEmpty) {
@@ -73,6 +75,26 @@ class ChannelSettingsStore {
await prefs.setBool(key, enabled);
}
Future<bool> loadImagesEnabled(int channelIndex) async {
if (publicKeyHex.isEmpty) {
appLogger.warn(
'Public key hex is not set. Cannot load channel image settings.',
);
return false;
}
return PrefsManager.instance.getBool('$keyForImages$channelIndex') ?? false;
}
Future<void> saveImagesEnabled(int channelIndex, bool enabled) async {
if (publicKeyHex.isEmpty) {
appLogger.warn(
'Public key hex is not set. Cannot save channel image settings.',
);
return;
}
await PrefsManager.instance.setBool('$keyForImages$channelIndex', enabled);
}
Future<String?> loadCyr2LatProfileId(int channelIndex) async {
if (publicKeyHex.isEmpty) {
appLogger.warn(
+23
View File
@@ -4,6 +4,7 @@ import 'prefs_manager.dart';
class ContactSettingsStore {
static const String _keyPrefix = 'contact_smaz_';
static const String _cyr2latKeyPrefix = 'contact_cyr2lat_';
static const String _imagesKeyPrefix = 'contact_images_';
String publicKeyHex = '';
set setPublicKeyHex(String value) =>
@@ -11,6 +12,7 @@ class ContactSettingsStore {
String get keyFor => '$_keyPrefix$publicKeyHex';
String get keyForCyr2Lat => '$_cyr2latKeyPrefix$publicKeyHex';
String get keyForImages => '$_imagesKeyPrefix$publicKeyHex';
Future<bool> loadSmazEnabled(String contactKeyHex) async {
if (publicKeyHex.isEmpty) {
@@ -73,6 +75,27 @@ class ContactSettingsStore {
await prefs.setBool(key, enabled);
}
Future<bool> loadImagesEnabled(String contactKeyHex) async {
if (publicKeyHex.isEmpty) {
appLogger.warn(
'Public key hex is not set. Cannot load contact image settings.',
);
return false;
}
return PrefsManager.instance.getBool('$keyForImages$contactKeyHex') ??
false;
}
Future<void> saveImagesEnabled(String contactKeyHex, bool enabled) async {
if (publicKeyHex.isEmpty) {
appLogger.warn(
'Public key hex is not set. Cannot save contact image settings.',
);
return;
}
await PrefsManager.instance.setBool('$keyForImages$contactKeyHex', enabled);
}
Future<String?> loadCyr2LatProfileId(String contactKeyHex) async {
if (publicKeyHex.isEmpty) {
appLogger.warn(