columns.json migration integration
Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
64
src/app.rs
64
src/app.rs
@@ -4,7 +4,7 @@ use crate::{
|
|||||||
app_size_handler::AppSizeHandler,
|
app_size_handler::AppSizeHandler,
|
||||||
args::Args,
|
args::Args,
|
||||||
column::Columns,
|
column::Columns,
|
||||||
decks::{Decks, DecksCache},
|
decks::{Decks, DecksCache, FALLBACK_PUBKEY},
|
||||||
draft::Drafts,
|
draft::Drafts,
|
||||||
filter::FilterState,
|
filter::FilterState,
|
||||||
frame_history::FrameHistory,
|
frame_history::FrameHistory,
|
||||||
@@ -450,21 +450,8 @@ impl Damus {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|a| a.pubkey.bytes());
|
.map(|a| a.pubkey.bytes());
|
||||||
|
|
||||||
let decks_cache = if parsed_args.columns.is_empty() {
|
let decks_cache = if !parsed_args.columns.is_empty() {
|
||||||
if let Some(decks_cache) = storage::load_decks_cache(&path, &ndb) {
|
info!("DecksCache: loading from command line arguments");
|
||||||
info!("Using decks cache from disk");
|
|
||||||
decks_cache
|
|
||||||
} else {
|
|
||||||
info!("Could read not decks cache from disk");
|
|
||||||
let mut cache = DecksCache::new_with_demo_config(&ndb);
|
|
||||||
for account in accounts.get_accounts() {
|
|
||||||
cache.add_deck_default(account.pubkey);
|
|
||||||
}
|
|
||||||
set_demo(&mut cache, &ndb, &mut accounts, &mut unknown_ids);
|
|
||||||
|
|
||||||
cache
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let mut columns: Columns = Columns::new();
|
let mut columns: Columns = Columns::new();
|
||||||
for col in parsed_args.columns {
|
for col in parsed_args.columns {
|
||||||
if let Some(timeline) = col.into_timeline(&ndb, account) {
|
if let Some(timeline) = col.into_timeline(&ndb, account) {
|
||||||
@@ -472,14 +459,28 @@ impl Damus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut decks_cache = DecksCache::default();
|
columns_to_decks_cache(columns, account)
|
||||||
let mut decks = Decks::default();
|
} else if let Some(decks_cache) = storage::load_decks_cache(&path, &ndb) {
|
||||||
*decks.active_mut().columns_mut() = columns;
|
info!(
|
||||||
|
"DecksCache: loading from disk {}",
|
||||||
if let Some(acc) = account {
|
crate::storage::DECKS_CACHE_FILE
|
||||||
decks_cache.add_decks(Pubkey::new(*acc), decks);
|
);
|
||||||
}
|
|
||||||
decks_cache
|
decks_cache
|
||||||
|
} else if let Some(cols) = storage::deserialize_columns(&path, &ndb, account) {
|
||||||
|
info!(
|
||||||
|
"DecksCache: loading from disk at depreciated location {}",
|
||||||
|
crate::storage::COLUMNS_FILE
|
||||||
|
);
|
||||||
|
columns_to_decks_cache(cols, account)
|
||||||
|
} else {
|
||||||
|
info!("DecksCache: creating new with demo configuration");
|
||||||
|
let mut cache = DecksCache::new_with_demo_config(&ndb);
|
||||||
|
for account in accounts.get_accounts() {
|
||||||
|
cache.add_deck_default(account.pubkey);
|
||||||
|
}
|
||||||
|
set_demo(&mut cache, &ndb, &mut accounts, &mut unknown_ids);
|
||||||
|
|
||||||
|
cache
|
||||||
};
|
};
|
||||||
|
|
||||||
let debug = parsed_args.debug;
|
let debug = parsed_args.debug;
|
||||||
@@ -823,3 +824,20 @@ pub fn set_demo(
|
|||||||
.process_action(unk_ids, ndb, &txn);
|
.process_action(unk_ids, ndb, &txn);
|
||||||
accounts.select_account(accounts.num_accounts() - 1);
|
accounts.select_account(accounts.num_accounts() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn columns_to_decks_cache(cols: Columns, key: Option<&[u8; 32]>) -> DecksCache {
|
||||||
|
let mut account_to_decks: HashMap<Pubkey, Decks> = Default::default();
|
||||||
|
let decks = Decks::new(crate::decks::Deck::new_with_columns(
|
||||||
|
crate::decks::Deck::default().icon,
|
||||||
|
"My Deck".to_owned(),
|
||||||
|
cols,
|
||||||
|
));
|
||||||
|
|
||||||
|
let account = if let Some(key) = key {
|
||||||
|
Pubkey::new(*key)
|
||||||
|
} else {
|
||||||
|
FALLBACK_PUBKEY()
|
||||||
|
};
|
||||||
|
account_to_decks.insert(account, decks);
|
||||||
|
DecksCache::new(account_to_decks)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
mod decks;
|
mod decks;
|
||||||
mod file_key_storage;
|
mod file_key_storage;
|
||||||
mod file_storage;
|
mod file_storage;
|
||||||
|
mod migration;
|
||||||
|
|
||||||
pub use decks::{load_decks_cache, save_decks_cache};
|
pub use decks::{load_decks_cache, save_decks_cache, DECKS_CACHE_FILE};
|
||||||
pub use file_key_storage::FileKeyStorage;
|
pub use file_key_storage::FileKeyStorage;
|
||||||
pub use file_storage::{delete_file, write_file, DataPath, DataPathType, Directory};
|
pub use file_storage::{delete_file, write_file, DataPath, DataPathType, Directory};
|
||||||
|
pub use migration::{deserialize_columns, COLUMNS_FILE};
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
mod security_framework_key_storage;
|
mod security_framework_key_storage;
|
||||||
|
|||||||
Reference in New Issue
Block a user