@@ -86,7 +86,6 @@ export class ServerManagerView {
8686 activeTabIndex : number ;
8787 tabs : ServerOrFunctionalTab [ ] ;
8888 functionalTabs : Map < TabPage , number > ;
89- tabId : number ;
9089 presetOrgs : string [ ] ;
9190 preferenceView ?: PreferenceView ;
9291 constructor ( ) {
@@ -132,7 +131,6 @@ export class ServerManagerView {
132131 this . tabs = [ ] ;
133132 this . presetOrgs = [ ] ;
134133 this . functionalTabs = new Map ( ) ;
135- this . tabId = 0 ;
136134 }
137135
138136 async init ( ) : Promise < void > {
@@ -375,7 +373,7 @@ export class ServerManagerView {
375373 }
376374
377375 initServer ( server : ServerConfig , index : number ) : ServerTab {
378- const tabId = this . gettabId ( ) ;
376+ const tabId = server . id ;
379377 const tab : ServerTab = new ServerTab ( {
380378 role : "server" ,
381379 icon : DomainUtil . iconAsUrl ( server . icon ) ,
@@ -483,10 +481,8 @@ export class ServerManagerView {
483481 this . toggleDndButton ( dnd ) ;
484482 }
485483
486- gettabId ( ) : number {
487- const currentIndex = this . tabId ;
488- this . tabId ++ ;
489- return currentIndex ;
484+ generateTabId ( ) : string {
485+ return DomainUtil . generateDomainId ( ) ;
490486 }
491487
492488 async getCurrentActiveServer ( ) : Promise < string > {
@@ -574,7 +570,7 @@ export class ServerManagerView {
574570 const index = this . tabs . length ;
575571 this . functionalTabs . set ( tabProperties . page , index ) ;
576572
577- const tabId = this . gettabId ( ) ;
573+ const tabId = this . generateTabId ( ) ;
578574 const $view = await tabProperties . makeView ( ) ;
579575 this . $webviewsContainer . append ( $view ) ;
580576
@@ -669,7 +665,8 @@ export class ServerManagerView {
669665 page : tab . properties . page ,
670666 label : tab . properties . label ,
671667 index : tab . properties . index ,
672- } ) ) ;
668+ id : tab . properties . tabId ,
669+ } ) ) ;
673670 }
674671
675672 async activateTab ( index : number , hideOldTab = true ) : Promise < void > {
@@ -811,14 +808,18 @@ export class ServerManagerView {
811808 }
812809 }
813810
814- async isLoggedIn ( tabId : number ) : Promise < boolean > {
815- const tab = this . tabs [ tabId ] ;
811+ async isLoggedIn ( index : number ) : Promise < boolean > {
812+ const tab = this . tabs [ index ] ;
816813 if ( ! ( tab instanceof ServerTab ) ) return false ;
817814 const webview = await tab . webview ;
818815 const url = webview . getWebContents ( ) . getURL ( ) ;
819816 return ! ( url . endsWith ( "/login/" ) || webview . loading ) ;
820817 }
821818
819+ getTabById ( tabId : string ) : ServerOrFunctionalTab | undefined {
820+ return this . tabs . find ( ( tab ) => tab . properties . tabId === tabId ) ;
821+ }
822+
822823 addContextMenu ( $serverImg : HTMLElement , index : number ) : void {
823824 $serverImg . addEventListener ( "contextmenu" , async ( event ) => {
824825 event . preventDefault ( ) ;
@@ -1005,8 +1006,9 @@ export class ServerManagerView {
10051006 ipcRenderer . send ( "reload-full-app" ) ;
10061007 } ) ;
10071008
1008- ipcRenderer . on ( "switch-server-tab" , async ( event , index : number ) => {
1009- await this . activateLastTab ( index ) ;
1009+ ipcRenderer . on ( "switch-server-tab" , async ( event , tabId : string ) => {
1010+ const tab = this . getTabById ( tabId ) ! ;
1011+ await this . activateLastTab ( tab . properties . index ) ;
10101012 } ) ;
10111013
10121014 ipcRenderer . on ( "open-org-tab" , async ( ) => {
0 commit comments