@shipfox/client-invitations 3.0.1 → 4.0.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shipfox/client-invitations",
3
3
  "license": "MIT",
4
- "version": "3.0.1",
4
+ "version": "4.0.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/ShipfoxHQ/shipfox.git",
@@ -31,11 +31,12 @@
31
31
  "dependencies": {
32
32
  "@swc/helpers": "^0.5.17",
33
33
  "@tanstack/react-query": "^5.101.0",
34
- "@shipfox/api-auth-dto": "6.0.0",
35
34
  "@shipfox/api-workspaces-dto": "6.0.0",
36
- "@shipfox/client-api": "1.0.0",
37
- "@shipfox/client-auth": "3.0.1",
38
- "@shipfox/client-shell": "3.0.1",
35
+ "@shipfox/client-api": "4.0.0",
36
+ "@shipfox/api-auth-dto": "7.1.0",
37
+ "@shipfox/client-shell": "4.0.0",
38
+ "@shipfox/client-auth": "4.0.0",
39
+ "@shipfox/client-ui": "4.0.0",
39
40
  "@shipfox/react-ui": "0.3.5"
40
41
  },
41
42
  "peerDependencies": {
@@ -44,25 +45,6 @@
44
45
  "react": "^19.0.0",
45
46
  "react-dom": "^19.0.0"
46
47
  },
47
- "devDependencies": {
48
- "@tanstack/react-query": "^5.101.0",
49
- "@tanstack/react-router": "^1.170.16",
50
- "@testing-library/jest-dom": "^6.6.3",
51
- "@testing-library/react": "^16.3.2",
52
- "@testing-library/user-event": "^14.6.1",
53
- "@types/react": "^19.1.11",
54
- "@types/react-dom": "^19.1.7",
55
- "jsdom": "^29.0.0",
56
- "react": "^19.1.1",
57
- "react-dom": "^19.1.1",
58
- "@shipfox/biome": "1.8.2",
59
- "@shipfox/client-test-setup": "0.0.3",
60
- "@shipfox/swc": "1.2.6",
61
- "@shipfox/ts-config": "1.3.8",
62
- "@shipfox/typescript": "1.1.7",
63
- "@shipfox/vite": "1.2.5",
64
- "@shipfox/vitest": "1.2.3"
65
- },
66
48
  "scripts": {
67
49
  "build": "shipfox-swc",
68
50
  "check": "shipfox-biome-check",
@@ -1,4 +1,5 @@
1
1
  import {AuthShell, useAuthState, useRefreshAuth} from '@shipfox/client-auth';
2
+ import {createSingleFlight} from '@shipfox/client-ui';
2
3
  import {Button} from '@shipfox/react-ui/button';
3
4
  import {Callout} from '@shipfox/react-ui/callout';
4
5
  import {ShipfoxLoader} from '@shipfox/react-ui/loader';
@@ -11,9 +12,7 @@ import {completeInvitationAcceptance} from '#complete-acceptance.js';
11
12
  import {useAcceptInvitation} from '#hooks/api/accept-invitation.js';
12
13
  import {usePreviewInvitation} from '#hooks/api/preview-invitation.js';
13
14
 
14
- // Module-scoped guard so React StrictMode's double-mount in dev does not
15
- // fire the accept mutation twice for the same token.
16
- const inFlightAccepts = new Set<string>();
15
+ const invitationAccepts = createSingleFlight<string, void>();
17
16
  const toastedTerminals = new Set<string>();
18
17
  const TOASTED_TERMINALS_MAX = 32;
19
18
 
@@ -65,7 +64,6 @@ export function InvitationAcceptPage() {
65
64
  if (!token) return;
66
65
  if (auth.isLoading) return;
67
66
  if (hasKickedAccept.current) return;
68
- if (inFlightAccepts.has(token)) return;
69
67
  const data = preview.data;
70
68
  if (!data) return;
71
69
  if (data.status !== 'pending') return;
@@ -75,15 +73,11 @@ export function InvitationAcceptPage() {
75
73
  if (authedEmail !== data.email.toLowerCase()) return;
76
74
 
77
75
  hasKickedAccept.current = true;
78
- inFlightAccepts.add(token);
79
-
80
- runAccept({token, workspaceName: data.workspace_name})
76
+ invitationAccepts
77
+ .run(token, async () => await runAccept({token, workspaceName: data.workspace_name}))
81
78
  .catch(() => {
82
79
  // The mutation surfaces its error via accept.error; the UI re-renders
83
80
  // into the auth-match-error state below.
84
- })
85
- .finally(() => {
86
- inFlightAccepts.delete(token);
87
81
  });
88
82
  }, [auth.isAuthenticated, auth.isLoading, auth.user?.email, preview.data, runAccept, token]);
89
83