@the-portland-company/shell 0.76.8 → 0.76.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  import { broadcastLogout, watchLogout } from './chunk-LL6LSJAH.js';
3
- import { clearBetaBannerDismissal, standardPolitogyNav, standardNavIcons, isNavItemActive, NavAppShell, NavChromeProvider, TopBarWidgetSlot, FuelAction, SpecOverlayAction, NotificationsAction, SupportAction, useChromeMe, useThemePreference, useNavChromeDedupedFetch, useChromeOrgs, useNavChromeFetcher } from './chunk-RBJGWQJX.js';
4
- export { standardNavIcons } from './chunk-RBJGWQJX.js';
3
+ import { clearBetaBannerDismissal, standardPolitogyNav, standardNavIcons, isNavItemActive, NavAppShell, NavChromeProvider, TopBarWidgetSlot, FuelAction, SpecOverlayAction, NotificationsAction, SupportAction, useChromeMe, useThemePreference, useNavChromeDedupedFetch, useChromeOrgs, useNavChromeFetcher } from './chunk-ZWGCO2EP.js';
4
+ export { standardNavIcons } from './chunk-ZWGCO2EP.js';
5
5
  import { warnDeprecated } from './chunk-MY6G3LMN.js';
6
6
  import './chunk-BHRVZPZ7.js';
7
7
  import { NAV_DISPLAY_DEFAULT, resolveNavDisplay, writeNavDisplayLocal, writeNavDisplayCookie, isNavDisplayPreference, NAV_DISPLAY_STORAGE_KEY, readNavDisplayCookie } from './chunk-7YVJ7HQG.js';
8
- import { readOrgSelectorFromUrl, matchOrgSelector, isOrgId, switchActiveOrg, ACTIVE_ORG_QUERY_PARAM, ORG_ID_QUERY_PARAM, orgIdTail, writeActiveOrgCookie, resolveActiveOrg, readActiveOrgCookie } from './chunk-BWV52AT6.js';
8
+ import { readOrgSelectorFromUrl, matchOrgSelector, isOrgId, switchActiveOrg, ACTIVE_ORG_QUERY_PARAM, ORG_ID_QUERY_PARAM, orgIdTail, syncOrgIdInUrl, writeActiveOrgCookie, resolveActiveOrg, readActiveOrgCookie } from './chunk-FBUF7LUE.js';
9
9
  import { createContext, useMemo, useRef, useEffect, useState, useCallback, useContext } from 'react';
10
10
  import { DevNotesMenu, createDevNotesClient, DevNotesProvider, DevNotesTaskListModal, DevNotesOverlay } from '@the-portland-company/devnotes';
11
11
  import { LuNotebookPen, LuContactRound, LuMegaphone, LuFilePenLine } from 'react-icons/lu';
@@ -911,9 +911,15 @@ function TokenChromeStateProvider({
911
911
  })),
912
912
  [tokenOrg.orgs, fetchedOrgs]
913
913
  );
914
- const [urlSelector] = useState(
914
+ const [urlSelector, setUrlSelector] = useState(
915
915
  () => typeof window === "undefined" ? null : readOrgSelectorFromUrl(window.location.search)
916
916
  );
917
+ useEffect(() => {
918
+ if (typeof window === "undefined") return;
919
+ const onLocationChange = () => setUrlSelector(readOrgSelectorFromUrl(window.location.search));
920
+ window.addEventListener("popstate", onLocationChange);
921
+ return () => window.removeEventListener("popstate", onLocationChange);
922
+ }, []);
917
923
  const overrideOrg = useMemo(
918
924
  () => urlSelector ? matchOrgSelector(urlSelector, orgs)?.id ?? null : null,
919
925
  [urlSelector, orgs]
@@ -939,6 +945,7 @@ function TokenChromeStateProvider({
939
945
  void (async () => {
940
946
  try {
941
947
  const claims = await switchActiveOrg(id, { authBaseUrl: current.authBaseUrl });
948
+ setUrlSelector(null);
942
949
  try {
943
950
  const url = new URL(window.location.href);
944
951
  url.searchParams.delete(ACTIVE_ORG_QUERY_PARAM);
@@ -959,15 +966,9 @@ function TokenChromeStateProvider({
959
966
  writeNavDisplayCookie(m);
960
967
  }, []);
961
968
  useEffect(() => {
962
- if (!isOrgId(orgId)) return;
963
969
  try {
964
- const url = new URL(window.location.href);
965
- const tail = orgIdTail(orgId);
966
- if (url.searchParams.has(ACTIVE_ORG_QUERY_PARAM) || url.searchParams.get(ORG_ID_QUERY_PARAM) !== tail) {
967
- url.searchParams.delete(ACTIVE_ORG_QUERY_PARAM);
968
- url.searchParams.set(ORG_ID_QUERY_PARAM, tail);
969
- window.history.replaceState(window.history.state, "", url.toString());
970
- }
970
+ const next = syncOrgIdInUrl(window.location.href, orgId);
971
+ if (next) window.history.replaceState(window.history.state, "", next);
971
972
  } catch {
972
973
  }
973
974
  }, [orgId]);