synced with last dev, added profiles for cyr2lat replacement dictionaries

This commit is contained in:
HDDen
2026-04-25 01:30:55 +03:00
parent 7a4ac9ae9b
commit f56c28a27d
45 changed files with 1547 additions and 394 deletions
+29 -14
View File
@@ -58,20 +58,7 @@ class ChannelSettingsStore {
}
final prefs = PrefsManager.instance;
final key = '$keyForCyr2Lat$channelIndex';
final oldKey = '$_cyr2latKeyPrefix$channelIndex';
bool? enabled = prefs.getBool(key);
if (enabled == null) {
// Attempt migration from legacy unscoped key on first load
enabled = prefs.getBool(oldKey);
prefs.remove(oldKey);
if (enabled != null) {
appLogger.info(
'Migrating channel Cyr2Lat settings from legacy key $oldKey to scoped key $key',
);
await prefs.setBool(key, enabled);
}
}
return enabled ?? false;
return prefs.getBool(key) ?? false;
}
Future<void> saveCyr2LatEnabled(int channelIndex, bool enabled) async {
@@ -85,4 +72,32 @@ class ChannelSettingsStore {
final key = '$keyForCyr2Lat$channelIndex';
await prefs.setBool(key, enabled);
}
Future<String?> loadCyr2LatProfileId(int channelIndex) async {
if (publicKeyHex.isEmpty) {
appLogger.warn(
'Public key hex is not set. Cannot load channel settings.',
);
return null;
}
final prefs = PrefsManager.instance;
final key = '${keyForCyr2Lat}profile_$channelIndex';
return prefs.getString(key);
}
Future<void> saveCyr2LatProfileId(int channelIndex, String? profileId) async {
if (publicKeyHex.isEmpty) {
appLogger.warn(
'Public key hex is not set. Cannot save channel settings.',
);
return;
}
final prefs = PrefsManager.instance;
final key = '${keyForCyr2Lat}profile_$channelIndex';
if (profileId == null) {
await prefs.remove(key);
} else {
await prefs.setString(key, profileId);
}
}
}
+31 -13
View File
@@ -58,19 +58,6 @@ class ContactSettingsStore {
}
final prefs = PrefsManager.instance;
final key = '$keyForCyr2Lat$contactKeyHex';
final oldKey = '$_cyr2latKeyPrefix$contactKeyHex';
bool? enabled = prefs.getBool(key);
if (enabled == null) {
// Attempt migration from legacy unscoped key on first load
enabled = prefs.getBool(oldKey);
prefs.remove(oldKey);
if (enabled != null) {
appLogger.info(
'Migrating contact Cyr2Lat settings from legacy key $oldKey to scoped key $key',
);
await prefs.setBool(key, enabled);
}
}
return prefs.getBool(key) ?? false;
}
@@ -85,4 +72,35 @@ class ContactSettingsStore {
final key = '$keyForCyr2Lat$contactKeyHex';
await prefs.setBool(key, enabled);
}
Future<String?> loadCyr2LatProfileId(String contactKeyHex) async {
if (publicKeyHex.isEmpty) {
appLogger.warn(
'Public key hex is not set. Cannot load contact settings.',
);
return null;
}
final prefs = PrefsManager.instance;
final key = '${keyForCyr2Lat}profile_$contactKeyHex';
return prefs.getString(key);
}
Future<void> saveCyr2LatProfileId(
String contactKeyHex,
String? profileId,
) async {
if (publicKeyHex.isEmpty) {
appLogger.warn(
'Public key hex is not set. Cannot save contact settings.',
);
return;
}
final prefs = PrefsManager.instance;
final key = '${keyForCyr2Lat}profile_$contactKeyHex';
if (profileId == null) {
await prefs.remove(key);
} else {
await prefs.setString(key, profileId);
}
}
}