Drop account selection from the identities window

The window offered a "Use for new pairings" menu item, a "Selected" badge and a
group description about new pairings. Choosing the current identity is the
header switcher's job, not this window's, and the selection machinery took
space and attention in a dialog that is only about managing keys now.

Remove the menu item, the badge and the description; drop the now-unused
`current` argument and `current_identity()` lookup; and stop listening for
registry changes, since that listener only existed to refresh the badge.
This commit is contained in:
raucao committed 2026-11-26 18:06:24 +04:00
1 parent a8bbee1eb5
commit 3985f0710d
1 file changed
+13 -46
+13 -46
View File
@@ -1,13 +1,14 @@
//! The identity keys: named, several of them.
//!
//! Creating, importing, renaming, exporting and removing a key all happen here,
//! and the selected identity (used for new pairings and by the header switcher)
//! is chosen from the same list. This is the whole app on first run — there is
//! nothing to sign with and nothing to listen for until a key exists — and
//! afterwards it lives in its own window, reached from the identity switcher.
//! Creating, importing, renaming, exporting and removing a key all happen here.
//! This is the whole app on first run — there is nothing to sign with and
//! nothing to listen for until a key exists — and afterwards it lives in its own
//! window, reached from the identity switcher.
//!
//! The vault's passphrase, its auto-lock timeout and the device key are not key
//! *management* and live in Preferences (`ui/preferences.rs`).
//! Choosing which identity is *current* (the default for new pairings) is the
//! header switcher's job, not this window's. The vault's passphrase, its
//! auto-lock timeout and the device key are not key *management* and live in
//! Preferences (`ui/preferences.rs`).
use std::cell::RefCell;
use std::rc::Rc;
@@ -74,10 +75,6 @@ impl KeysView {
let list = adw::PreferencesGroup::builder()
.title("Identity keys")
.description(
"New pairings sign as the selected key. Each approved application keeps \
the key it was paired with.",
)
.build();
let add_group = adw::PreferencesGroup::builder().title("Add a key").build();
let create_row = plain::row(
@@ -118,23 +115,20 @@ impl KeysView {
button.connect_clicked(move |_| present_import(handles.clone(), Rc::clone(&state)));
}
// Reload on key changes and on a selection change.
// Reload on key changes (`refresh_identities` announces them with
// `notify`). The selection no longer shows here, so a registry change is
// nothing this window needs to hear about.
{
let (listener_state, handles, rows) =
(Rc::clone(&state), handles.clone(), Rc::clone(&rows));
state.listen(move || reload(&listener_state, &handles, &rows));
}
{
let (listener_state, handles, rows) =
(Rc::clone(&state), handles.clone(), Rc::clone(&rows));
state.listen_changes(move || reload(&listener_state, &handles, &rows));
}
Self { widget }
}
}
/// Rebuild the identity list from the shared state (names + selected key).
/// Rebuild the identity list from the shared state.
fn reload(state: &Rc<AppState>, handles: &Handles, rows: &Rows) {
for row in rows.borrow_mut().drain(..) {
handles.list.remove(&row);
@@ -142,7 +136,6 @@ fn reload(state: &Rc<AppState>, handles: &Handles, rows: &Rows) {
let names = state.names();
let names = names.lock().unwrap().clone();
let current = state.current_identity().map(|key| key.to_hex());
if names.is_empty() {
handles.stack.set_visible_child_name("empty");
@@ -156,14 +149,7 @@ fn reload(state: &Rc<AppState>, handles: &Handles, rows: &Rows) {
let profile = PublicKey::from_hex(&hex)
.ok()
.and_then(|key| state.profiles().display_name(&key));
let row = key_row(
state,
handles,
&hex,
&name,
profile.as_deref(),
current.as_deref() == Some(hex.as_str()),
);
let row = key_row(state, handles, &hex, &name, profile.as_deref());
handles.list.add(&row);
rows.borrow_mut().push(row);
}
@@ -175,7 +161,6 @@ fn key_row(
hex: &str,
name: &str,
profile: Option<&str>,
current: bool,
) -> adw::ActionRow {
let public_key = PublicKey::from_hex(hex).ok();
let npub = public_key
@@ -193,15 +178,6 @@ fn key_row(
// Initials avatar, from the kind-0 name when there is one.
row.add_prefix(&adw::Avatar::new(32, Some(profile.unwrap_or(name)), true));
if current {
let badge = gtk::Label::builder()
.label("Selected")
.css_classes(["dim-label"])
.valign(gtk::Align::Center)
.build();
row.add_suffix(&badge);
}
let menu = gtk::Box::builder()
.orientation(gtk::Orientation::Vertical)
.spacing(2)
@@ -209,15 +185,6 @@ fn key_row(
let popover = gtk::Popover::new();
popover.set_child(Some(&menu));
if !current {
if let Some(public_key) = public_key {
let use_button = menu_button("Use for new pairings");
let state = Rc::clone(state);
use_button.connect_clicked(move |_| state.set_current_identity(public_key));
menu.append(&use_button);
}
}
if let Some(public_key) = public_key {
let rename = menu_button("Rename…");
{