remote-wallet: Append wallet "name" to entries in selector UI

This commit is contained in:
Trent Nelson 2020-10-07 20:05:15 -06:00 committed by Trent Nelson
parent 8e3353d9ef
commit f1a2ad1b7d
1 changed files with 6 additions and 3 deletions

View File

@ -525,13 +525,16 @@ pub fn get_ledger_from_info(
} }
let mut matches: Vec<(String, String)> = matches let mut matches: Vec<(String, String)> = matches
.filter(|&device_info| device_info.error.is_none()) .filter(|&device_info| device_info.error.is_none())
.map(|device_info| (device_info.host_device_path.clone(), device_info.get_pretty_path())) .map(|device_info| {
let query_item = format!("{} ({})", device_info.get_pretty_path(), device_info.model,);
(device_info.host_device_path.clone(), query_item)
})
.collect(); .collect();
if matches.is_empty() { if matches.is_empty() {
return Err(RemoteWalletError::NoDeviceFound); return Err(RemoteWalletError::NoDeviceFound);
} }
matches.sort_by(|a, b| a.1.cmp(&b.1)); matches.sort_by(|a, b| a.1.cmp(&b.1));
let (host_device_paths, device_paths): (Vec<Pubkey>, Vec<String>) = matches.into_iter().unzip(); let (host_device_paths, items): (Vec<String>, Vec<String>) = matches.into_iter().unzip();
let wallet_host_device_path = if host_device_paths.len() > 1 { let wallet_host_device_path = if host_device_paths.len() > 1 {
let selection = Select::with_theme(&ColorfulTheme::default()) let selection = Select::with_theme(&ColorfulTheme::default())
@ -540,7 +543,7 @@ pub fn get_ledger_from_info(
keypair_name keypair_name
)) ))
.default(0) .default(0)
.items(&device_paths[..]) .items(&items[..])
.interact() .interact()
.unwrap(); .unwrap();
&host_device_paths[selection] &host_device_paths[selection]