refactor account switcher & management previews
Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
committed by
William Casarin
parent
22264e70f5
commit
7ebd694f11
@@ -1,7 +1,14 @@
|
||||
use enostr::{FullKeypair, Pubkey, RelayPool};
|
||||
use nostrdb::ProfileRecord;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::account_manager::UserAccount;
|
||||
use enostr::{FullKeypair, Pubkey, RelayPool};
|
||||
use nostrdb::{Config, Ndb, ProfileRecord};
|
||||
|
||||
use crate::{
|
||||
account_manager::{AccountManager, UserAccount},
|
||||
imgcache::ImageCache,
|
||||
key_storage::KeyStorage,
|
||||
relay_generation::RelayGenerator,
|
||||
};
|
||||
|
||||
#[allow(unused_must_use)]
|
||||
pub fn sample_pool() -> RelayPool {
|
||||
@@ -86,3 +93,22 @@ pub fn get_test_accounts() -> Vec<UserAccount> {
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn get_accmgr_and_ndb_and_imgcache() -> (AccountManager, Ndb, ImageCache) {
|
||||
let mut account_manager =
|
||||
AccountManager::new(None, KeyStorage::None, RelayGenerator::Constant, || {});
|
||||
let accounts = get_test_accounts();
|
||||
accounts
|
||||
.into_iter()
|
||||
.for_each(|acc| account_manager.add_account(acc.key, || {}));
|
||||
|
||||
let mut config = Config::new();
|
||||
config.set_ingester_threads(2);
|
||||
|
||||
let db_dir = Path::new(".");
|
||||
let path = db_dir.to_str().unwrap();
|
||||
let ndb = Ndb::new(path, &config).expect("ndb");
|
||||
let imgcache_dir = db_dir.join("cache/img");
|
||||
let img_cache = ImageCache::new(imgcache_dir);
|
||||
(account_manager, ndb, img_cache)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user