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
1 change: 1 addition & 0 deletions figura/tsapi.fig
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ struct BrowserTab {
service BrowserExtension {
fn getTabs() => BrowserTab[];
fn focusTab(browserId: string, tabId: int) => void;
fn closeTab(browserId: string, tabId: int) => void;
};

// EventCore - used for loosely typed callbacks, required for component event handlers
Expand Down
2 changes: 1 addition & 1 deletion src/server/src/actions/browser-tab-actions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct BrowserTabActionGenerator {
ctx->services->toastService()->failure(tr("Failed to close tab: %1").arg(result.error().c_str()));
return;
}
ctx->navigation->closeWindow({.clearRootSearch = true});
// Keep window open: root search refreshes via tabsChanged, built-in view reloads on the same signal.
});
closeTab->setShortcut(Keybind::RemoveAction);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class ExtBrowserExtensionService : public tsapi::AbstractBrowserExtension {
return Void::ok();
}

tsapi::Result<void>::Future closeTab(std::string browserId, int32_t tabId) override {
m_browser.closeTab(browserId, tabId);
return Void::ok();
}

private:
BrowserExtensionService &m_browser;
};
12 changes: 12 additions & 0 deletions src/typescript/api/src/api/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export namespace BrowserExtension {
title?: string;
url: string;
active: boolean;
browserId: string;
focus: () => void;
close: () => void;
};

export async function getTabs(): Promise<Tab[]> {
Expand All @@ -20,7 +22,17 @@ export namespace BrowserExtension {
focus: () => {
getClient().BrowserExtension.focusTab(b.browserId, b.id);
},
close: () => {
getClient().BrowserExtension.closeTab(b.browserId, b.id);
},
})),
);
}

export async function closeTab(
browserId: string,
tabId: number,
): Promise<void> {
return getClient().BrowserExtension.closeTab(browserId, tabId);
}
}
4 changes: 4 additions & 0 deletions src/typescript/api/src/api/proto/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,10 @@ class BrowserExtensionService {
return this.transport.request("BrowserExtension/focusTab", { browserId, tabId});
}

closeTab(browserId: string, tabId: number): Promise<void> {
return this.transport.request("BrowserExtension/closeTab", { browserId, tabId});
}

}

class EventCoreService {
Expand Down
Loading