@@ -29,22 +29,22 @@ export class SearchHistory {
2929 private readonly localStorage = inject ( LOCAL_STORAGE ) ;
3030 private readonly history = signal < Map < string , HistoryItem > > ( new Map ( ) ) ;
3131
32- private allItems = computed ( ( ) =>
32+ private readonly allItems = computed ( ( ) =>
3333 Array . from ( this . history ( ) . values ( ) ) . sort ( ( a , b ) => b . createdAt - a . createdAt ) ,
3434 ) ;
3535
36- items = computed < { recent : HistoryItem [ ] ; favorite : HistoryItem [ ] } > ( ( ) => ( {
36+ readonly items = computed < { recent : HistoryItem [ ] ; favorite : HistoryItem [ ] } > ( ( ) => ( {
3737 recent : this . allItems ( ) . filter ( ( v ) => ! v . isFavorite ) ,
3838 favorite : this . allItems ( ) . filter ( ( v ) => v . isFavorite ) ,
3939 } ) ) ;
4040
41- hasItems = computed ( ( ) => this . allItems ( ) . length > 0 ) ;
41+ readonly hasItems = computed ( ( ) => this . allItems ( ) . length > 0 ) ;
4242
4343 constructor ( ) {
4444 this . loadHistory ( ) ;
4545 }
4646
47- addItem ( item : SearchResultItem | HistoryItem ) {
47+ addItem ( item : SearchResultItem | HistoryItem ) : void {
4848 this . updateHistory ( ( map ) => {
4949 const labelHtml = ( item . labelHtml || '' ) . replace ( / < \/ ? m a r k > / g, '' ) ;
5050
@@ -64,13 +64,13 @@ export class SearchHistory {
6464 } ) ;
6565 }
6666
67- removeItem ( item : SearchResultItem | HistoryItem ) {
67+ removeItem ( item : SearchResultItem | HistoryItem ) : void {
6868 this . updateHistory ( ( map ) => {
6969 map . delete ( item . id ) ;
7070 } ) ;
7171 }
7272
73- makeFavorite ( item : SearchResultItem | HistoryItem ) {
73+ makeFavorite ( item : SearchResultItem | HistoryItem ) : void {
7474 this . updateHistory ( ( map ) => {
7575 const updated = map . get ( item . id ) ;
7676 if ( updated ) {
@@ -83,7 +83,7 @@ export class SearchHistory {
8383 } ) ;
8484 }
8585
86- private loadHistory ( ) {
86+ private loadHistory ( ) : void {
8787 let parsedData : HistoryItem [ ] ;
8888
8989 try {
@@ -100,7 +100,7 @@ export class SearchHistory {
100100 this . history . set ( history ) ;
101101 }
102102
103- private updateHistory ( updateFn : ( map : Map < string , HistoryItem > ) => void ) {
103+ private updateHistory ( updateFn : ( map : Map < string , HistoryItem > ) => void ) : void {
104104 const history = new Map ( this . history ( ) ) ;
105105 updateFn ( history ) ;
106106 this . history . set ( history ) ;
0 commit comments