api-client/packages/hoppscotch-common/src/helpers/rest/tabRenderCache.ts

23 lines
520 B
TypeScript
Raw Normal View History

2026-05-06 08:23:39 +00:00
type UpdateRenderedRESTTabIDsOptions = {
renderedTabIDs: string[]
activeTabID: string
activeTabIDs: string[]
maxRenderedTabs: number
}
export function updateRenderedRESTTabIDs({
renderedTabIDs,
activeTabID,
activeTabIDs,
maxRenderedTabs,
}: UpdateRenderedRESTTabIDsOptions) {
const activeTabIDSet = new Set(activeTabIDs)
return [
activeTabID,
...renderedTabIDs.filter((tabID) => tabID !== activeTabID),
]
.filter((tabID) => activeTabIDSet.has(tabID))
.slice(0, maxRenderedTabs)
}