Merge remote-tracking branch 'origin/dev' into pr-593
# Conflicts: # lib/models/app_settings.dart # lib/screens/channel_chat_screen.dart # lib/screens/chat_screen.dart # untranslated.json
This commit is contained in:
commit
7e7e7a48db
87 files changed
+4822
-882
No files matched your search
@@ -29,6 +29,8 @@ String migratePublicIpfsGateway(String? value) {
|
||||
return gateway;
|
||||
}
|
||||
|
||||
enum ChannelNotificationMode { all, mentionsOnly, muted }
|
||||
|
||||
extension UnitSystemValue on UnitSystem {
|
||||
String get value {
|
||||
switch (this) {
|
||||
@@ -150,7 +152,7 @@ class AppSettings {
|
||||
final Map<String, String> batteryChemistryByDeviceId;
|
||||
final Map<String, String> batteryChemistryByRepeaterId;
|
||||
final UnitSystem unitSystem;
|
||||
final Set<String> mutedChannels;
|
||||
final Map<String, ChannelNotificationMode> channelNotificationModes;
|
||||
final bool mapShowDiscoveryContacts;
|
||||
final bool evictDiscoveredContactsEnabled;
|
||||
final String tcpServerAddress;
|
||||
@@ -273,7 +275,7 @@ class AppSettings {
|
||||
Map<String, String>? batteryChemistryByDeviceId,
|
||||
Map<String, String>? batteryChemistryByRepeaterId,
|
||||
this.unitSystem = UnitSystem.metric,
|
||||
Set<String>? mutedChannels,
|
||||
Map<String, ChannelNotificationMode>? channelNotificationModes,
|
||||
this.mapShowDiscoveryContacts = true,
|
||||
this.evictDiscoveredContactsEnabled = true,
|
||||
this.tcpServerAddress = '',
|
||||
@@ -303,7 +305,7 @@ class AppSettings {
|
||||
String? selectedCyr2latProfileId,
|
||||
}) : batteryChemistryByDeviceId = batteryChemistryByDeviceId ?? {},
|
||||
batteryChemistryByRepeaterId = batteryChemistryByRepeaterId ?? {},
|
||||
mutedChannels = mutedChannels ?? {},
|
||||
channelNotificationModes = channelNotificationModes ?? {},
|
||||
imageCodecDownloadedModels = imageCodecDownloadedModels ?? const [],
|
||||
translationDownloadedModels = translationDownloadedModels ?? const [],
|
||||
cyr2latProfiles =
|
||||
@@ -361,7 +363,14 @@ class AppSettings {
|
||||
'battery_chemistry_by_device_id': batteryChemistryByDeviceId,
|
||||
'battery_chemistry_by_repeater_id': batteryChemistryByRepeaterId,
|
||||
'unit_system': unitSystem.value,
|
||||
'muted_channels': mutedChannels.toList(),
|
||||
// Written for older builds that only read the muted set.
|
||||
'muted_channels': [
|
||||
for (final entry in channelNotificationModes.entries)
|
||||
if (entry.value == ChannelNotificationMode.muted) entry.key,
|
||||
],
|
||||
'channel_notification_modes': channelNotificationModes.map(
|
||||
(key, value) => MapEntry(key, value.name),
|
||||
),
|
||||
'map_show_discovery_contacts': mapShowDiscoveryContacts,
|
||||
'evict_discovered_contacts_enabled': evictDiscoveredContactsEnabled,
|
||||
'tcp_server_address': tcpServerAddress,
|
||||
@@ -406,6 +415,35 @@ class AppSettings {
|
||||
return UnitSystem.metric;
|
||||
}
|
||||
|
||||
Map<String, ChannelNotificationMode> parseChannelNotificationModes(
|
||||
Map<String, dynamic> json,
|
||||
) {
|
||||
// Migration from old muted_channels (Set<String>) to new system
|
||||
final mutedList = json['muted_channels'] as List?;
|
||||
final newModes = json['channel_notification_modes'] as Map?;
|
||||
|
||||
final result = <String, ChannelNotificationMode>{};
|
||||
|
||||
// Migrate old muted channels
|
||||
if (mutedList != null) {
|
||||
for (final channelName in mutedList) {
|
||||
result[channelName.toString()] = ChannelNotificationMode.muted;
|
||||
}
|
||||
}
|
||||
|
||||
// Load new modes (overrides old muted channels if present)
|
||||
if (newModes != null) {
|
||||
for (final entry in newModes.entries) {
|
||||
final value = entry.value;
|
||||
if (value is! String) continue;
|
||||
final mode = ChannelNotificationMode.values.asNameMap()[value];
|
||||
if (mode != null) result[entry.key.toString()] = mode;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return AppSettings(
|
||||
clearPathOnMaxRetry: json['clear_path_on_max_retry'] as bool? ?? false,
|
||||
mapShowRepeaters: json['map_show_repeaters'] as bool? ?? true,
|
||||
@@ -468,11 +506,7 @@ class AppSettings {
|
||||
) ??
|
||||
{},
|
||||
unitSystem: parseUnitSystem(json['unit_system']),
|
||||
mutedChannels:
|
||||
((json['muted_channels'] as List?)
|
||||
?.map((e) => e.toString())
|
||||
.toSet()) ??
|
||||
{},
|
||||
channelNotificationModes: parseChannelNotificationModes(json),
|
||||
mapShowDiscoveryContacts:
|
||||
json['map_show_discovery_contacts'] as bool? ?? true,
|
||||
evictDiscoveredContactsEnabled:
|
||||
@@ -603,7 +637,7 @@ class AppSettings {
|
||||
Map<String, String>? batteryChemistryByDeviceId,
|
||||
Map<String, String>? batteryChemistryByRepeaterId,
|
||||
UnitSystem? unitSystem,
|
||||
Set<String>? mutedChannels,
|
||||
Map<String, ChannelNotificationMode>? channelNotificationModes,
|
||||
bool? mapShowDiscoveryContacts,
|
||||
bool? evictDiscoveredContactsEnabled,
|
||||
String? tcpServerAddress,
|
||||
@@ -692,7 +726,8 @@ class AppSettings {
|
||||
batteryChemistryByRepeaterId:
|
||||
batteryChemistryByRepeaterId ?? this.batteryChemistryByRepeaterId,
|
||||
unitSystem: unitSystem ?? this.unitSystem,
|
||||
mutedChannels: mutedChannels ?? this.mutedChannels,
|
||||
channelNotificationModes:
|
||||
channelNotificationModes ?? this.channelNotificationModes,
|
||||
mapShowDiscoveryContacts:
|
||||
mapShowDiscoveryContacts ?? this.mapShowDiscoveryContacts,
|
||||
evictDiscoveredContactsEnabled:
|
||||
|
||||
@@ -43,6 +43,17 @@ class Contact {
|
||||
|
||||
String get publicKeyHex => pubKeyToHex(publicKey);
|
||||
|
||||
/// Uppercase hex of the first [byteWidth] public-key bytes: the hash this
|
||||
/// node appears as in routing paths.
|
||||
String publicKeyPrefixHex(int byteWidth) {
|
||||
final width = byteWidth.clamp(1, 3).toInt();
|
||||
return publicKey
|
||||
.take(width)
|
||||
.map((b) => b.toRadixString(16).padLeft(2, '0'))
|
||||
.join()
|
||||
.toUpperCase();
|
||||
}
|
||||
|
||||
/// Non-localized type label, intended for logs and non-UI exports
|
||||
/// (e.g. GPX). For UI use the `typeLabel(l10n)` extension in
|
||||
/// `lib/l10n/contact_localization.dart`.
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
|
||||
import 'contact.dart';
|
||||
|
||||
/// The map's path-trace builder state: the hops picked so far, the trace
|
||||
/// mode and the last result. Held by [UiViewStateService] for the app session
|
||||
/// so leaving the map or opening the result doesn't discard it.
|
||||
class MapPathTraceDraft {
|
||||
bool active = false;
|
||||
Uint8List? radioKey;
|
||||
final List<int> pathBytes = [];
|
||||
final List<int> hopWidths = [];
|
||||
final List<Contact> contacts = [];
|
||||
final List<LatLng> points = [];
|
||||
bool returnPath = true;
|
||||
Uint8List? lastResultFrame;
|
||||
|
||||
bool get hasHops => pathBytes.isNotEmpty;
|
||||
|
||||
bool belongsTo(Uint8List? selfKey) =>
|
||||
radioKey == null || selfKey == null || listEquals(radioKey, selfKey);
|
||||
|
||||
void clear() {
|
||||
pathBytes.clear();
|
||||
hopWidths.clear();
|
||||
contacts.clear();
|
||||
points.clear();
|
||||
lastResultFrame = null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user