onboarding: use demo config when no accounts
Closes: #487 Fixes: https://github.com/damus-io/notedeck/issues/446 Signed-off-by: kernelkind <kernelkind@gmail.com> Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
committed by
William Casarin
parent
236d1684e7
commit
c2bdae1dcb
37
src/app.rs
37
src/app.rs
@@ -19,13 +19,13 @@ use crate::{
|
|||||||
support::Support,
|
support::Support,
|
||||||
thread::Thread,
|
thread::Thread,
|
||||||
timeline::{self, Timeline, TimelineKind},
|
timeline::{self, Timeline, TimelineKind},
|
||||||
ui::{self, add_column::AddColumnRoute, DesktopSidePanel},
|
ui::{self, DesktopSidePanel},
|
||||||
unknowns::UnknownIds,
|
unknowns::UnknownIds,
|
||||||
view_state::ViewState,
|
view_state::ViewState,
|
||||||
Result,
|
Result,
|
||||||
};
|
};
|
||||||
|
|
||||||
use enostr::{ClientMessage, RelayEvent, RelayMessage, RelayPool};
|
use enostr::{ClientMessage, Keypair, Pubkey, RelayEvent, RelayMessage, RelayPool};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use egui::{Context, Frame, Style};
|
use egui::{Context, Frame, Style};
|
||||||
@@ -498,10 +498,7 @@ impl Damus {
|
|||||||
|
|
||||||
if columns.columns().is_empty() {
|
if columns.columns().is_empty() {
|
||||||
if accounts.get_accounts().is_empty() {
|
if accounts.get_accounts().is_empty() {
|
||||||
columns.add_column(Column::new(vec![
|
set_demo(&path, &ndb, &mut accounts, &mut columns, &mut unknown_ids);
|
||||||
Route::AddColumn(AddColumnRoute::Base),
|
|
||||||
Route::Accounts(AccountsRoute::AddAccount),
|
|
||||||
]));
|
|
||||||
} else {
|
} else {
|
||||||
columns.new_column_picker();
|
columns.new_column_picker();
|
||||||
}
|
}
|
||||||
@@ -877,3 +874,31 @@ impl eframe::App for Damus {
|
|||||||
render_damus(self, ctx);
|
render_damus(self, ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_demo(
|
||||||
|
data_path: &DataPath,
|
||||||
|
ndb: &Ndb,
|
||||||
|
accounts: &mut Accounts,
|
||||||
|
columns: &mut Columns,
|
||||||
|
unk_ids: &mut UnknownIds,
|
||||||
|
) {
|
||||||
|
let demo_pubkey =
|
||||||
|
Pubkey::from_hex("aa733081e4f0f79dd43023d8983265593f2b41a988671cfcef3f489b91ad93fe")
|
||||||
|
.unwrap();
|
||||||
|
{
|
||||||
|
let txn = Transaction::new(ndb).expect("txn");
|
||||||
|
accounts
|
||||||
|
.add_account(Keypair::only_pubkey(demo_pubkey))
|
||||||
|
.process_action(unk_ids, ndb, &txn);
|
||||||
|
accounts.select_account(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
columns.add_column(Column::new(vec![Route::Accounts(AccountsRoute::Accounts)]));
|
||||||
|
let timeline = TimelineKind::contact_list(timeline::PubkeySource::Explicit(demo_pubkey))
|
||||||
|
.into_timeline(ndb, Some(demo_pubkey.bytes()));
|
||||||
|
|
||||||
|
if let Some(timeline) = timeline {
|
||||||
|
columns.add_new_timeline_column(timeline);
|
||||||
|
}
|
||||||
|
storage::save_columns(data_path, columns.as_serializable_columns());
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user