mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-17 16:06:28 +10:00
add auto clock synchronization setting after repeater login
Introduced a new setting for automatic clock synchronization after a successful repeater login. Added localization support for the new feature in multiple languages (Bulgarian, German, English, Spanish, French, Hungarian, Italian, Japanese, Korean, Dutch, Polish, Portuguese, Russian, Slovak, Slovenian, Swedish, Ukrainian, Chinese). Implemented storage service methods to manage the new setting. Updated the repeater settings screen to include a toggle for the new feature. Enhanced the repeater login dialog to trigger clock synchronization automatically if the setting is enabled.
This commit is contained in:
@@ -7,8 +7,42 @@ class StorageService {
|
||||
static const String _pathHistoryPrefix = 'path_history_';
|
||||
static const String _pendingMessagesKey = 'pending_messages';
|
||||
static const String _repeaterPasswordsKey = 'repeater_passwords';
|
||||
static const String _repeaterAutoClockSyncAfterLoginKey =
|
||||
'repeater_auto_clock_sync_after_login';
|
||||
static const String _deliveryObservationsKey = 'delivery_observations';
|
||||
|
||||
Future<Map<String, bool>> _loadRepeaterAutoClockSyncAfterLogin() async {
|
||||
final prefs = PrefsManager.instance;
|
||||
final jsonStr = prefs.getString(_repeaterAutoClockSyncAfterLoginKey);
|
||||
|
||||
if (jsonStr == null) return {};
|
||||
|
||||
try {
|
||||
final json = jsonDecode(jsonStr) as Map<String, dynamic>;
|
||||
return json.map((key, value) => MapEntry(key, value == true));
|
||||
} catch (e) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> getRepeaterAutoClockSyncAfterLoginEnabled(
|
||||
String repeaterPubKeyHex,
|
||||
) async {
|
||||
final settings = await _loadRepeaterAutoClockSyncAfterLogin();
|
||||
return settings[repeaterPubKeyHex] ?? false;
|
||||
}
|
||||
|
||||
Future<void> setRepeaterAutoClockSyncAfterLoginEnabled(
|
||||
String repeaterPubKeyHex,
|
||||
bool enabled,
|
||||
) async {
|
||||
final prefs = PrefsManager.instance;
|
||||
final settings = await _loadRepeaterAutoClockSyncAfterLogin();
|
||||
settings[repeaterPubKeyHex] = enabled;
|
||||
final jsonStr = jsonEncode(settings);
|
||||
await prefs.setString(_repeaterAutoClockSyncAfterLoginKey, jsonStr);
|
||||
}
|
||||
|
||||
Future<void> savePathHistory(
|
||||
String contactPubKeyHex,
|
||||
ContactPathHistory history,
|
||||
|
||||
Reference in New Issue
Block a user