@@ -382,15 +382,14 @@ export class ServerManagerView {
382382 webview : WebView . create ( {
383383 $root : this . $webviewsContainer ,
384384 rootWebContents,
385- index,
386385 tabId,
387386 url : server . url ,
388387 role : "server" ,
389388 hasPermission : ( origin : string , permission : string ) =>
390389 origin === server . url &&
391390 permission === "notifications" &&
392391 ConfigUtil . getConfigItem ( "showNotification" , true ) ,
393- isActive : ( ) : boolean => this . tabs [ index ] === this . activeTab ,
392+ isActive : ( ) : boolean => this . getTabById ( tabId ) === this . activeTab ,
394393 switchLoading : async ( loading : boolean , url : string ) => {
395394 if ( loading ) {
396395 this . loading . add ( url ) ;
@@ -404,8 +403,8 @@ export class ServerManagerView {
404403 this . loading . has ( ( await activeTab . webview ) . properties . url ) ,
405404 ) ;
406405 } ,
407- onNetworkError : async ( index : number ) => {
408- await this . openNetworkTroubleshooting ( index ) ;
406+ onNetworkError : async ( id : string ) => {
407+ await this . openNetworkTroubleshooting ( id ) ;
409408 } ,
410409 onTitleChange : this . updateBadge . bind ( this ) ,
411410 preload : url . pathToFileURL ( path . join ( bundlePath , "preload.cjs" ) ) . href ,
@@ -625,8 +624,8 @@ export class ServerManagerView {
625624 } ) ;
626625 }
627626
628- async openNetworkTroubleshooting ( index : number ) : Promise < void > {
629- const tab = this . tabs [ index ] ;
627+ async openNetworkTroubleshooting ( id : string ) : Promise < void > {
628+ const tab = this . getTabById ( id ) ;
630629 if ( ! ( tab instanceof ServerTab ) ) return ;
631630 const webview = await tab . webview ;
632631 const reconnectUtil = new ReconnectUtil ( webview ) ;
@@ -737,7 +736,9 @@ export class ServerManagerView {
737736
738737 const wasActive = tab === this . activeTab ;
739738
740- delete this . tabs [ tab . properties . index ] ; // eslint-disable-line @typescript-eslint/no-array-delete
739+ this . tabs = this . tabs . filter (
740+ ( tabObject ) => tabObject . properties . tabId !== tabId ,
741+ ) ;
741742 await tab . destroy ( ) ;
742743 this . functionalTabs . delete ( page ) ;
743744
@@ -1092,9 +1093,9 @@ export class ServerManagerView {
10921093 ipcRenderer . on (
10931094 "update-realm-name" ,
10941095 ( event , serverURL : string , realmName : string ) => {
1095- for ( const [ index , domain ] of DomainUtil . getDomains ( ) . entries ( ) ) {
1096+ for ( const domain of DomainUtil . getDomains ( ) ) {
10961097 if ( domain . url === serverURL ) {
1097- const tab = this . tabs [ index ] ;
1098+ const tab = this . getTabById ( domain . id ) ;
10981099 if ( tab instanceof ServerTab ) tab . setLabel ( realmName ) ;
10991100 domain . alias = realmName ;
11001101 DomainUtil . updateDomainById ( domain . id , domain ) ;
@@ -1114,10 +1115,10 @@ export class ServerManagerView {
11141115 "update-realm-icon" ,
11151116 async ( event , serverURL : string , iconURL : string ) => {
11161117 await Promise . all (
1117- DomainUtil . getDomains ( ) . map ( async ( domain , index ) => {
1118+ DomainUtil . getDomains ( ) . map ( async ( domain ) => {
11181119 if ( domain . url === serverURL ) {
11191120 const localIconPath = await DomainUtil . saveServerIcon ( iconURL ) ;
1120- const tab = this . tabs [ index ] ;
1121+ const tab = this . getTabById ( domain . id ) ;
11211122 if ( tab instanceof ServerTab )
11221123 tab . setIcon ( DomainUtil . iconAsUrl ( localIconPath ) ) ;
11231124 domain . icon = localIconPath ;
0 commit comments