@@ -4154,23 +4154,29 @@ var SessionStoreInternal = {
41544154 winData . tabs = [ ] ;
41554155 }
41564156
4157- // Remove tab entries duplicating already open tabs.
4158- // This is intended to work when both tab restore and fresh tab features
4159- // are enabled .
4157+ // CLIQZ-SPECIAL: this piece of code remove all the
4158+ // homepage entries from the session restore object
4159+ // except one, we need atleast one tab for restore .
41604160 if ( ! overwriteTabs ) {
4161- let homePages = HomePage . get ( ) . split ( "|" )
4162- // Use final URLs that get into session after redirection (see DB-1219).
4163- . map ( url => {
4164- return CliqzResources . matchUrlByString ( url ) ;
4165- } ) ;
4166- winData . tabs = winData . tabs . filter ( function ( tabData ) {
4167- if ( ! tabData . entries || ! tabData . entries . length ) {
4161+ let homePages = HomePage . get ( ) . split ( "|" ) ;
4162+ let hasHome = false ;
4163+ winData . tabs = winData . tabs . filter ( function ( { entries = [ ] } ) {
4164+ // Entries is array of history address URL, which allows back navigation
4165+ // even after restore.
4166+ // 0: moz-extension:asdasdasdasdassd
4167+ // 1: https://google.com
4168+ // 2: https://cliqz.com
4169+ // we are only interested in last entry
4170+ const lastEntry = entries [ entries . length - 1 ] || { } ;
4171+ if ( ! lastEntry . url ) {
41684172 return true ;
41694173 }
4170- let entryIndex = ( tabData . index || 1 ) - 1 ; // It's 1-based.
4171- let entry = tabData . entries [ entryIndex ] ||
4172- tabData . entries [ tabData . entries . length - 1 ] ;
4173- return homePages . indexOf ( entry . url ) == - 1 ;
4174+ const isHome = homePages . includes ( lastEntry . url ) ;
4175+ if ( isHome && hasHome ) {
4176+ return false ;
4177+ }
4178+ hasHome = true ;
4179+ return true ;
41744180 } ) ;
41754181 }
41764182
0 commit comments