Main brings the merge of phase5/ui-vm: the toolkit-free crates/voelin-ui-vm
crate and the logic/bind split of crates/voelin-ui. Conflicts, and what each
resolution keeps:
- crates/voelin-ui/src/settings_pages.rs: main deleted it (it is
settings_pages/{mod,bind}.rs and voelin-ui-vm's settings_pages/logic.rs
now), this branch had changed its voelin_core::identity paths. Deleted; the
paths are voelin_core::ts::identity:: in bind.rs and in logic.rs.
- crates/voelin-ui/src/identities.rs: the module comment names
voelin_core::ts::identity::import_new (this branch) and settings_pages/
(main).
- docs/architecture.md: the voelin-core row of this branch with the
voelin-ui-vm and voelin-ui rows of main.
Not conflicts, but needed to compile: voelin-ui-vm named the in-tree
voelin-model by path, which this branch moved to the protocol repository
(workspace dependency), and imported voelin_core::identity::Found, which is
voelin_core::ts::identity::Found. Cargo.lock merged without a conflict and
resolves with --locked; THIRD_PARTY_NOTICES.md is up to date
(scripts/notices.sh --check).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
44 lines
1.3 KiB
Rust
44 lines
1.3 KiB
Rust
//! The identity servers see us as: the store's default (schema 4,
|
|
//! `Store::default_identity`), chosen under Settings → Profiles, and the
|
|
//! import of the official clients' identities on start
|
|
//! (`voelin_core::ts::identity::import_new`, app.rs). The rest of the Profiles
|
|
//! page is in `settings_pages/`.
|
|
|
|
use tracing::warn;
|
|
use voelin_core::settings::IDENTITY_IMPORT;
|
|
|
|
use crate::app::App;
|
|
|
|
impl App {
|
|
/// The user's choice of the identity servers see us as, from the next
|
|
/// connection on; no import replaces it.
|
|
pub(crate) fn use_identity(&mut self, id: i64) {
|
|
let result =
|
|
self.store.set_default_identity(id, true).and_then(|()| self.store.identity(id));
|
|
match result {
|
|
Ok(identity) => {
|
|
self.identity = identity;
|
|
let name = self
|
|
.store
|
|
.identities()
|
|
.ok()
|
|
.and_then(|all| all.into_iter().find(|e| e.id == id))
|
|
.map(|e| e.name)
|
|
.unwrap_or_default();
|
|
self.set_status(format!(
|
|
"Servers see you as \u{201c}{name}\u{201d} from your next connection"
|
|
));
|
|
}
|
|
Err(e) => self.set_status(format!("Could not change the identity: {e}")),
|
|
}
|
|
self.refresh_identities();
|
|
}
|
|
|
|
pub(crate) fn set_identity_import(&mut self, on: bool) {
|
|
if let Err(e) = self.prefs.set(&IDENTITY_IMPORT, on) {
|
|
warn!(%e, "could not store the setting");
|
|
}
|
|
self.refresh_identities();
|
|
}
|
|
}
|