mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-22 02:14:28 +10:00
synced with last dev, added profiles for cyr2lat replacement dictionaries
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user