Fix QR contact import replay guard, type fallback and rescan loops

- Pass the existing contact's advert timestamp (0 for new contacts) so the
  firmware replay guard does not drop the node's real adverts.
- Leave a missing/invalid QR type unset and fall back to the existing
  contact's type instead of rewriting repeaters/rooms as Companion.
- Show a failed state with Retry instead of reopening the camera, which
  rescanned the same QR and resent the frame in a loop.
- Keep the processing flag set after a successful import so the closing
  route cannot restart the camera, import again and pop twice.
This commit is contained in:
zjs81 committed 2026-09-27 12:04:05 -07:00
1 parent fba97b9628
commit 3c971705bd
5 files changed
+111 -19

No files matched your search

+6 -5
View File
@@ -11,14 +11,15 @@ class ScannedContact {
/// Contact name from the card form; empty string when unknown.
final String name;
/// Advert type: 1 Companion, 2 Repeater, 3 Room Server, 4 Sensor.
final int type;
/// Advert type: 1 Companion, 2 Repeater, 3 Room Server, 4 Sensor; null
/// when the card omits it or carries an unknown value.
final int? type;
const ScannedContact({
this.advertPacket,
this.publicKey,
this.name = '',
this.type = 1,
this.type,
});
bool get isAdvertPacket => advertPacket != null;
@@ -71,8 +72,8 @@ ScannedContact? _parseContactCard(Uri uri) {
}
final name = (params['name'] ?? '').trim();
int type = int.tryParse(params['type'] ?? '') ?? 1;
if (type < 1 || type > 4) type = 1;
int? type = int.tryParse(params['type'] ?? '');
if (type != null && (type < 1 || type > 4)) type = null;
return ScannedContact(publicKey: publicKey, name: name, type: type);
}