@@ -15,7 +15,7 @@ use crate::{
1515 api:: { HnClient , types:: HnItemIdScalar } ,
1616 app:: {
1717 AppContext ,
18- history:: { ResumeItemHistoryData , SynchronizedHistoryItem } ,
18+ history:: { HistoryPersistCommand , ResumeItemHistoryData , SynchronizedHistoryItem } ,
1919 } ,
2020 errors:: Result ,
2121 ui:: {
@@ -39,7 +39,7 @@ impl ItemWithId<HnItemIdScalar> for ResumeItemHistoryData {
3939
4040#[ derive( Debug ) ]
4141pub struct ResumeList {
42- initialized : bool ,
42+ loaded : bool ,
4343 list_cutoff : usize ,
4444 /// The Item selected in the list, waiting to be fetched.
4545 ///
@@ -52,7 +52,7 @@ pub struct ResumeList {
5252impl Default for ResumeList {
5353 fn default ( ) -> Self {
5454 Self {
55- initialized : false ,
55+ loaded : false ,
5656 list_cutoff : RESUME_SCREEN_MAX_DISPLAYED_ITEMS ,
5757 pending_selected_item_id : None ,
5858 list_state : CustomListState :: with_items ( vec ! [ ] ) ,
@@ -69,7 +69,7 @@ impl UiComponent for ResumeList {
6969 }
7070
7171 fn before_unmount ( & mut self ) {
72- self . initialized = false ;
72+ self . loaded = false ;
7373 self . pending_selected_item_id = None ;
7474 }
7575
@@ -78,11 +78,11 @@ impl UiComponent for ResumeList {
7878 _elapsed_ticks : UiTickScalar ,
7979 _ctx : & AppContext ,
8080 ) -> Result < bool > {
81- Ok ( !self . initialized || self . pending_selected_item_id . is_some ( ) )
81+ Ok ( !self . loaded || self . pending_selected_item_id . is_some ( ) )
8282 }
8383
8484 async fn update ( & mut self , client : & mut HnClient , ctx : & mut AppContext ) -> Result < ( ) > {
85- if !self . initialized {
85+ if !self . loaded {
8686 let resume_items: Vec < _ > = ctx
8787 . get_history ( )
8888 . restored_resume_items ( )
@@ -94,7 +94,7 @@ impl UiComponent for ResumeList {
9494 if !self . list_state . is_empty ( ) && self . list_state . selected ( ) . is_none ( ) {
9595 self . list_state . select ( Some ( 0 ) ) ;
9696 }
97- self . initialized = true ;
97+ self . loaded = true ;
9898 }
9999
100100 if let Some ( item_id) = self . pending_selected_item_id . take ( ) {
@@ -143,7 +143,14 @@ impl UiComponent for ResumeList {
143143 true
144144 } else if let Some ( selected_index) = selected {
145145 let selected_item_id = self . list_state . get_items ( ) [ selected_index] . get_id ( ) ;
146- if inputs. is_active ( & ApplicationAction :: OpenHackerNewsLink )
146+ if inputs. is_active ( & ApplicationAction :: ResumeClearEntry ) {
147+ ctx. get_history_mut ( )
148+ . persist ( & [ HistoryPersistCommand :: ResumeRemove {
149+ item_id : selected_item_id,
150+ } ] ) ;
151+ self . loaded = false ;
152+ true
153+ } else if inputs. is_active ( & ApplicationAction :: OpenHackerNewsLink )
147154 // the external URL of a stored Item, if any, is unknown until it is
148155 // fetched: both link actions can only open its Hacker News page here
149156 || inputs. is_active ( & ApplicationAction :: OpenExternalOrHackerNewsLink )
0 commit comments