Skip to content

Commit b005d8b

Browse files
committed
main: Don't access tabs by index.
1 parent 6937044 commit b005d8b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

app/renderer/js/main.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,9 @@ export class ServerManagerView {
736736

737737
const wasActive = tab === this.activeTab;
738738

739-
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+
);
740742
await tab.destroy();
741743
this.functionalTabs.delete(page);
742744

@@ -1091,9 +1093,9 @@ export class ServerManagerView {
10911093
ipcRenderer.on(
10921094
"update-realm-name",
10931095
(event, serverURL: string, realmName: string) => {
1094-
for (const [index, domain] of DomainUtil.getDomains().entries()) {
1096+
for (const domain of DomainUtil.getDomains()) {
10951097
if (domain.url === serverURL) {
1096-
const tab = this.tabs[index];
1098+
const tab = this.getTabById(domain.id);
10971099
if (tab instanceof ServerTab) tab.setLabel(realmName);
10981100
domain.alias = realmName;
10991101
DomainUtil.updateDomainById(domain.id, domain);
@@ -1113,10 +1115,10 @@ export class ServerManagerView {
11131115
"update-realm-icon",
11141116
async (event, serverURL: string, iconURL: string) => {
11151117
await Promise.all(
1116-
DomainUtil.getDomains().map(async (domain, index) => {
1118+
DomainUtil.getDomains().map(async (domain) => {
11171119
if (domain.url === serverURL) {
11181120
const localIconPath = await DomainUtil.saveServerIcon(iconURL);
1119-
const tab = this.tabs[index];
1121+
const tab = this.getTabById(domain.id);
11201122
if (tab instanceof ServerTab)
11211123
tab.setIcon(DomainUtil.iconAsUrl(localIconPath));
11221124
domain.icon = localIconPath;

0 commit comments

Comments
 (0)