diff --git a/crates/voelin-ui/src/settings_pages/bind.rs b/crates/voelin-ui/src/settings_pages/bind.rs index 6e112c4..ecf10ef 100644 --- a/crates/voelin-ui/src/settings_pages/bind.rs +++ b/crates/voelin-ui/src/settings_pages/bind.rs @@ -426,23 +426,22 @@ impl App { self.state.own_uids = uids; } - /// The identity servers see us as on `bookmark` (the one place that - /// picks it): the bookmark's own if it names one that exists, else the - /// store's default. - fn identity_id_for(&self, bookmark: Option) -> Option { - let entries = self.store.identities().unwrap_or_default(); - bookmark - .and_then(|b| self.bookmark(b)) - .and_then(|b| b.identity) - .filter(|id| entries.iter().any(|e| e.id == *id)) - .or_else(|| self.default_identity_id()) + /// The identity a bookmark names, if it names one. + fn named_identity(&self, bookmark: Option) -> Option { + bookmark.and_then(|b| self.bookmark(b)).and_then(|b| b.identity) } - /// The identity a connection to `bookmark` uses ([`Self::identity_id_for`]). + /// The identity servers see us as on `bookmark`: the bookmark's own if it + /// names one that exists, else the store's default (the one place that + /// picks it is [`voelin_store::Store::identity_id_for`]). + fn identity_id_for(&self, bookmark: Option) -> Option { + self.store.identity_id_for(self.named_identity(bookmark)) + } + + /// The identity a connection to `bookmark` uses + /// ([`voelin_store::Store::identity_for`]). pub(crate) fn identity_for(&self, bookmark: Option) -> tsclientlib::Identity { - self.identity_id_for(bookmark) - .and_then(|id| self.store.identity(id).ok()) - .unwrap_or_else(|| self.identity.clone()) + self.store.identity_for(self.named_identity(bookmark), &self.identity) } /// The store's default identity (`Store::default_identity`).