@hanzo/app 0.2.60 → 0.2.61

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.
package/dist/Orgs.js CHANGED
@@ -44,7 +44,7 @@ import { useHost } from './lib/hostname.js';
44
44
  import { useHydrated } from './lib/hydrated.js';
45
45
  import { api } from './lib/api.js';
46
46
  import { usePersonal, useTier } from './lib/tier.js';
47
- import { CHOOSE, ORG, PICKED, assumed, bearer, hasSession, org, orgs as claimed, pick, renew, role, scope, superAdmin, support } from './lib/session.js';
47
+ import { CHOOSE, ORG, assumed, bearer, hasSession, org, orgs as claimed, pick, renew, role, scope, superAdmin, support } from './lib/session.js';
48
48
  import { matches, refusal, slugify } from './lib/orgname.js';
49
49
  import { team as workspace } from './lib/host.js';
50
50
  import { checkoutUrl, money } from './lib/pay.js';
@@ -86,7 +86,6 @@ export function Orgs({ children, front = false, forward, signup = false, }) {
86
86
  window.removeEventListener('storage', on);
87
87
  };
88
88
  }, [accessToken]);
89
- const [picked, setPicked] = useState(false);
90
89
  // The team being set up in this page. Once its name is taken the setup owns
91
90
  // the screen until checkout, whatever `Orgs` reads of the new organization.
92
91
  const [founding, setFounding] = useState(null);
