@@ -150,7 +150,7 @@ class WindowManager {
150150 if ( Array . isArray ( tabs ) && tabs . length ) {
151151 tabs . forEach ( ( tab , i ) => {
152152 setTimeout ( ( ) => {
153- this . addTab ( "loadContent.js" , tab . url , tab . title , false ) ;
153+ this . addTab ( "loadContent.js" , tab . url , tab . title ) ;
154154 } , 500 * i ) ;
155155 } ) ;
156156
@@ -308,7 +308,7 @@ class WindowManager {
308308 url = `${ url } ${ args [ 2 ] } ` ;
309309 }
310310
311- this . addTab ( "loadContent.js" , url , undefined , false ) ;
311+ this . addTab ( "loadContent.js" , url ) ;
312312 } ) ;
313313 E . ipcMain . on ( "setFeatureFlags" , ( _ , args ) => {
314314 storage . setFeatureFlags ( args . featureFlags ) ;
@@ -660,36 +660,24 @@ class WindowManager {
660660 return false ;
661661 } ;
662662
663- public addTab = (
664- scriptPreload = "loadMainContent.js" ,
665- url = Const . RECENT_FILES ,
666- title ?: string ,
667- focused = true ,
668- ) : E . BrowserView => {
663+ public addTab = ( scriptPreload = "loadMainContent.js" , url = Const . RECENT_FILES , title ?: string ) : E . BrowserView => {
669664 const userId = storage . get ( ) . userId ;
670665 const tab = Tabs . newTab ( `${ url } ?fuid=${ userId } ` , this . getBounds ( ) , scriptPreload ) ;
671666
672- if ( focused ) {
673- this . focusTab ( tab . view . webContents . id ) ;
674- }
675-
676667 tab . view . webContents . on ( "will-navigate" , this . onMainWindowWillNavigate ) ;
677668 tab . view . webContents . on ( "new-window" , this . onNewWindow ) ;
678669
679670 MenuState . updateActionState ( Const . ACTIONTABSTATE ) ;
680671
672+ this . mainWindow . addBrowserView ( tab . view ) ;
673+ this . mainWindow . setTopBrowserView ( this . mainTab ) ;
681674 this . mainWindow . webContents . send ( "didTabAdd" , {
682675 id : tab . view . webContents . id ,
683676 url,
684677 showBackBtn : true ,
685678 title,
686- focused,
687679 } ) ;
688680
689- if ( focused ) {
690- this . focusTab ( tab . view . webContents . id ) ;
691- }
692-
693681 tab . view . webContents . session . setPermissionRequestHandler ( ( webContents , permission , cb ) => {
694682 if ( permission === "media" ) {
695683 if ( tab . micAccess ) {
@@ -724,7 +712,8 @@ class WindowManager {
724712 const url = `${ Const . RECENT_FILES } /?fuid=${ userId } ` ;
725713 const tab = Tabs . newTab ( url , this . getBounds ( ) , "loadMainContent.js" , false ) ;
726714
727- this . mainWindow . setBrowserView ( tab . view ) ;
715+ this . mainWindow . addBrowserView ( tab . view ) ;
716+ this . mainWindow . setTopBrowserView ( tab . view ) ;
728717
729718 tab . view . webContents . on ( "will-navigate" , this . onMainTabWillNavigate ) ;
730719 tab . view . webContents . on ( "will-navigate" , this . onMainWindowWillNavigate ) ;
@@ -738,30 +727,17 @@ class WindowManager {
738727 } ;
739728
740729 public focusTab = ( webContentsId : number ) : void => {
741- const tabs = Tabs . getAll ( ) ;
742-
743- tabs . forEach ( tab => {
744- this . mainWindow . removeBrowserView ( tab . view ) ;
745- } ) ;
746-
747730 const neededTab = Tabs . getByWebContentId ( webContentsId ) ;
748731
749732 if ( ! neededTab ) {
750- this . mainWindow . addBrowserView ( this . mainTab ) ;
733+ this . mainWindow . setTopBrowserView ( this . mainTab ) ;
751734 this . lastFocusedTab = this . mainTab . webContents ;
752735
753736 return ;
754737 }
755738
756- this . mainWindow . addBrowserView ( neededTab . view ) ;
739+ this . mainWindow . setTopBrowserView ( neededTab . view ) ;
757740 this . lastFocusedTab = neededTab . view . webContents ;
758-
759- // Ugly hack for rerender BrowserView
760- setTimeout ( ( ) => {
761- this . mainWindow . removeBrowserView ( neededTab . view ) ;
762- this . mainWindow . addBrowserView ( neededTab . view ) ;
763- this . lastFocusedTab = neededTab . view . webContents ;
764- } , 500 ) ;
765741 } ;
766742
767743 private initSettingsView = ( ) => {
0 commit comments