@@ -4,38 +4,39 @@ import type { Tab } from "./Tab";
44// history api emulation
55export class HistoryState {
66 url : URL ;
7- tab : Tab ;
87 state : any ;
9- title ?: string ;
10- favicon ?: string ;
8+ title : string | null ;
9+ favicon : string | null ;
10+ timestamp : number ;
1111
1212 constructor ( partial ?: Partial < HistoryState > ) {
1313 Object . assign ( this , partial ) ;
14+ this . timestamp = Date . now ( ) ;
1415 }
1516
1617 serialize ( ) : SerializedHistoryState {
1718 return {
1819 state : this . state ,
1920 url : this . url . href ,
20- tab : this . tab . id ,
2121 title : this . title ,
2222 favicon : this . favicon ,
23+ timestamp : this . timestamp ,
2324 } ;
2425 }
2526 deserialize ( de : SerializedHistoryState ) {
2627 this . state = de . state ;
2728 this . url = new URL ( de . url ) ;
28- this . tab = browser . tabs . find ( ( t ) => t . id === de . tab ) || this . tab ;
2929 this . title = de . title ;
3030 this . favicon = de . favicon ;
31+ this . timestamp = de . timestamp ;
3132 }
3233}
3334export type SerializedHistoryState = {
3435 state : any ;
3536 url : string ;
36- tab : number ;
37- title ? : string ;
38- favicon ?: string ;
37+ title : string | null ;
38+ favicon : string | null ;
39+ timestamp : number ;
3940} ;
4041
4142export type SerializedHistory = {
@@ -73,8 +74,8 @@ export class History {
7374 }
7475
7576 push ( url : URL , state : any = null , navigate : boolean = true ) : HistoryState {
76- const hstate = new HistoryState ( { url, state, tab : this . tab } ) ;
77- browser . globalhistory . push ( hstate ) ;
77+ const hstate = new HistoryState ( { url, state } ) ;
78+ if ( url . href != "puter://newtab" ) browser . globalhistory . push ( hstate ) ;
7879 this . states . push ( hstate ) ;
7980 this . index ++ ;
8081
@@ -89,9 +90,8 @@ export class History {
8990 if ( this . index < this . states . length ) {
9091 this . current ( ) . url = url ;
9192 this . current ( ) . state = state ;
92- this . current ( ) . tab = this . tab ;
93- this . current ( ) . title = undefined ;
94- this . current ( ) . favicon = undefined ;
93+ this . current ( ) . title = null ;
94+ this . current ( ) . favicon = null ;
9595 } else {
9696 return this . push ( url , state ) ;
9797 }
0 commit comments