Don't re-create a removed contact when syncing its path or flags
The firmware's CMD_ADD_UPDATE_CONTACT adds the key when it isn't in the contact table. Screens that stay open after a contact is removed (e.g. a repeater admin screen after the repeater's keys were changed and the old contact deleted) sync the path before every send, so the next command, status or telemetry request silently added the old contact back. Skip path and flag writes for contacts no longer in the contact list.
This commit is contained in:
1 parent
f2a27f0f71
commit
21e727cf21
2 files changed
+36
-4
No files matched your search
@@ -4366,7 +4366,7 @@ class MeshCoreConnector extends ChangeNotifier {
|
||||
_pathOpLock = completer.future;
|
||||
await prev;
|
||||
try {
|
||||
if (!isConnected) return;
|
||||
if (!isConnected || !_isKnownContact(contact)) return;
|
||||
|
||||
final width =
|
||||
pathHashWidth ??
|
||||
@@ -4409,6 +4409,13 @@ class MeshCoreConnector extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether [contact] is still in the radio's contact list. The firmware's
|
||||
/// CMD_ADD_UPDATE_CONTACT adds unknown keys, so path/flag writes for a
|
||||
/// removed contact (e.g. a repeater screen still open after its old key was
|
||||
/// deleted) would re-create it on the radio.
|
||||
bool _isKnownContact(Contact contact) =>
|
||||
_contacts.any((c) => c.publicKeyHex == contact.publicKeyHex);
|
||||
|
||||
/// The advert timestamp the firmware holds for [contact] (Contact.lastSeen
|
||||
/// is parsed from that field); the stored copy is freshest.
|
||||
DateTime _deviceLastAdvert(Contact contact) {
|
||||
@@ -4425,7 +4432,7 @@ class MeshCoreConnector extends ChangeNotifier {
|
||||
bool? teleLoc,
|
||||
bool? teleEnv,
|
||||
}) async {
|
||||
if (!isConnected) return;
|
||||
if (!isConnected || !_isKnownContact(contact)) return;
|
||||
final latestContact =
|
||||
await _fetchContactSnapshotFromDevice(contact.publicKey) ?? contact;
|
||||
int updatedFlags = isFavorite != null
|
||||
|
||||
Reference in new issue
Block a user