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5BBIQC LPSUBGUBMG2QHJJSAWQ35SZIMUR62R6ODPWBS7TSNNXJ5UJCNABQC 5BAPU7K6DRZD2DYLIW3GKD2SIM6ANP7RYWGDJ6JCGHB37MHJUMTAC T4UECD3SERZLQMSESSATEHQEPFDIZGMMWY35EPV6JV2WOYMR7JRQC IOXNOVX2FJWPCEFVUHA5FEKIZJQT45R7VBAA43EPAKKVF5IWF4GAC 6E6MSENZAZE7RGL4QBQD3MIAURXE5R3HINFWTNLOASJYVNHVOUMAC OPXFZKEBDHZZLXEJ2JRDYBOJH6YIN7UZNZYHVHMWMQVDTE2ZD53QC VCNKFNUF7OWVSWC6I5D25KUZ3XZZICZ3LHWVPF2N5ZSP7LQ2JOUQC 6YZAVBWU6E5FYOI5JGEIPXGZLIKAW6LS2AOFIQWEE5DMOPPCD5PQC ManagingRepoSubState::SelectingId {user_ids: _,user_selection_ix: _,user_selection_nav: _,
ManagingRepoSubState::SelectingIdentity {ids,selection_ix,selection_nav,confirmed_selection_ix,
} => todo!(),
} => {let main = el(container(view_selecting_identity(ids,confirmed_selection_ix.unwrap_or_else(|| *selection_ix),selection_nav,)).width(Length::Fill).height(Length::Fill));add_actions_and_report(None,main,window_size,allowed_actions,report,)}
ManagingRepoSubState::NoIdFound { repo: _ } => {let main = el(container(text("No Pijul identity found. Create a new one in with Pijul CLI and then reload it here.")).width(Length::Fill).height(Length::Fill));add_actions_and_report(None,main,window_size,allowed_actions,report,)}
}fn view_selecting_identity<'a>(ids: &'a [Id],selection_ix: usize,selection_nav: &'a nav_scrollable::State,) -> Element<'a, Msg, Theme> {el(column([el(text("Select identity:")),el(nav_scrollable(selection_nav,ids.iter().enumerate().map(|(ix, id)| {el(button(text(id.name.to_string())).on_press(Msg::SelectIdentity(ix)).class(if ix == selection_ix {theme::Button::Selected} else {theme::Button::Normal}))}),)),]))
user_ids: Vec<Id>,
user_ids: Option<Vec<Id>>,repo: Option<repo::State>,},SelectingIdentity {ids: Vec<Id>,selection_ix: usize,selection_nav: nav_scrollable::State,// This will be set if confirmed before a repo is loadedconfirmed_selection_ix: Option<usize>,
let load_id_task = Task::future(async {let id = spawn_blocking(identity::load).await.unwrap();ManagingRepoMsg::LoadedId(Box::new(id))});
let load_ids_task = load_identities_task();
ManagingRepoMsg::LoadedId(id) => {match &mut model.sub {model::ManagingRepoSubState::Loading { user_ids, repo } => {// TODO switch to `SelectingId` if more than one id foundif let Some(repo) = repo.take() {
ManagingRepoMsg::LoadedIdentities(ids) => {match ids {Ok(mut user_ids) => {let get_repo = |sub: &mut model::ManagingRepoSubState| {match sub {model::ManagingRepoSubState::Loading {repo,..} => repo.take(),model::ManagingRepoSubState::SelectingIdentity {repo,..} => repo.take(),model::ManagingRepoSubState::NoIdFound { repo } => {repo.take()}model::ManagingRepoSubState::Ready(_) => {unreachable!()}}};if user_ids.is_empty() {let repo = get_repo(&mut model.sub);
model::ManagingRepoSubState::Ready(ReadyState {user_id: *id,
model::ManagingRepoSubState::NoIdFound { repo }} else if user_ids.len() == 1 {let user_id = user_ids.pop().unwrap();match &mut model.sub {model::ManagingRepoSubState::Loading {user_ids,
selection: default(),navigation: default(),record_changes: default(),forking_channel_name: default(),logs: default(),to_record: default(),jobs: default(),})
} => {if let Some(repo) = repo.take() {model.sub =model::ManagingRepoSubState::Ready(ReadyState {user_id,repo,selection: default(),navigation: default(),record_changes: default(),forking_channel_name: default(),logs: default(),to_record: default(),jobs: default(),},)} else {*user_ids = Some(vec![user_id]);}}model::ManagingRepoSubState::SelectingIdentity {..} => {unreachable!()}model::ManagingRepoSubState::Ready(..) => {unreachable!()}model::ManagingRepoSubState::NoIdFound {repo,} => {if let Some(repo) = repo.take() {model.sub =model::ManagingRepoSubState::Ready(ReadyState {user_id,repo,selection: default(),navigation: default(),record_changes: default(),forking_channel_name: default(),logs: default(),to_record: default(),jobs: default(),},)} else {model.sub = model::ManagingRepoSubState::SelectingIdentity {ids: user_ids,selection_ix: default(),selection_nav: default(),confirmed_selection_ix: default(),repo: default(),};}}}
model::ManagingRepoSubState::SelectingId { .. } => {unreachable!()}model::ManagingRepoSubState::Ready(..) => {unreachable!()
Err(err) => {let msg =format!("Failed to load Pijul identity with {err:#?}");report::show_err(report, msg);
view::Msg::SelectIdentity(ix) => {if let model::ManagingRepoSubState::SelectingIdentity {ids,repo,confirmed_selection_ix,..} = &mut model.sub{if let Some(repo) = repo.take() {let user_id = ids.get(ix).unwrap().clone();model.sub =model::ManagingRepoSubState::Ready(ReadyState {user_id,repo,selection: default(),navigation: default(),record_changes: default(),forking_channel_name: default(),logs: default(),to_record: default(),jobs: default(),});} else {*confirmed_selection_ix = Some(ix);}}Task::none()}
} else if let model::ManagingRepoSubState::SelectingIdentity {ids,selection_ix,selection_nav: _,confirmed_selection_ix,repo,} = &mut model.sub{if let Some(repo) = repo.take() {let user_id = ids.get(*selection_ix).unwrap().clone();model.sub =model::ManagingRepoSubState::Ready(ReadyState {user_id,repo,selection: default(),navigation: default(),record_changes: default(),forking_channel_name: default(),logs: default(),to_record: default(),jobs: default(),});} else {*confirmed_selection_ix = Some(*selection_ix);}Task::none()
} else if let model::ManagingRepoSubState::SelectingIdentity {ids,selection_ix,selection_nav: _,confirmed_selection_ix,repo: _,} = &mut model.sub{match msg {selection::Msg::PressDir(dir) => match dir {inflorescence_model::selection::Dir::Down => {*confirmed_selection_ix = None;if *selection_ix == ids.len().saturating_sub(1) {*selection_ix = 0;} else {*selection_ix += 1;}}inflorescence_model::selection::Dir::Up => {*confirmed_selection_ix = None;if *selection_ix == 0 {*selection_ix = ids.len().saturating_sub(1);} else {*selection_ix -= 1;}}inflorescence_model::selection::Dir::Right| inflorescence_model::selection::Dir::Left => {}},selection::Msg::AltPressDir(_) => {}}Task::none()
model.sub = if user_ids.len() == 1 {let user_id = user_ids.pop().unwrap();model::ManagingRepoSubState::Ready(ReadyState {user_id,repo: repo_state,selection: default(),navigation: default(),record_changes: default(),forking_channel_name: default(),logs: default(),to_record: default(),jobs: default(),})} else {model::ManagingRepoSubState::SelectingId {user_ids: mem::take(user_ids),user_selection_ix: default(),user_selection_nav: default(),repo: Some(repo_state),
if let Some(user_ids) = user_ids {model.sub = if user_ids.len() == 1 {let user_id = user_ids.pop().unwrap();model::ManagingRepoSubState::Ready(ReadyState {user_id,repo: repo_state,selection: default(),navigation: default(),record_changes: default(),forking_channel_name: default(),logs: default(),to_record: default(),jobs: default(),})} else {model::ManagingRepoSubState::SelectingIdentity {ids: mem::take(user_ids),selection_ix: default(),selection_nav: default(),confirmed_selection_ix: default(),repo: Some(repo_state),}