From f76d71fede7336f368631bb437e971c3024bca2a Mon Sep 17 00:00:00 2001 From: DanS Date: Tue, 13 Oct 2026 16:00:10 -0500 Subject: [PATCH] fix(chat): drop a redundant save and report a real contact-save result Renaming or adding a contact from the chat tab called the address-book mutator and then saved again, even though the mutator already persists. It also reported success unconditionally, so a failed rename still showed a success toast. - The redundant explicit save is removed; the mutator's own save stands. - A rename now shows success only when the mutator succeeds and an error toast when it does not. Co-Authored-By: Claude Opus 4.8 --- src/ui/windows/chat_tab.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ui/windows/chat_tab.cpp b/src/ui/windows/chat_tab.cpp index 7e26819..63d6360 100644 --- a/src/ui/windows/chat_tab.cpp +++ b/src/ui/windows/chat_tab.cpp @@ -1118,12 +1118,12 @@ void RenderChatTab(App* app) if (nm != book.entries()[bookIdx].label) { // skip a no-op rewrite/save data::AddressBookEntry e = book.entries()[bookIdx]; e.label = nm; // keep address/notes/scope/avatar - book.updateEntry(static_cast(bookIdx), e); - book.save(); - Notifications::instance().success(TR("chat_renamed")); + if (book.updateEntry(static_cast(bookIdx), e)) // mutator already saves + Notifications::instance().success(TR("chat_renamed")); + else + Notifications::instance().error(TR("address_book_update_failed")); } - } else if (book.addEntry(data::AddressBookEntry(nm, sel->peerZaddr))) { - book.save(); + } else if (book.addEntry(data::AddressBookEntry(nm, sel->peerZaddr))) { // mutator already saves Notifications::instance().success(TR("chat_contact_added")); } else { Notifications::instance().error(TR("address_book_exists"));