Files
OmniRoute/src/shared/utils/sidebarExpansionState.ts
Jan Leon c711ed257b Restore proxy navigation and sidebar accordion state (#7381)
* fix(sidebar): restore proxy navigation and accordion state

* fix(proxy): prevent free pool translation crash

* fix(settings): guard protected sidebar items and hydration state

* test(sidebar): cover proxy visibility and expansion state

* chore: restart pull request checks

* refactor(sidebar): extract group item visibility control

* refactor(sidebar): move group visibility control to module scope

* fix(sidebar): preserve collapsed state on initial load

* fix(proxy): collect free pool UI regression test

* chore(test): unfreeze free-pool-tab.test.tsx from test-discovery baseline

The move to tests/unit/ui/free-pool-tab.test.tsx (this branch) relinks
it to the test:vitest:ui runner, so the tests/unit/free-pool-tab.test.tsx
entry in the frozen orphan baseline is now stale and fails
check:test-discovery. Removes the stale entry (60 -> 59 known orphans).

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

---------

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
2026-07-18 15:13:19 -03:00

30 lines
810 B
TypeScript

import type { SidebarSectionId } from "@/shared/constants/sidebarVisibility";
export function hydrateExpandedSections(
storedExpanded: readonly SidebarSectionId[],
pinned: ReadonlySet<SidebarSectionId>
): Set<SidebarSectionId> {
return new Set([...storedExpanded, ...pinned]);
}
export function toggleExpandedSection(
expanded: ReadonlySet<SidebarSectionId>,
pinned: ReadonlySet<SidebarSectionId>,
sectionId: SidebarSectionId
): Set<SidebarSectionId> {
if (expanded.has(sectionId)) {
const next = new Set(expanded);
next.delete(sectionId);
return next;
}
return new Set([...pinned, sectionId]);
}
export function expandActiveSection(
pinned: ReadonlySet<SidebarSectionId>,
sectionId: SidebarSectionId
): Set<SidebarSectionId> {
return new Set([...pinned, sectionId]);
}