view_state.rs (1867B)
1 use std::collections::{HashMap, HashSet}; 2 3 use enostr::Pubkey; 4 use notedeck::compact::CompactState; 5 use notedeck::Nip51SetCache; 6 use notedeck::ReportType; 7 use notedeck_ui::nip51_set::Nip51SetUiCache; 8 9 use crate::deck_state::DeckState; 10 use crate::login_manager::AcquireKeyState; 11 use crate::ui::search::SearchQueryState; 12 use enostr::ProfileState; 13 use notedeck_ui::media::MediaViewerState; 14 15 /// Various state for views 16 /// 17 /// TODO(jb55): we likely want to encapsulate these better, 18 /// or at least document where they are used 19 #[derive(Default)] 20 pub struct ViewState { 21 pub login: AcquireKeyState, 22 pub id_to_deck_state: HashMap<egui::Id, DeckState>, 23 pub id_state_map: HashMap<egui::Id, AcquireKeyState>, 24 pub id_string_map: HashMap<egui::Id, String>, 25 pub searches: HashMap<egui::Id, SearchQueryState>, 26 pub pubkey_to_profile_state: HashMap<Pubkey, ProfileState>, 27 28 /// Keeps track of what urls we are actively viewing in the 29 /// fullscreen media viewier, as well as any other state we want to 30 /// keep track of 31 pub media_viewer: MediaViewerState, 32 33 /// Keep track of checkbox state of follow pack onboarding 34 pub follow_packs: Nip51SetUiCache, 35 36 /// TOS acceptance screen checkbox state 37 pub tos_age_confirmed: bool, 38 pub tos_confirmed: bool, 39 40 /// Report screen selected report type 41 pub selected_report_type: Option<ReportType>, 42 43 /// Database compaction state 44 pub compact: CompactState, 45 46 /// Cache for people list selection in "Add Column" UI 47 pub people_lists: Option<Nip51SetCache>, 48 49 /// State for the "Create People List" flow 50 pub create_people_list: CreatePeopleListState, 51 } 52 53 #[derive(Default)] 54 pub struct CreatePeopleListState { 55 pub selected_members: HashSet<Pubkey>, 56 } 57 58 impl ViewState { 59 pub fn login_mut(&mut self) -> &mut AcquireKeyState { 60 &mut self.login 61 } 62 }