refactor app state

This commit is contained in:
2024-11-24 15:17:35 +07:00
parent 17e7766401
commit db7e28a78a
12 changed files with 49 additions and 65 deletions

View File

@@ -1,12 +1,11 @@
use keyring_search::{Limit, List, Search};
use nostr_sdk::prelude::*;
use std::collections::HashSet;
pub fn get_all_accounts_from_keyring() -> HashSet<PublicKey> {
pub fn get_all_accounts_from_keyring() -> Vec<PublicKey> {
let search = Search::new().expect("Keyring not working.");
let results = search.by_service("Coop Safe Storage");
let list = List::list_credentials(&results, Limit::All);
let accounts: HashSet<PublicKey> = list
let accounts: Vec<PublicKey> = list
.split_whitespace()
.filter(|v| v.starts_with("npub1") && !v.ends_with("coop"))
.filter_map(|i| PublicKey::from_bech32(i).ok())