Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/app/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async function openUrlInWindow(useNewWindow: boolean, url: string) {

// Create a new tab with the URL
const tab = await tabsController.createTab(window.id, undefined, undefined, undefined, { url });
tabsController.setActiveTab(tab);
tabsController.activateTab(tab);
}

/**
Expand Down
52 changes: 17 additions & 35 deletions src/main/controllers/app-menu-controller/menu/items/spaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ async function createSpaceMenuItem(
* Creates the Spaces menu for the application
*/
export async function createSpacesMenu(): Promise<MenuItemConstructorOptions> {
const manageSpacesItem = {
label: "Manage Spaces",
click: () => settings.show()
};
const noSpacesMenu = {
label: "Spaces",
submenu: [manageSpacesItem]
};

try {
const [spaces, areProfilesInternal] = await Promise.all([
spacesController.getAll(),
Expand All @@ -156,30 +165,18 @@ export async function createSpacesMenu(): Promise<MenuItemConstructorOptions> {

const focusedWindow = windowsController.getFocused();
if (!focusedWindow || !browserWindowsManager.isInstanceOf(focusedWindow)) {
return {
label: "Spaces",
submenu: [
{
label: "Manage Spaces",
click: () => settings.show()
}
]
};
return noSpacesMenu;
}

if (focusedWindow.browserWindowType === "popup") {
return noSpacesMenu;
}

const currentSpaceId = focusedWindow.currentSpaceId;
if (currentSpaceId) {
const currentSpace = spaces.find((space) => space.id === currentSpaceId);
if (currentSpace && areProfilesInternal[currentSpace.profileId]) {
return {
label: "Spaces",
submenu: [
{
label: "Manage Spaces",
click: () => settings.show()
}
]
};
return noSpacesMenu;
}
}

Expand All @@ -196,26 +193,11 @@ export async function createSpacesMenu(): Promise<MenuItemConstructorOptions> {

return {
label: "Spaces",
submenu: [
...spaceMenuItems,
{ type: "separator" },
{
label: "Manage Spaces",
click: () => settings.show()
}
]
submenu: [...spaceMenuItems, { type: "separator" }, manageSpacesItem]
};
} catch (error) {
console.error("Failed to create spaces menu:", error);
// Provide a fallback menu if the spaces menu creation fails
return {
label: "Spaces",
submenu: [
{
label: "Manage Spaces",
click: () => settings.show()
}
]
};
return noSpacesMenu;
}
}
6 changes: 3 additions & 3 deletions src/main/controllers/loaded-profiles-controller/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class LoadedProfilesController extends TypedEventEmitter<LoadedProfilesControlle
url: tabDetails.url
});
if (tabDetails.active) {
tabsController.setActiveTab(tab);
tabsController.activateTab(tab);
}

const electronWindow = tab.getWindow().browserWindow;
Expand All @@ -160,7 +160,7 @@ class LoadedProfilesController extends TypedEventEmitter<LoadedProfilesControlle
setWindowSpace(window, tab.spaceId);

// Set the active tab
tabsController.setActiveTab(tab);
tabsController.activateTab(tab);
},
removeTab: (tabWebContents) => {
const tab = tabsController.getTabByWebContents(tabWebContents);
Expand Down Expand Up @@ -188,7 +188,7 @@ class LoadedProfilesController extends TypedEventEmitter<LoadedProfilesControlle

tabsController.createTab(window.id, profileId, undefined, undefined, { url }).then((tab) => {
if (currentTabIndex === 0) {
tabsController.setActiveTab(tab);
tabsController.activateTab(tab);
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/main/controllers/tabs-controller/context-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function createTabContextMenu(
undefined,
{ url }
);
tabsController.setActiveTab(sourceTab);
tabsController.activateTab(sourceTab);
};

// Create all menu sections
Expand Down
Loading
Loading