From 402a8916f7d50f3148a5af97d34aee8da8cdf43c Mon Sep 17 00:00:00 2001 From: otsmr Date: Thu, 16 Oct 2025 23:22:58 +0200 Subject: [PATCH] fix issue with username change after deletion --- lib/src/services/api.service.dart | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/src/services/api.service.dart b/lib/src/services/api.service.dart index f1a88ed..461d180 100644 --- a/lib/src/services/api.service.dart +++ b/lib/src/services/api.service.dart @@ -339,12 +339,18 @@ class ApiService { } if (res.error == ErrorCode.UserIdNotFound && contactId != null) { Log.error('Contact deleted their account $contactId.'); - await twonlyDB.contactsDao.updateContact( - contactId, - const ContactsCompanion( - deleted: Value(true), - ), - ); + final contact = await twonlyDB.contactsDao + .getContactByUserId(contactId) + .getSingleOrNull(); + if (contact != null) { + await twonlyDB.contactsDao.updateContact( + contactId, + ContactsCompanion( + deleted: const Value(true), + username: Value('${contact.username} (${contact.userId})'), + ), + ); + } } } return res;