notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit c2bdae1dcb9b55d340394dc40652e85a369f464c
parent 236d1684e75ad9e8208f11323136bfb1fb80633a
Author: kernelkind <kernelkind@gmail.com>
Date:   Fri, 29 Nov 2024 10:13:39 -0500

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>

Diffstat:
Msrc/app.rs | 37+++++++++++++++++++++++++++++++------
1 file changed, 31 insertions(+), 6 deletions(-)

diff --git a/src/app.rs b/src/app.rs @@ -19,13 +19,13 @@ use crate::{ support::Support, thread::Thread, timeline::{self, Timeline, TimelineKind}, - ui::{self, add_column::AddColumnRoute, DesktopSidePanel}, + ui::{self, DesktopSidePanel}, unknowns::UnknownIds, view_state::ViewState, Result, }; -use enostr::{ClientMessage, RelayEvent, RelayMessage, RelayPool}; +use enostr::{ClientMessage, Keypair, Pubkey, RelayEvent, RelayMessage, RelayPool}; use uuid::Uuid; use egui::{Context, Frame, Style}; @@ -498,10 +498,7 @@ impl Damus { if columns.columns().is_empty() { if accounts.get_accounts().is_empty() { - columns.add_column(Column::new(vec![ - Route::AddColumn(AddColumnRoute::Base), - Route::Accounts(AccountsRoute::AddAccount), - ])); + set_demo(&path, &ndb, &mut accounts, &mut columns, &mut unknown_ids); } else { columns.new_column_picker(); } @@ -877,3 +874,31 @@ impl eframe::App for Damus { 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()); +}