refactor(data): make AddressBook an App-owned shared instance
Phase 0a of the Contacts/Chat plan. The address book was a file-scoped singleton (`s_address_book` + `getAddressBook()`) trapped inside address_book_dialog.cpp, reachable only from that TU. Promote it to an App-owned member so the upcoming Contacts tab, the Send contact picker, and a future Chat roster all read one source of truth. - app.h: add `data::AddressBook address_book_;` + `App::addressBook()` accessors, next to the other owned data models. - app.cpp: load it once in App::init() (idempotent; missing file is fine; purely local, no daemon dependency). - address_book_dialog.cpp: delete the singleton + getAddressBook(); read through the App* the dialog already carries (dropping the dead `(void)app;`). show() is static so it can't reach the App — drop its per-open reload (the book is authoritative for the app lifetime and self-saves on mutation). Drop the now-unused <memory> include. No behavior change; groundwork for the Contacts tab. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -454,6 +454,10 @@ bool App::init()
|
||||
tryConnect();
|
||||
}
|
||||
|
||||
// Populate the shared contact store from disk (per-variant addressbook.json).
|
||||
// Idempotent; a missing file is fine (returns true). Purely local — no daemon/RPC dependency.
|
||||
address_book_.load();
|
||||
|
||||
DEBUG_LOGF("Initialization complete\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user