@@ -107,14 +106,6 @@ export function Orgs({ children, front = false, forward, signup = false, }) {
107
106
  const supporting = Boolean(current) && assumed() === current;
108
107
  const open = !asks || live || supporting;
109
108
  const { client } = useAi();
110
- useEffect(() => {
111
- try {
112
- setPicked(Boolean(localStorage.getItem(PICKED)));
113
- }
114
- catch {
115
- setPicked(true);
116
- }
117
- }, [accessToken]);
118
109
  // Back from checkout: the plan may be live now.
119
110
  useEffect(() => {
120
111
  const back = () => {
@@ -137,7 +128,6 @@ export function Orgs({ children, front = false, forward, signup = false, }) {
137
128
  }, []);
138
129
  const choose = useCallback((o) => {
139
130
  pick(o);
140
- setPicked(true);
141
131
  setChoosing(false);
142
132
  }, []);
143
133
  // The organization a link arrives for. hanzo.ai opens the workspace at
@@ -156,11 +146,6 @@ export function Orgs({ children, front = false, forward, signup = false, }) {
156
146
  if (members.includes(asked))
157
147
  choose(asked);
158
148
  }, [door, hydrated, isLoading, isAuthenticated, members, choose]);
159
- // One organization is not a choice.
160
- useEffect(() => {
161
- if (members.length === 1 && !picked)
162
- choose(members[0]);
163
- }, [members, picked, choose]);
164
149
  // The template chosen at creation, set up once the organization opens.
165
150
  useEffect(() => {
166
151
  if (!open || !client)
@@ -214,11 +199,17 @@ export function Orgs({ children, front = false, forward, signup = false, }) {
214
199
  return _jsx(Landing, { member: true });
215
200
  return door ? _jsx(Start, { onFounded: setFounding, first: true }) : _jsx(Create, {});
216
201
  }
217
- if (!current || (members.length > 1 && !picked))
202
+ // The organization this browser works in is the choice (session.ts `org`: the
203
+ // SDK's selection when the token names it, else the person's only one). Only a
204
+ // browser working in none of the person's is asked, so a sign-in goes straight
205
+ // to the room in the organization the person last worked in, and the account
206
+ // menu switches it (`choosing`).
207
+ if (!current)
218
208
  return _jsx(Pick, { members: members, current: current, onPick: choose });
219
- // Asked for over an open room, the room keeps its place under the chooser and closing it goes back.
209
+ // Asked for over an open room, the room keeps its place under the chooser and closing it goes back;
210
+ // asked for from a plan's page (`swap`), the chooser stands alone, since that room is not open.
220
211
  if (choosing)
221
- return _jsxs(_Fragment, { children: [_jsx(Held, { veiled: true, children: children }), _jsx(Pick, { members: members, current: current, onPick: choose, onClose: () => setChoosing(false) })] });
212
+ return _jsxs(_Fragment, { children: [open ? _jsx(Held, { veiled: true, children: children }) : null, _jsx(Pick, { members: members, current: current, onPick: choose, onClose: () => setChoosing(false) })] });
222
213
  if (open)
223
214
  return forward ? _jsx(Forward, { to: forward }) : _jsx(_Fragment, { children: _jsx(Held, { veiled: false, children: children }) });
224
215
  // IN THE WORKSPACE NOTHING OPENS WITHOUT A LIVE PLAN. Every branch here
@@ -231,7 +222,7 @@ export function Orgs({ children, front = false, forward, signup = false, }) {
231
222
  return _jsxs(_Fragment, { children: [_jsx(Held, { veiled: true, children: children }), _jsx(Veil, {})] });
232
223
  if (free && personal === null)
233
224
  return _jsxs(_Fragment, { children: [_jsx(Held, { veiled: true, children: children }), _jsx(Veil, {})] });
234
- const swap = () => setPicked(false);
225
+ const swap = () => setChoosing(true);
235
226
  if (door) {
236
227
  // A billing OUTAGE is ours; the plan is still the condition.
237
228
  if (!tier)
@@ -450,7 +441,6 @@ function CreateDialog({ onClose }) {
450
441
  try {
451
442
  if (template)
452
443
  localStorage.setItem(SETUP, template);
453
- localStorage.setItem(PICKED, '1');
454
444
  }
455
445
  catch {
456
446
  /* the next load re-derives both */
@@ -182,12 +182,10 @@ export declare function scope(): Record<string, string>;
182
182
  export declare function renew(): void;
183
183
  /** Fired on `window` when the organization this browser works in changes. */
184
184
  export declare const ORG = "hanzo:org";
185
- /** This person picked an organization in this browser. `own()` clears it with the person. */
186
- export declare const PICKED = "hanzo:org:picked";
187
185
  /**
188
- * Work in this organization from now on: the SDK's selection, noted as picked
189
- * and announced. Noted here, so a choice made anywhere — the rooms' gate, the
190
- * app's account menu — is one the gate does not ask for again.
186
+ * Work in this organization from now on: the SDK's selection, announced. A choice
187
+ * made anywhere (the shell's gate, the app's account menu) is the one `org()`
188
+ * answers, so the gate does not ask for it again.
191
189
  */
192
190
  export declare function pick(o: string): void;
193
191
  /** Fired on `window` to open the organization chooser over the room. */
@@ -453,17 +453,14 @@ export function renew() {
453
453
  }
454
454
  /** Fired on `window` when the organization this browser works in changes. */
455
455
  export const ORG = 'hanzo:org';
456
- /** This person picked an organization in this browser. `own()` clears it with the person. */
457
- export const PICKED = 'hanzo:org:picked';
458
456
  /**
459
- * Work in this organization from now on: the SDK's selection, noted as picked
460
- * and announced. Noted here, so a choice made anywhere — the rooms' gate, the
461
- * app's account menu — is one the gate does not ask for again.
457
+ * Work in this organization from now on: the SDK's selection, announced. A choice
458
+ * made anywhere (the shell's gate, the app's account menu) is the one `org()`
459
+ * answers, so the gate does not ask for it again.
462
460
  */
463
461
  export function pick(o) {
464
462
  try {
465
463
  window.localStorage.setItem(`${PREFIX}current_org`, o);
466
- window.localStorage.setItem(PICKED, '1');
467
464
  }
468
465
  catch {
469
466
  /* the choice lives only in this page */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/app",
3
- "version": "0.2.60",
3
+ "version": "0.2.61",
4
4
  "description": "Hanzo's app: the shell and its apps (Home, Chat, Inbox, Contacts, Meet, Calendar, Drive, Board, Work, Bots), once, for every Hanzo surface.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",