Skip to content

Commit f194e7c

Browse files
committed
temp: Replace index with order.
1 parent 8f36750 commit f194e7c

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

app/common/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ export type TabData = {
2929
role: TabRole;
3030
page?: TabPage;
3131
label: string;
32-
index: number;
32+
order: number;
3333
id: string;
3434
};

app/main/menu.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ function getWindowSubmenu(
323323
initialSubmenu.push({
324324
label: tab.label,
325325
accelerator:
326-
tab.role === "function" ? "" : `${shortcutKey} + ${tab.index + 1}`,
326+
tab.role === "function" ? "" : `${shortcutKey} + ${tab.order + 1}`,
327327
checked: tab.id === activeTabId,
328328
click(_item, focusedWindow) {
329329
if (focusedWindow) {
@@ -700,27 +700,27 @@ async function checkForUpdate(): Promise<void> {
700700
}
701701

702702
function getTabByOrder(tabs: TabData[], order: number): TabData | undefined {
703-
return tabs.find((tab) => tab.index === order);
703+
return tabs.find((tab) => tab.order === order);
704704
}
705705

706706
function getNextServer(tabs: TabData[], activeTabId: string): string {
707707
const activeTab = tabs.find((tab) => tab.id === activeTabId)!;
708-
let {index} = activeTab;
708+
let {order} = activeTab;
709709
do {
710-
index = (index + 1) % tabs.length;
711-
} while (getTabByOrder(tabs, index)?.role !== "server");
710+
order = (order + 1) % tabs.length;
711+
} while (getTabByOrder(tabs, order)?.role !== "server");
712712

713-
return getTabByOrder(tabs, index)!.id;
713+
return getTabByOrder(tabs, order)!.id;
714714
}
715715

716716
function getPreviousServer(tabs: TabData[], activeTabId: string): string {
717717
const activeTab = tabs.find((tab) => tab.id === activeTabId)!;
718-
let {index} = activeTab;
718+
let {order} = activeTab;
719719
do {
720-
index = (index - 1) % tabs.length;
721-
} while (getTabByOrder(tabs, index)?.role !== "server");
720+
order = (order - 1) % tabs.length;
721+
} while (getTabByOrder(tabs, order)?.role !== "server");
722722

723-
return getTabByOrder(tabs, index)!.id;
723+
return getTabByOrder(tabs, order)!.id;
724724
}
725725

726726
export function setMenu(properties: MenuProperties): void {

app/renderer/js/components/server-tab.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ export default class ServerTab extends Tab {
7777

7878
generateShortcutText(): string {
7979
// Only provide shortcuts for server [0..9]
80-
if (this.properties.index >= 9) {
80+
if (this.properties.order >= 9) {
8181
return "";
8282
}
8383

84-
const shownIndex = this.properties.index + 1;
84+
const shownIndex = this.properties.order + 1;
8585

86-
// Array index == Shown index - 1
86+
// Array order == Shown order - 1
8787
ipcRenderer.send("switch-server-tab", this.properties.tabId);
8888

8989
return process.platform === "darwin"

app/renderer/js/components/tab.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export type TabProperties = {
77
label: string;
88
$root: Element;
99
onClick: () => void;
10-
index: number;
10+
order: number;
1111
tabId: string;
1212
onHover?: () => void;
1313
onHoverOut?: () => void;

app/renderer/js/main.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ export class ServerManagerView {
339339
firstTab.properties.tabId,
340340
)!;
341341
let lastActiveTab = this.getTabById(lastActiveTabId)!;
342-
if (lastActiveTab.properties.index >= servers.length) {
342+
if (lastActiveTab.properties.order >= servers.length) {
343343
lastActiveTab = firstTab;
344344
}
345345

@@ -367,15 +367,15 @@ export class ServerManagerView {
367367
}
368368
}
369369

370-
initServer(server: ServerConfig, index: number): ServerTab {
370+
initServer(server: ServerConfig, order: number): ServerTab {
371371
const tabId = server.id;
372372
const tab: ServerTab = new ServerTab({
373373
role: "server",
374374
icon: DomainUtil.iconAsUrl(server.icon),
375375
label: server.alias,
376376
$root: this.$tabsContainer,
377377
onClick: this.activateLastTab.bind(this, tabId),
378-
index,
378+
order,
379379
tabId,
380380
onHover: this.onHover.bind(this, tabId),
381381
onHoverOut: this.onHoverOut.bind(this, tabId),
@@ -555,7 +555,7 @@ export class ServerManagerView {
555555
return;
556556
}
557557

558-
const index = this.tabs.length;
558+
const order = this.tabs.length;
559559
const tabId = this.generateTabId();
560560
this.functionalTabs.set(tabProperties.page, tabId);
561561
const $view = await tabProperties.makeView();
@@ -568,7 +568,7 @@ export class ServerManagerView {
568568
label: tabProperties.label,
569569
page: tabProperties.page,
570570
$root: this.$tabsContainer,
571-
index,
571+
order,
572572
tabId,
573573
onClick: this.activateTab.bind(this, tabId),
574574
onDestroy: async () => {
@@ -651,7 +651,7 @@ export class ServerManagerView {
651651
role: tab.properties.role,
652652
page: tab.properties.page,
653653
label: tab.properties.label,
654-
index: tab.properties.index,
654+
order: tab.properties.order,
655655
id: tab.properties.tabId,
656656
}));
657657
}
@@ -660,7 +660,7 @@ export class ServerManagerView {
660660
tabs: ServerOrFunctionalTab[],
661661
order: number,
662662
): ServerOrFunctionalTab | undefined {
663-
return tabs.find((tab) => tab.properties.index === order);
663+
return tabs.find((tab) => tab.properties.order === order);
664664
}
665665

666666
async activateTab(id: string, hideOldTab = true): Promise<void> {

0 commit comments

Comments
 (0)