fix issue with username change after deletion

This commit is contained in:
otsmr 2025-10-16 23:22:58 +02:00
parent cb2f0d00a6
commit 402a8916f7

View file

@ -339,14 +339,20 @@ class ApiService {
}
if (res.error == ErrorCode.UserIdNotFound && contactId != null) {
Log.error('Contact deleted their account $contactId.');
final contact = await twonlyDB.contactsDao
.getContactByUserId(contactId)
.getSingleOrNull();
if (contact != null) {
await twonlyDB.contactsDao.updateContact(
contactId,
const ContactsCompanion(
deleted: Value(true),
ContactsCompanion(
deleted: const Value(true),
username: Value('${contact.username} (${contact.userId})'),
),
);
}
}
}
return res;
}