forked from jsnbuchanan/crowd-funder-for-time-pwa
fix: prevent duplicate contacts during QR code scanning
- Add explicit duplicate contact check before database insertion - Show warning notification when duplicate contact is detected - Return early to prevent duplicate database entries - Improve user feedback for duplicate contact scenarios This change ensures users get clear feedback when scanning an already-added contact and prevents duplicate entries in the contacts database.
This commit is contained in:
@@ -574,6 +574,26 @@ export default class ContactQRScanShow extends Vue {
|
||||
try {
|
||||
logger.info("Opening database connection for new contact");
|
||||
await db.open();
|
||||
|
||||
// Check if contact already exists
|
||||
const existingContacts = await db.contacts.toArray();
|
||||
const existingContact = existingContacts.find(c => c.did === contact.did);
|
||||
|
||||
if (existingContact) {
|
||||
logger.info("Contact already exists", { did: contact.did });
|
||||
this.$notify(
|
||||
{
|
||||
group: "alert",
|
||||
type: "warning",
|
||||
title: "Contact Exists",
|
||||
text: "This contact has already been added to your list.",
|
||||
},
|
||||
3000,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Add new contact
|
||||
await db.contacts.add(contact);
|
||||
|
||||
if (this.activeDid) {
|
||||
|
||||
Reference in New Issue
Block a user