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 <noreply@anthropic.com>
This commit is contained in:
@@ -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<std::size_t>(bookIdx), e);
|
||||
book.save();
|
||||
Notifications::instance().success(TR("chat_renamed"));
|
||||
if (book.updateEntry(static_cast<std::size_t>(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"));
|
||||
|
||||
Reference in New Issue
Block a user