@the-portland-company/shell 0.43.0 → 0.43.1

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.
@@ -3156,10 +3156,14 @@ function ChromeStateProvider({
3156
3156
  orgReconciled.current = true;
3157
3157
  return;
3158
3158
  }
3159
- if (memberOrgsRef.current.length === 0) return;
3159
+ if (!orgs && !orgsError) return;
3160
3160
  orgReconciled.current = true;
3161
- applyExternalOrg(pref ?? null);
3162
- }, [chromeMe.me, orgs, controlledOrg, applyExternalOrg]);
3161
+ const members = [...orgs ?? [], ...controlledOrg?.orgs ?? []];
3162
+ if (!members.some((o) => o.id === pref)) return;
3163
+ const controlled = controlledOrgRef.current;
3164
+ if (controlled) (controlled.onExternalSwitch ?? controlled.onSwitch)(pref);
3165
+ else setOrgIdState(pref);
3166
+ }, [chromeMe.me, orgs, orgsError, controlledOrg]);
3163
3167
  const setOrgId = react.useCallback((id) => {
3164
3168
  setOrgIdState(id);
3165
3169
  try {
@@ -3238,7 +3242,7 @@ function ChromeStateProvider({
3238
3242
  } catch {
3239
3243
  }
3240
3244
  const known = chromeMe.me?.activeOrg ?? null;
3241
- if (chromeMe.me && activeOrgId !== known && activeOrgId !== lastPatchedOrg.current) {
3245
+ if (orgReconciled.current && chromeMe.me && activeOrgId !== known && activeOrgId !== lastPatchedOrg.current) {
3242
3246
  lastPatchedOrg.current = activeOrgId;
3243
3247
  chromeFetch?.("me/preferences", {
3244
3248
  method: "PATCH",