add setting to enable eviction of discovered contacts in settings

This commit is contained in:
ZIER committed 2026-08-03 09:04:36 +02:00
1 parent 98f6cf3745
commit 9db2307ea0
30 files changed
+260 -40

No files matched your search

+4 -2
View File
@@ -1077,7 +1077,8 @@ class MeshCoreConnector extends ChangeNotifier {
final cached = await _discoveryContactStore.loadContacts(); final cached = await _discoveryContactStore.loadContacts();
// Trim a previously-saved oversized list down to the freshest entries so a // Trim a previously-saved oversized list down to the freshest entries so a
// device that grew unbounded before the cap existed recovers on load. // device that grew unbounded before the cap existed recovers on load.
if (cached.length > _maxDiscoveredContacts) { if (_appSettingsService?.settings.evictDiscoveredContactsEnabled == true &&
cached.length > _maxDiscoveredContacts) {
cached.sort((a, b) => b.lastSeen.compareTo(a.lastSeen)); cached.sort((a, b) => b.lastSeen.compareTo(a.lastSeen));
cached.removeRange(_maxDiscoveredContacts, cached.length); cached.removeRange(_maxDiscoveredContacts, cached.length);
unawaited(_discoveryContactStore.saveContacts(cached)); unawaited(_discoveryContactStore.saveContacts(cached));
@@ -7201,7 +7202,8 @@ class MeshCoreConnector extends ChangeNotifier {
flags: 0, flags: 0,
); );
if (_discoveredContacts.length >= _maxDiscoveredContacts) { if (_appSettingsService?.settings.evictDiscoveredContactsEnabled == true &&
_discoveredContacts.length >= _maxDiscoveredContacts) {
_evictStalestDiscoveredContact(); _evictStalestDiscoveredContact();
} }
_discoveredContacts.add(disContact); _discoveredContacts.add(disContact);
+3 -1
View File
@@ -2129,6 +2129,7 @@
"contactsSettings_autoAddUsersTitle": "Automatische Hinzufügung von Benutzern", "contactsSettings_autoAddUsersTitle": "Automatische Hinzufügung von Benutzern",
"settings_contactSettingsSubtitle": "Einstellungen für das Hinzufügen von Kontakten", "settings_contactSettingsSubtitle": "Einstellungen für das Hinzufügen von Kontakten",
"contactsSettings_autoAddSensorsTitle": "Automatisch Sensoren hinzufügen", "contactsSettings_autoAddSensorsTitle": "Automatisch Sensoren hinzufügen",
"contactsSettings_autoAddSensorsSubtitle": "Ermöglichen Sie dem Begleiter, automatisch entdeckte Sensoren hinzuzufügen",
"contactsSettings_autoAddUsersSubtitle": "Ermöglichen Sie dem Begleiter, automatisch entdeckte Benutzer hinzuzufügen", "contactsSettings_autoAddUsersSubtitle": "Ermöglichen Sie dem Begleiter, automatisch entdeckte Benutzer hinzuzufügen",
"contactsSettings_autoAddRoomServersTitle": "Automatisch Raumservers hinzufügen", "contactsSettings_autoAddRoomServersTitle": "Automatisch Raumservers hinzufügen",
"contactsSettings_autoAddRoomServersSubtitle": "Ermöglichen Sie dem Begleiter, entdeckte Raumserver automatisch hinzuzufügen", "contactsSettings_autoAddRoomServersSubtitle": "Ermöglichen Sie dem Begleiter, entdeckte Raumserver automatisch hinzuzufügen",
@@ -2142,8 +2143,9 @@
"discoveredContacts_Title": "Entdeckte Kontakte", "discoveredContacts_Title": "Entdeckte Kontakte",
"discoveredContacts_copyContact": "Kontakt in die Zwischenablage kopieren", "discoveredContacts_copyContact": "Kontakt in die Zwischenablage kopieren",
"contactsSettings_overwriteOldestTitle": "Überschreiben des Ältesten", "contactsSettings_overwriteOldestTitle": "Überschreiben des Ältesten",
"contactsSettings_autoAddSensorsSubtitle": "Ermöglichen Sie dem Begleiter, automatisch entdeckte Sensoren hinzuzufügen",
"contactsSettings_overwriteOldestSubtitle": "Wenn die Kontaktliste voll ist, wird der älteste nicht favorisierte Kontakt ersetzt.", "contactsSettings_overwriteOldestSubtitle": "Wenn die Kontaktliste voll ist, wird der älteste nicht favorisierte Kontakt ersetzt.",
"contactsSettings_evictDiscoveredContactsTitle": "Kürze entdeckte Kontakte Liste",
"contactsSettings_evictDiscoveredContactsSubtitle": "Wenn aktiviert, wird die Liste der entdeckten Kontackte auf 500 Kontakten begrenzt.",
"common_deleteAll": "Alles löschen", "common_deleteAll": "Alles löschen",
"discoveredContacts_deleteContactAllContent": "Sind Sie sicher, dass Sie alle gefundenen Kontakte löschen möchten?", "discoveredContacts_deleteContactAllContent": "Sind Sie sicher, dass Sie alle gefundenen Kontakte löschen möchten?",
"discoveredContacts_deleteContactAll": "Alle entdeckten Kontakte löschen", "discoveredContacts_deleteContactAll": "Alle entdeckten Kontakte löschen",
+2
View File
@@ -2459,6 +2459,8 @@
"contactsSettings_autoAddSensorsSubtitle": "Allow the companion to automatically add discovered sensors.", "contactsSettings_autoAddSensorsSubtitle": "Allow the companion to automatically add discovered sensors.",
"contactsSettings_overwriteOldestTitle": "Overwrite Oldest", "contactsSettings_overwriteOldestTitle": "Overwrite Oldest",
"contactsSettings_overwriteOldestSubtitle": "When the contact list is full, the oldest non-favorited contact will be replaced.", "contactsSettings_overwriteOldestSubtitle": "When the contact list is full, the oldest non-favorited contact will be replaced.",
"contactsSettings_evictDiscoveredContactsTitle": "Evict discovered contacts",
"contactsSettings_evictDiscoveredContactsSubtitle": "When enabled, the app removes the oldest discovered contacts once the discovery list reaches its limit of 500 entries.",
"discoveredContacts_Title": "Discovered Contacts", "discoveredContacts_Title": "Discovered Contacts",
"discoveredContacts_noMatching": "No matching contacts", "discoveredContacts_noMatching": "No matching contacts",
"discoveredContacts_searchHint": "Search discovered contacts", "discoveredContacts_searchHint": "Search discovered contacts",
+12
View File
@@ -7564,6 +7564,18 @@ abstract class AppLocalizations {
/// **'When the contact list is full, the oldest non-favorited contact will be replaced.'** /// **'When the contact list is full, the oldest non-favorited contact will be replaced.'**
String get contactsSettings_overwriteOldestSubtitle; String get contactsSettings_overwriteOldestSubtitle;
/// No description provided for @contactsSettings_evictDiscoveredContactsTitle.
///
/// In en, this message translates to:
/// **'Evict discovered contacts'**
String get contactsSettings_evictDiscoveredContactsTitle;
/// No description provided for @contactsSettings_evictDiscoveredContactsSubtitle.
///
/// In en, this message translates to:
/// **'When enabled, the app removes the oldest discovered contacts once the discovery list reaches its limit of 500 entries.'**
String get contactsSettings_evictDiscoveredContactsSubtitle;
/// No description provided for @discoveredContacts_Title. /// No description provided for @discoveredContacts_Title.
/// ///
/// In en, this message translates to: /// In en, this message translates to:
+8
View File
@@ -4393,6 +4393,14 @@ class AppLocalizationsBg extends AppLocalizations {
String get contactsSettings_overwriteOldestSubtitle => String get contactsSettings_overwriteOldestSubtitle =>
'Когато списъкът с контакти е пълен, най-старият неключов контакт ще бъде заменен.'; 'Когато списъкът с контакти е пълен, най-старият неключов контакт ще бъде заменен.';
@override
String get contactsSettings_evictDiscoveredContactsTitle =>
'Evict discovered contacts';
@override
String get contactsSettings_evictDiscoveredContactsSubtitle =>
'When enabled, the app removes the oldest discovered contacts once the discovery list reaches its limit of 500 entries.';
@override @override
String get discoveredContacts_Title => 'Открити контакти'; String get discoveredContacts_Title => 'Открити контакти';
+8
View File
@@ -4402,6 +4402,14 @@ class AppLocalizationsDe extends AppLocalizations {
String get contactsSettings_overwriteOldestSubtitle => String get contactsSettings_overwriteOldestSubtitle =>
'Wenn die Kontaktliste voll ist, wird der älteste nicht favorisierte Kontakt ersetzt.'; 'Wenn die Kontaktliste voll ist, wird der älteste nicht favorisierte Kontakt ersetzt.';
@override
String get contactsSettings_evictDiscoveredContactsTitle =>
'Kürze entdeckte Kontakte Liste';
@override
String get contactsSettings_evictDiscoveredContactsSubtitle =>
'Wenn aktiviert, wird die Liste der entdeckten Kontackte auf 500 Kontakten begrenzt.';
@override @override
String get discoveredContacts_Title => 'Entdeckte Kontakte'; String get discoveredContacts_Title => 'Entdeckte Kontakte';
+8
View File
@@ -4325,6 +4325,14 @@ class AppLocalizationsEn extends AppLocalizations {
String get contactsSettings_overwriteOldestSubtitle => String get contactsSettings_overwriteOldestSubtitle =>
'When the contact list is full, the oldest non-favorited contact will be replaced.'; 'When the contact list is full, the oldest non-favorited contact will be replaced.';
@override
String get contactsSettings_evictDiscoveredContactsTitle =>
'Evict discovered contacts';
@override
String get contactsSettings_evictDiscoveredContactsSubtitle =>
'When enabled, the app removes the oldest discovered contacts once the discovery list reaches its limit of 500 entries.';
@override @override
String get discoveredContacts_Title => 'Discovered Contacts'; String get discoveredContacts_Title => 'Discovered Contacts';
+8
View File
@@ -4396,6 +4396,14 @@ class AppLocalizationsEs extends AppLocalizations {
String get contactsSettings_overwriteOldestSubtitle => String get contactsSettings_overwriteOldestSubtitle =>
'Cuando la lista de contactos esté llena, se reemplazará el contacto no favorito más antiguo.'; 'Cuando la lista de contactos esté llena, se reemplazará el contacto no favorito más antiguo.';
@override
String get contactsSettings_evictDiscoveredContactsTitle =>
'Evict discovered contacts';
@override
String get contactsSettings_evictDiscoveredContactsSubtitle =>
'When enabled, the app removes the oldest discovered contacts once the discovery list reaches its limit of 500 entries.';
@override @override
String get discoveredContacts_Title => 'Contactos descubiertos'; String get discoveredContacts_Title => 'Contactos descubiertos';
+8
View File
@@ -4415,6 +4415,14 @@ class AppLocalizationsFr extends AppLocalizations {
String get contactsSettings_overwriteOldestSubtitle => String get contactsSettings_overwriteOldestSubtitle =>
'Lorsque la liste de contacts est pleine, le contact le plus ancien non favori sera remplacé.'; 'Lorsque la liste de contacts est pleine, le contact le plus ancien non favori sera remplacé.';
@override
String get contactsSettings_evictDiscoveredContactsTitle =>
'Evict discovered contacts';
@override
String get contactsSettings_evictDiscoveredContactsSubtitle =>
'When enabled, the app removes the oldest discovered contacts once the discovery list reaches its limit of 500 entries.';
@override @override
String get discoveredContacts_Title => 'Contacts découverts'; String get discoveredContacts_Title => 'Contacts découverts';
+8
View File
@@ -4391,6 +4391,14 @@ class AppLocalizationsHu extends AppLocalizations {
String get contactsSettings_overwriteOldestSubtitle => String get contactsSettings_overwriteOldestSubtitle =>
'Amikor a névjegylista megtelik, a legrégebbi, nem kedvenc névjegy lecserélődik.'; 'Amikor a névjegylista megtelik, a legrégebbi, nem kedvenc névjegy lecserélődik.';
@override
String get contactsSettings_evictDiscoveredContactsTitle =>
'Evict discovered contacts';
@override
String get contactsSettings_evictDiscoveredContactsSubtitle =>
'When enabled, the app removes the oldest discovered contacts once the discovery list reaches its limit of 500 entries.';
@override @override
String get discoveredContacts_Title => 'Felfedezett kapcsolatok'; String get discoveredContacts_Title => 'Felfedezett kapcsolatok';
+8
View File
@@ -4402,6 +4402,14 @@ class AppLocalizationsIt extends AppLocalizations {
String get contactsSettings_overwriteOldestSubtitle => String get contactsSettings_overwriteOldestSubtitle =>
'Quando l\'elenco dei contatti è pieno, il contatto più vecchio non tra i preferiti verrà sostituito.'; 'Quando l\'elenco dei contatti è pieno, il contatto più vecchio non tra i preferiti verrà sostituito.';
@override
String get contactsSettings_evictDiscoveredContactsTitle =>
'Evict discovered contacts';
@override
String get contactsSettings_evictDiscoveredContactsSubtitle =>
'When enabled, the app removes the oldest discovered contacts once the discovery list reaches its limit of 500 entries.';
@override @override
String get discoveredContacts_Title => 'Contatti scoperti'; String get discoveredContacts_Title => 'Contatti scoperti';
+8
View File
@@ -4177,6 +4177,14 @@ class AppLocalizationsJa extends AppLocalizations {
String get contactsSettings_overwriteOldestSubtitle => String get contactsSettings_overwriteOldestSubtitle =>
'連絡先リストが満杯になった場合、最も古いかつ「お気に入り」ではない連絡先が削除されます。'; '連絡先リストが満杯になった場合、最も古いかつ「お気に入り」ではない連絡先が削除されます。';
@override
String get contactsSettings_evictDiscoveredContactsTitle =>
'Evict discovered contacts';
@override
String get contactsSettings_evictDiscoveredContactsSubtitle =>
'When enabled, the app removes the oldest discovered contacts once the discovery list reaches its limit of 500 entries.';
@override @override
String get discoveredContacts_Title => '連絡先が見つかった'; String get discoveredContacts_Title => '連絡先が見つかった';
+8
View File
@@ -4185,6 +4185,14 @@ class AppLocalizationsKo extends AppLocalizations {
String get contactsSettings_overwriteOldestSubtitle => String get contactsSettings_overwriteOldestSubtitle =>
'연락처 목록이 가득 차면, 가장 오래된 (선호하지 않은) 연락처가 대체됩니다.'; '연락처 목록이 가득 차면, 가장 오래된 (선호하지 않은) 연락처가 대체됩니다.';
@override
String get contactsSettings_evictDiscoveredContactsTitle =>
'Evict discovered contacts';
@override
String get contactsSettings_evictDiscoveredContactsSubtitle =>
'When enabled, the app removes the oldest discovered contacts once the discovery list reaches its limit of 500 entries.';
@override @override
String get discoveredContacts_Title => '연락처 찾기'; String get discoveredContacts_Title => '연락처 찾기';
+8
View File
@@ -4380,6 +4380,14 @@ class AppLocalizationsNl extends AppLocalizations {
String get contactsSettings_overwriteOldestSubtitle => String get contactsSettings_overwriteOldestSubtitle =>
'Wanneer de contactenlijst vol is, wordt de oudste niet-favoriete contactpersoon vervangen.'; 'Wanneer de contactenlijst vol is, wordt de oudste niet-favoriete contactpersoon vervangen.';
@override
String get contactsSettings_evictDiscoveredContactsTitle =>
'Evict discovered contacts';
@override
String get contactsSettings_evictDiscoveredContactsSubtitle =>
'When enabled, the app removes the oldest discovered contacts once the discovery list reaches its limit of 500 entries.';
@override @override
String get discoveredContacts_Title => 'Ontdekte contacten'; String get discoveredContacts_Title => 'Ontdekte contacten';
+8
View File
@@ -4419,6 +4419,14 @@ class AppLocalizationsPl extends AppLocalizations {
String get contactsSettings_overwriteOldestSubtitle => String get contactsSettings_overwriteOldestSubtitle =>
'Gdy lista kontaktów jest pełna, najstarszy nieulubiony kontakt zostanie zastąpiony.'; 'Gdy lista kontaktów jest pełna, najstarszy nieulubiony kontakt zostanie zastąpiony.';
@override
String get contactsSettings_evictDiscoveredContactsTitle =>
'Evict discovered contacts';
@override
String get contactsSettings_evictDiscoveredContactsSubtitle =>
'When enabled, the app removes the oldest discovered contacts once the discovery list reaches its limit of 500 entries.';
@override @override
String get discoveredContacts_Title => 'Odkryte Kontakty'; String get discoveredContacts_Title => 'Odkryte Kontakty';
+8
View File
@@ -4396,6 +4396,14 @@ class AppLocalizationsPt extends AppLocalizations {
String get contactsSettings_overwriteOldestSubtitle => String get contactsSettings_overwriteOldestSubtitle =>
'Quando a lista de contatos estiver cheia, o contato mais antigo não favoritado será substituído.'; 'Quando a lista de contatos estiver cheia, o contato mais antigo não favoritado será substituído.';
@override
String get contactsSettings_evictDiscoveredContactsTitle =>
'Evict discovered contacts';
@override
String get contactsSettings_evictDiscoveredContactsSubtitle =>
'When enabled, the app removes the oldest discovered contacts once the discovery list reaches its limit of 500 entries.';
@override @override
String get discoveredContacts_Title => 'Contatos Descobertos'; String get discoveredContacts_Title => 'Contatos Descobertos';
+8
View File
@@ -4412,6 +4412,14 @@ class AppLocalizationsRu extends AppLocalizations {
String get contactsSettings_overwriteOldestSubtitle => String get contactsSettings_overwriteOldestSubtitle =>
'Когда список контактов заполнен, будет заменен самый старый контакт, который не находится в избранном.'; 'Когда список контактов заполнен, будет заменен самый старый контакт, который не находится в избранном.';
@override
String get contactsSettings_evictDiscoveredContactsTitle =>
'Evict discovered contacts';
@override
String get contactsSettings_evictDiscoveredContactsSubtitle =>
'When enabled, the app removes the oldest discovered contacts once the discovery list reaches its limit of 500 entries.';
@override @override
String get discoveredContacts_Title => 'Обнаруженные контакты'; String get discoveredContacts_Title => 'Обнаруженные контакты';
+8
View File
@@ -4380,6 +4380,14 @@ class AppLocalizationsSk extends AppLocalizations {
String get contactsSettings_overwriteOldestSubtitle => String get contactsSettings_overwriteOldestSubtitle =>
'Keď je zoznam kontaktov plný, bude nahradený najstarší neoznačený kontakt.'; 'Keď je zoznam kontaktov plný, bude nahradený najstarší neoznačený kontakt.';
@override
String get contactsSettings_evictDiscoveredContactsTitle =>
'Evict discovered contacts';
@override
String get contactsSettings_evictDiscoveredContactsSubtitle =>
'When enabled, the app removes the oldest discovered contacts once the discovery list reaches its limit of 500 entries.';
@override @override
String get discoveredContacts_Title => 'Objavené kontakty'; String get discoveredContacts_Title => 'Objavené kontakty';
+8
View File
@@ -4377,6 +4377,14 @@ class AppLocalizationsSl extends AppLocalizations {
String get contactsSettings_overwriteOldestSubtitle => String get contactsSettings_overwriteOldestSubtitle =>
'Ko je seznam stikov poln, bo najstarejši nestarševski stik zamenjan.'; 'Ko je seznam stikov poln, bo najstarejši nestarševski stik zamenjan.';
@override
String get contactsSettings_evictDiscoveredContactsTitle =>
'Evict discovered contacts';
@override
String get contactsSettings_evictDiscoveredContactsSubtitle =>
'When enabled, the app removes the oldest discovered contacts once the discovery list reaches its limit of 500 entries.';
@override @override
String get discoveredContacts_Title => 'Odkriti stiki'; String get discoveredContacts_Title => 'Odkriti stiki';
+8
View File
@@ -4350,6 +4350,14 @@ class AppLocalizationsSv extends AppLocalizations {
String get contactsSettings_overwriteOldestSubtitle => String get contactsSettings_overwriteOldestSubtitle =>
'När kontaktlistan är full ersätts den äldsta icke-favoriterade kontakten.'; 'När kontaktlistan är full ersätts den äldsta icke-favoriterade kontakten.';
@override
String get contactsSettings_evictDiscoveredContactsTitle =>
'Evict discovered contacts';
@override
String get contactsSettings_evictDiscoveredContactsSubtitle =>
'When enabled, the app removes the oldest discovered contacts once the discovery list reaches its limit of 500 entries.';
@override @override
String get discoveredContacts_Title => 'Upptäckta kontakter'; String get discoveredContacts_Title => 'Upptäckta kontakter';
+8
View File
@@ -4408,6 +4408,14 @@ class AppLocalizationsUk extends AppLocalizations {
String get contactsSettings_overwriteOldestSubtitle => String get contactsSettings_overwriteOldestSubtitle =>
'Коли список контактів заповнений, найстарший контакт без позначки улюбленого буде замінений.'; 'Коли список контактів заповнений, найстарший контакт без позначки улюбленого буде замінений.';
@override
String get contactsSettings_evictDiscoveredContactsTitle =>
'Evict discovered contacts';
@override
String get contactsSettings_evictDiscoveredContactsSubtitle =>
'When enabled, the app removes the oldest discovered contacts once the discovery list reaches its limit of 500 entries.';
@override @override
String get discoveredContacts_Title => 'Виявлені контакти'; String get discoveredContacts_Title => 'Виявлені контакти';
+8
View File
@@ -4075,6 +4075,14 @@ class AppLocalizationsZh extends AppLocalizations {
String get contactsSettings_overwriteOldestSubtitle => String get contactsSettings_overwriteOldestSubtitle =>
'当联系人列表已满时,将替换最老的非收藏联系人。'; '当联系人列表已满时,将替换最老的非收藏联系人。';
@override
String get contactsSettings_evictDiscoveredContactsTitle =>
'Evict discovered contacts';
@override
String get contactsSettings_evictDiscoveredContactsSubtitle =>
'When enabled, the app removes the oldest discovered contacts once the discovery list reaches its limit of 500 entries.';
@override @override
String get discoveredContacts_Title => '已发现的联系人'; String get discoveredContacts_Title => '已发现的联系人';
+10 -4
View File
@@ -76,8 +76,7 @@ class Cyr2LatProfile {
class AppSettings { class AppSettings {
static const Object _unset = Object(); static const Object _unset = Object();
static const String stadiaDemo = static const String stadiaDemo = '51bd0381-4685-4666-bae8-48940f6d77c0';
'51bd0381-4685-4666-bae8-48940f6d77c0';
final bool clearPathOnMaxRetry; final bool clearPathOnMaxRetry;
final bool mapShowRepeaters; final bool mapShowRepeaters;
@@ -116,6 +115,7 @@ class AppSettings {
final UnitSystem unitSystem; final UnitSystem unitSystem;
final Set<String> mutedChannels; final Set<String> mutedChannels;
final bool mapShowDiscoveryContacts; final bool mapShowDiscoveryContacts;
final bool evictDiscoveredContactsEnabled;
final String tcpServerAddress; final String tcpServerAddress;
final int tcpServerPort; final int tcpServerPort;
final bool jumpToOldestUnread; final bool jumpToOldestUnread;
@@ -137,8 +137,7 @@ class AppSettings {
return apiKey; return apiKey;
} }
bool get usesstadiaDemo => bool get usesstadiaDemo => effectiveMapTileApiKey == stadiaDemo;
effectiveMapTileApiKey == stadiaDemo;
Map<String, String> get cyr2latCharMap { Map<String, String> get cyr2latCharMap {
final profile = cyr2latProfiles.firstWhere( final profile = cyr2latProfiles.firstWhere(
@@ -186,6 +185,7 @@ class AppSettings {
this.unitSystem = UnitSystem.metric, this.unitSystem = UnitSystem.metric,
Set<String>? mutedChannels, Set<String>? mutedChannels,
this.mapShowDiscoveryContacts = true, this.mapShowDiscoveryContacts = true,
this.evictDiscoveredContactsEnabled = false,
this.tcpServerAddress = '', this.tcpServerAddress = '',
this.tcpServerPort = 0, this.tcpServerPort = 0,
this.jumpToOldestUnread = false, this.jumpToOldestUnread = false,
@@ -253,6 +253,7 @@ class AppSettings {
'unit_system': unitSystem.value, 'unit_system': unitSystem.value,
'muted_channels': mutedChannels.toList(), 'muted_channels': mutedChannels.toList(),
'map_show_discovery_contacts': mapShowDiscoveryContacts, 'map_show_discovery_contacts': mapShowDiscoveryContacts,
'evict_discovered_contacts_enabled': evictDiscoveredContactsEnabled,
'tcp_server_address': tcpServerAddress, 'tcp_server_address': tcpServerAddress,
'tcp_server_port': tcpServerPort, 'tcp_server_port': tcpServerPort,
'jump_to_oldest_unread': jumpToOldestUnread, 'jump_to_oldest_unread': jumpToOldestUnread,
@@ -342,6 +343,8 @@ class AppSettings {
{}, {},
mapShowDiscoveryContacts: mapShowDiscoveryContacts:
json['map_show_discovery_contacts'] as bool? ?? true, json['map_show_discovery_contacts'] as bool? ?? true,
evictDiscoveredContactsEnabled:
json['evict_discovered_contacts_enabled'] as bool? ?? false,
tcpServerAddress: json['tcp_server_address'] as String? ?? '', tcpServerAddress: json['tcp_server_address'] as String? ?? '',
tcpServerPort: json['tcp_server_port'] as int? ?? 0, tcpServerPort: json['tcp_server_port'] as int? ?? 0,
jumpToOldestUnread: json['jump_to_oldest_unread'] as bool? ?? false, jumpToOldestUnread: json['jump_to_oldest_unread'] as bool? ?? false,
@@ -438,6 +441,7 @@ class AppSettings {
UnitSystem? unitSystem, UnitSystem? unitSystem,
Set<String>? mutedChannels, Set<String>? mutedChannels,
bool? mapShowDiscoveryContacts, bool? mapShowDiscoveryContacts,
bool? evictDiscoveredContactsEnabled,
String? tcpServerAddress, String? tcpServerAddress,
int? tcpServerPort, int? tcpServerPort,
bool? jumpToOldestUnread, bool? jumpToOldestUnread,
@@ -505,6 +509,8 @@ class AppSettings {
mutedChannels: mutedChannels ?? this.mutedChannels, mutedChannels: mutedChannels ?? this.mutedChannels,
mapShowDiscoveryContacts: mapShowDiscoveryContacts:
mapShowDiscoveryContacts ?? this.mapShowDiscoveryContacts, mapShowDiscoveryContacts ?? this.mapShowDiscoveryContacts,
evictDiscoveredContactsEnabled:
evictDiscoveredContactsEnabled ?? this.evictDiscoveredContactsEnabled,
tcpServerAddress: tcpServerAddress ?? this.tcpServerAddress, tcpServerAddress: tcpServerAddress ?? this.tcpServerAddress,
tcpServerPort: tcpServerPort ?? this.tcpServerPort, tcpServerPort: tcpServerPort ?? this.tcpServerPort,
jumpToOldestUnread: jumpToOldestUnread ?? this.jumpToOldestUnread, jumpToOldestUnread: jumpToOldestUnread ?? this.jumpToOldestUnread,
+1 -3
View File
@@ -1153,9 +1153,7 @@ class AppSettingsScreen extends StatelessWidget {
) { ) {
final currentApiKey = settingsService.settings.mapTileApiKey?.trim() ?? ''; final currentApiKey = settingsService.settings.mapTileApiKey?.trim() ?? '';
final maskedApiKey = _maskApiKey( final maskedApiKey = _maskApiKey(
currentApiKey.isEmpty currentApiKey.isEmpty ? AppSettings.stadiaDemo : currentApiKey,
? AppSettings.stadiaDemo
: currentApiKey,
); );
final controller = TextEditingController(text: maskedApiKey); final controller = TextEditingController(text: maskedApiKey);
showDialog( showDialog(
+6 -12
View File
@@ -700,9 +700,9 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
child: Text( child: Text(
context.l10n.channels_via( context.l10n.channels_via(
_formatPathPrefixes( _formatPathPrefixes(
displayPath, displayPath,
displayPathHashWidth, displayPathHashWidth,
), ),
), ),
style: MeshTheme.mono( style: MeshTheme.mono(
fontSize: 9.5 * textScale, fontSize: 9.5 * textScale,
@@ -1214,25 +1214,19 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
decoration: InputDecoration( decoration: InputDecoration(
hintText: context.l10n.chat_typeMessage, hintText: context.l10n.chat_typeMessage,
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: BorderRadius.circular( borderRadius: BorderRadius.circular(MeshRadii.md),
MeshRadii.md,
),
borderSide: BorderSide( borderSide: BorderSide(
color: scheme.outlineVariant, color: scheme.outlineVariant,
), ),
), ),
enabledBorder: OutlineInputBorder( enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular( borderRadius: BorderRadius.circular(MeshRadii.md),
MeshRadii.md,
),
borderSide: BorderSide( borderSide: BorderSide(
color: scheme.outlineVariant, color: scheme.outlineVariant,
), ),
), ),
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular( borderRadius: BorderRadius.circular(MeshRadii.md),
MeshRadii.md,
),
borderSide: BorderSide( borderSide: BorderSide(
color: scheme.primary, color: scheme.primary,
width: 1.5, width: 1.5,
+2 -1
View File
@@ -412,7 +412,8 @@ class _ChannelsScreenState extends State<ChannelsScreen>
final messages = connector.getChannelMessages(channel); final messages = connector.getChannelMessages(channel);
final lastMessage = messages.isNotEmpty ? messages.last : null; final lastMessage = messages.isNotEmpty ? messages.last : null;
final lastMessageText = lastMessage?.text ?? ''; final lastMessageText = lastMessage?.text ?? '';
final lastPreview = lastMessageText.isNotEmpty && final lastPreview =
lastMessageText.isNotEmpty &&
GifHelper.parseGif(lastMessageText) != null GifHelper.parseGif(lastMessageText) != null
? context.l10n.chat_receivedGif ? context.l10n.chat_receivedGif
: lastMessageText; : lastMessageText;
+17 -1
View File
@@ -1168,6 +1168,9 @@ class _SettingsScreenState extends State<SettingsScreen> {
bool autoAddRoomServer = false; bool autoAddRoomServer = false;
bool autoAddSensor = false; bool autoAddSensor = false;
bool overwriteOldest = false; bool overwriteOldest = false;
final appSettingsService = context.read<AppSettingsService>();
bool evictDiscoveredContactsEnabled =
appSettingsService.settings.evictDiscoveredContactsEnabled;
final connector = context.read<MeshCoreConnector>(); final connector = context.read<MeshCoreConnector>();
autoAddChat = connector.autoAddUsers ?? false; autoAddChat = connector.autoAddUsers ?? false;
@@ -1229,6 +1232,15 @@ class _SettingsScreenState extends State<SettingsScreen> {
setDialogState(() => overwriteOldest = value); setDialogState(() => overwriteOldest = value);
}, },
), ),
const Divider(height: 4),
FeatureToggleRow(
title: l10n.contactsSettings_evictDiscoveredContactsTitle,
subtitle: l10n.contactsSettings_evictDiscoveredContactsSubtitle,
value: evictDiscoveredContactsEnabled,
onChanged: (value) {
setDialogState(() => evictDiscoveredContactsEnabled = value);
},
),
], ],
), ),
), ),
@@ -1238,7 +1250,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
child: Text(l10n.common_cancel), child: Text(l10n.common_cancel),
), ),
TextButton( TextButton(
onPressed: () { onPressed: () async {
await appSettingsService.setEvictDiscoveredContactsEnabled(
evictDiscoveredContactsEnabled,
);
_sendSettings( _sendSettings(
connector, connector,
autoAddChat, autoAddChat,
@@ -1247,6 +1262,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
autoAddSensor, autoAddSensor,
overwriteOldest, overwriteOldest,
); );
if (!mounted) return;
Navigator.pop(context); Navigator.pop(context);
}, },
child: Text(l10n.common_save), child: Text(l10n.common_save),
+6
View File
@@ -223,6 +223,12 @@ class AppSettingsService extends ChangeNotifier {
await updateSettings(_settings.copyWith(mapShowDiscoveryContacts: value)); await updateSettings(_settings.copyWith(mapShowDiscoveryContacts: value));
} }
Future<void> setEvictDiscoveredContactsEnabled(bool value) async {
await updateSettings(
_settings.copyWith(evictDiscoveredContactsEnabled: value),
);
}
Future<void> setBatteryChemistryForDevice( Future<void> setBatteryChemistryForDevice(
String deviceId, String deviceId,
String chemistry, String chemistry,
+5
View File
@@ -385,6 +385,7 @@ void main() {
expect(settings.routeWeightSuccessIncrement, equals(0.5)); expect(settings.routeWeightSuccessIncrement, equals(0.5));
expect(settings.routeWeightFailureDecrement, equals(0.2)); expect(settings.routeWeightFailureDecrement, equals(0.2));
expect(settings.maxMessageRetries, equals(5)); expect(settings.maxMessageRetries, equals(5));
expect(settings.evictDiscoveredContactsEnabled, isFalse);
}); });
test('toJson includes all new fields', () { test('toJson includes all new fields', () {
@@ -395,11 +396,13 @@ void main() {
expect(json.containsKey('route_weight_success_increment'), isTrue); expect(json.containsKey('route_weight_success_increment'), isTrue);
expect(json.containsKey('route_weight_failure_decrement'), isTrue); expect(json.containsKey('route_weight_failure_decrement'), isTrue);
expect(json.containsKey('max_message_retries'), isTrue); expect(json.containsKey('max_message_retries'), isTrue);
expect(json.containsKey('evict_discovered_contacts_enabled'), isFalse);
expect(json['max_route_weight'], equals(5.0)); expect(json['max_route_weight'], equals(5.0));
expect(json['initial_route_weight'], equals(3.0)); expect(json['initial_route_weight'], equals(3.0));
expect(json['route_weight_success_increment'], equals(0.5)); expect(json['route_weight_success_increment'], equals(0.5));
expect(json['route_weight_failure_decrement'], equals(0.2)); expect(json['route_weight_failure_decrement'], equals(0.2));
expect(json['max_message_retries'], equals(5)); expect(json['max_message_retries'], equals(5));
expect(json['evict_discovered_contacts_enabled'], isFalse);
}); });
test('fromJson reads all new fields', () { test('fromJson reads all new fields', () {
@@ -409,6 +412,7 @@ void main() {
'route_weight_success_increment': 1.0, 'route_weight_success_increment': 1.0,
'route_weight_failure_decrement': 1.5, 'route_weight_failure_decrement': 1.5,
'max_message_retries': 8, 'max_message_retries': 8,
'evict_discovered_contacts_enabled': false,
}; };
final settings = AppSettings.fromJson(json); final settings = AppSettings.fromJson(json);
expect(settings.maxRouteWeight, equals(10.0)); expect(settings.maxRouteWeight, equals(10.0));
@@ -416,6 +420,7 @@ void main() {
expect(settings.routeWeightSuccessIncrement, equals(1.0)); expect(settings.routeWeightSuccessIncrement, equals(1.0));
expect(settings.routeWeightFailureDecrement, equals(1.5)); expect(settings.routeWeightFailureDecrement, equals(1.5));
expect(settings.maxMessageRetries, equals(8)); expect(settings.maxMessageRetries, equals(8));
expect(settings.evictDiscoveredContactsEnabled, isFalse);
}); });
test( test(
+48 -16
View File
@@ -30,7 +30,9 @@
"repeater_pubKey", "repeater_pubKey",
"repeater_pubKeyHelper", "repeater_pubKeyHelper",
"repeater_pubKeyPrefix", "repeater_pubKeyPrefix",
"repeater_pubKeyPrefixHelper" "repeater_pubKeyPrefixHelper",
"contactsSettings_evictDiscoveredContactsTitle",
"contactsSettings_evictDiscoveredContactsSubtitle"
], ],
"de": [ "de": [
@@ -85,7 +87,9 @@
"repeater_pubKey", "repeater_pubKey",
"repeater_pubKeyHelper", "repeater_pubKeyHelper",
"repeater_pubKeyPrefix", "repeater_pubKeyPrefix",
"repeater_pubKeyPrefixHelper" "repeater_pubKeyPrefixHelper",
"contactsSettings_evictDiscoveredContactsTitle",
"contactsSettings_evictDiscoveredContactsSubtitle"
], ],
"fr": [ "fr": [
@@ -119,7 +123,9 @@
"repeater_pubKey", "repeater_pubKey",
"repeater_pubKeyHelper", "repeater_pubKeyHelper",
"repeater_pubKeyPrefix", "repeater_pubKeyPrefix",
"repeater_pubKeyPrefixHelper" "repeater_pubKeyPrefixHelper",
"contactsSettings_evictDiscoveredContactsTitle",
"contactsSettings_evictDiscoveredContactsSubtitle"
], ],
"hu": [ "hu": [
@@ -153,7 +159,9 @@
"repeater_pubKey", "repeater_pubKey",
"repeater_pubKeyHelper", "repeater_pubKeyHelper",
"repeater_pubKeyPrefix", "repeater_pubKeyPrefix",
"repeater_pubKeyPrefixHelper" "repeater_pubKeyPrefixHelper",
"contactsSettings_evictDiscoveredContactsTitle",
"contactsSettings_evictDiscoveredContactsSubtitle"
], ],
"it": [ "it": [
@@ -187,7 +195,9 @@
"repeater_pubKey", "repeater_pubKey",
"repeater_pubKeyHelper", "repeater_pubKeyHelper",
"repeater_pubKeyPrefix", "repeater_pubKeyPrefix",
"repeater_pubKeyPrefixHelper" "repeater_pubKeyPrefixHelper",
"contactsSettings_evictDiscoveredContactsTitle",
"contactsSettings_evictDiscoveredContactsSubtitle"
], ],
"ja": [ "ja": [
@@ -221,7 +231,9 @@
"repeater_pubKey", "repeater_pubKey",
"repeater_pubKeyHelper", "repeater_pubKeyHelper",
"repeater_pubKeyPrefix", "repeater_pubKeyPrefix",
"repeater_pubKeyPrefixHelper" "repeater_pubKeyPrefixHelper",
"contactsSettings_evictDiscoveredContactsTitle",
"contactsSettings_evictDiscoveredContactsSubtitle"
], ],
"ko": [ "ko": [
@@ -255,7 +267,9 @@
"repeater_pubKey", "repeater_pubKey",
"repeater_pubKeyHelper", "repeater_pubKeyHelper",
"repeater_pubKeyPrefix", "repeater_pubKeyPrefix",
"repeater_pubKeyPrefixHelper" "repeater_pubKeyPrefixHelper",
"contactsSettings_evictDiscoveredContactsTitle",
"contactsSettings_evictDiscoveredContactsSubtitle"
], ],
"nl": [ "nl": [
@@ -289,7 +303,9 @@
"repeater_pubKey", "repeater_pubKey",
"repeater_pubKeyHelper", "repeater_pubKeyHelper",
"repeater_pubKeyPrefix", "repeater_pubKeyPrefix",
"repeater_pubKeyPrefixHelper" "repeater_pubKeyPrefixHelper",
"contactsSettings_evictDiscoveredContactsTitle",
"contactsSettings_evictDiscoveredContactsSubtitle"
], ],
"pl": [ "pl": [
@@ -323,7 +339,9 @@
"repeater_pubKey", "repeater_pubKey",
"repeater_pubKeyHelper", "repeater_pubKeyHelper",
"repeater_pubKeyPrefix", "repeater_pubKeyPrefix",
"repeater_pubKeyPrefixHelper" "repeater_pubKeyPrefixHelper",
"contactsSettings_evictDiscoveredContactsTitle",
"contactsSettings_evictDiscoveredContactsSubtitle"
], ],
"pt": [ "pt": [
@@ -357,7 +375,9 @@
"repeater_pubKey", "repeater_pubKey",
"repeater_pubKeyHelper", "repeater_pubKeyHelper",
"repeater_pubKeyPrefix", "repeater_pubKeyPrefix",
"repeater_pubKeyPrefixHelper" "repeater_pubKeyPrefixHelper",
"contactsSettings_evictDiscoveredContactsTitle",
"contactsSettings_evictDiscoveredContactsSubtitle"
], ],
"ru": [ "ru": [
@@ -391,7 +411,9 @@
"repeater_pubKey", "repeater_pubKey",
"repeater_pubKeyHelper", "repeater_pubKeyHelper",
"repeater_pubKeyPrefix", "repeater_pubKeyPrefix",
"repeater_pubKeyPrefixHelper" "repeater_pubKeyPrefixHelper",
"contactsSettings_evictDiscoveredContactsTitle",
"contactsSettings_evictDiscoveredContactsSubtitle"
], ],
"sk": [ "sk": [
@@ -425,7 +447,9 @@
"repeater_pubKey", "repeater_pubKey",
"repeater_pubKeyHelper", "repeater_pubKeyHelper",
"repeater_pubKeyPrefix", "repeater_pubKeyPrefix",
"repeater_pubKeyPrefixHelper" "repeater_pubKeyPrefixHelper",
"contactsSettings_evictDiscoveredContactsTitle",
"contactsSettings_evictDiscoveredContactsSubtitle"
], ],
"sl": [ "sl": [
@@ -459,7 +483,9 @@
"repeater_pubKey", "repeater_pubKey",
"repeater_pubKeyHelper", "repeater_pubKeyHelper",
"repeater_pubKeyPrefix", "repeater_pubKeyPrefix",
"repeater_pubKeyPrefixHelper" "repeater_pubKeyPrefixHelper",
"contactsSettings_evictDiscoveredContactsTitle",
"contactsSettings_evictDiscoveredContactsSubtitle"
], ],
"sv": [ "sv": [
@@ -493,7 +519,9 @@
"repeater_pubKey", "repeater_pubKey",
"repeater_pubKeyHelper", "repeater_pubKeyHelper",
"repeater_pubKeyPrefix", "repeater_pubKeyPrefix",
"repeater_pubKeyPrefixHelper" "repeater_pubKeyPrefixHelper",
"contactsSettings_evictDiscoveredContactsTitle",
"contactsSettings_evictDiscoveredContactsSubtitle"
], ],
"uk": [ "uk": [
@@ -527,7 +555,9 @@
"repeater_pubKey", "repeater_pubKey",
"repeater_pubKeyHelper", "repeater_pubKeyHelper",
"repeater_pubKeyPrefix", "repeater_pubKeyPrefix",
"repeater_pubKeyPrefixHelper" "repeater_pubKeyPrefixHelper",
"contactsSettings_evictDiscoveredContactsTitle",
"contactsSettings_evictDiscoveredContactsSubtitle"
], ],
"zh": [ "zh": [
@@ -561,6 +591,8 @@
"repeater_pubKey", "repeater_pubKey",
"repeater_pubKeyHelper", "repeater_pubKeyHelper",
"repeater_pubKeyPrefix", "repeater_pubKeyPrefix",
"repeater_pubKeyPrefixHelper" "repeater_pubKeyPrefixHelper",
"contactsSettings_evictDiscoveredContactsTitle",
"contactsSettings_evictDiscoveredContactsSubtitle"
] ]
} }