@@ -86,7 +86,6 @@ export class ServerManagerView {
8686 activeTab ?: ServerOrFunctionalTab ;
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
@@ -668,6 +664,7 @@ export class ServerManagerView {
668664 page : tab . properties . page ,
669665 label : tab . properties . label ,
670666 index : tab . properties . index ,
667+ id : tab . properties . tabId ,
671668 } ;
672669 }
673670
@@ -824,14 +821,18 @@ export class ServerManagerView {
824821 }
825822 }
826823
827- async isLoggedIn ( tabId : number ) : Promise < boolean > {
828- const tab = this . tabs [ tabId ] ;
824+ async isLoggedIn ( index : number ) : Promise < boolean > {
825+ const tab = this . tabs [ index ] ;
829826 if ( ! ( tab instanceof ServerTab ) ) return false ;
830827 const webview = await tab . webview ;
831828 const url = webview . getWebContents ( ) . getURL ( ) ;
832829 return ! ( url . endsWith ( "/login/" ) || webview . loading ) ;
833830 }
834831
832+ getTabById ( tabId : string ) : ServerOrFunctionalTab | undefined {
833+ return this . tabs . find ( ( tab ) => tab . properties . tabId === tabId ) ;
834+ }
835+
835836 addContextMenu ( $serverImg : HTMLElement , index : number ) : void {
836837 $serverImg . addEventListener ( "contextmenu" , async ( event ) => {
837838 event . preventDefault ( ) ;
@@ -1018,8 +1019,9 @@ export class ServerManagerView {
10181019 ipcRenderer . send ( "reload-full-app" ) ;
10191020 } ) ;
10201021
1021- ipcRenderer . on ( "switch-server-tab" , async ( event , index : number ) => {
1022- await this . activateLastTab ( index ) ;
1022+ ipcRenderer . on ( "switch-server-tab" , async ( event , tabId : string ) => {
1023+ const tab = this . getTabById ( tabId ) ! ;
1024+ await this . activateLastTab ( tab . properties . index ) ;
10231025 } ) ;
10241026
10251027 ipcRenderer . on ( "open-org-tab" , async ( ) => {
0 commit comments