Skip to content

Commit faa6ec6

Browse files
committed
chore(dashboard): remove all JWT generation timeouts
1 parent d2139f4 commit faa6ec6

File tree

8 files changed

+38
-72
lines changed

8 files changed

+38
-72
lines changed

packages/apps/app-dashboard/src/components/user-dashboard/connect/ConnectPage.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,16 @@ export function ConnectPage({
6868
useEffect(() => {
6969
if (redirectUrl && !localSuccess) {
7070
setLocalSuccess('Success! Redirecting to app...');
71-
setTimeout(() => {
72-
executeRedirect();
73-
}, 2000);
71+
executeRedirect();
7472
}
7573
}, [redirectUrl, localSuccess, executeRedirect]);
7674

7775
// Generate JWT when agentPKP is set and permissions are granted
7876
useEffect(() => {
7977
if (agentPKP && localSuccess === 'Permissions granted successfully!') {
80-
const timer = setTimeout(async () => {
81-
setLocalSuccess(null);
82-
await generateJWT(connectInfoMap.app, connectInfoMap.app.activeVersion!);
83-
}, 1000);
84-
return () => clearTimeout(timer);
78+
setLocalSuccess(null);
79+
generateJWT(connectInfoMap.app, connectInfoMap.app.activeVersion!);
8580
}
86-
return undefined;
8781
}, [agentPKP, localSuccess, generateJWT, connectInfoMap.app]);
8882

8983
const handleSubmit = useCallback(async () => {

packages/apps/app-dashboard/src/components/user-dashboard/connect/EditPermissionsCard.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ export function EditPermissionsCard({
5858
useEffect(() => {
5959
if (redirectUrl && !localSuccess) {
6060
setLocalSuccess('Success! Redirecting to app...');
61-
setTimeout(() => {
62-
executeRedirect();
63-
}, 2000);
61+
executeRedirect();
6462
}
6563
}, [redirectUrl, localSuccess, executeRedirect]);
6664

packages/apps/app-dashboard/src/components/user-dashboard/connect/RepermitConnect.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,15 @@ export function RepermitConnect({
4545
useEffect(() => {
4646
if (redirectUrl && localSuccess !== 'Success! Redirecting to app...') {
4747
setLocalSuccess('Success! Redirecting to app...');
48-
setTimeout(() => {
49-
executeRedirect();
50-
}, 2000);
48+
executeRedirect();
5149
}
5250
}, [redirectUrl, localSuccess, executeRedirect]);
5351

5452
// Generate JWT when re-permitting is successful
5553
useEffect(() => {
5654
if (localSuccess === 'App re-permitted successfully!') {
57-
const timer = setTimeout(async () => {
58-
await generateJWT(appData, appData.activeVersion!);
59-
}, 1000);
60-
return () => clearTimeout(timer);
55+
generateJWT(appData, appData.activeVersion!);
6156
}
62-
return undefined;
6357
}, [localSuccess, generateJWT, appData]);
6458

6559
const handleSubmit = useCallback(async () => {

packages/apps/app-dashboard/src/components/user-dashboard/connect/ReturningUserConnect.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ export function ReturningUserConnect({
4747
useEffect(() => {
4848
if (redirectUrl && !localSuccess) {
4949
setLocalSuccess('Success! Redirecting to app...');
50-
setTimeout(() => {
51-
executeRedirect();
52-
}, 2000);
50+
executeRedirect();
5351
}
5452
}, [redirectUrl, localSuccess, executeRedirect]);
5553

packages/apps/app-dashboard/src/components/user-dashboard/connect/UpdateVersionCard.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ export function UpdateVersionCard({
5757
useEffect(() => {
5858
if (redirectUrl && !localSuccess) {
5959
setLocalSuccess('Success! Redirecting to app...');
60-
setTimeout(() => {
61-
executeRedirect();
62-
}, 2000);
60+
executeRedirect();
6361
}
6462
}, [redirectUrl, localSuccess, executeRedirect]);
6563

packages/apps/app-dashboard/src/components/user-dashboard/dashboard/RepermitConnectPage.tsx

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ export function RepermitConnectPage({
5656
useEffect(() => {
5757
if (redirectUrl && !localSuccess) {
5858
setLocalSuccess('Success! Redirecting to app...');
59-
setTimeout(() => {
60-
executeRedirect();
61-
}, 2000);
59+
executeRedirect();
6260
}
6361
}, [redirectUrl, localSuccess, executeRedirect]);
6462

@@ -94,17 +92,15 @@ export function RepermitConnectPage({
9492
setIsConnectProcessing(false);
9593
setLocalSuccess('App re-permitted successfully!');
9694

97-
// Generate JWT for redirect after short delay
98-
setTimeout(async () => {
99-
setLocalSuccess(null);
100-
// Only generate JWT if there's an effectiveRedirectUri (for app redirects)
101-
if (effectiveRedirectUri) {
102-
await generateJWT(appData, appData.activeVersion!);
103-
} else {
104-
// Navigate to the app permissions page with full refresh to update sidebar
105-
window.location.href = `/user/appId/${appData.appId}`;
106-
}
107-
}, 3000);
95+
// Generate JWT for redirect or navigate
96+
setLocalSuccess(null);
97+
// Only generate JWT if there's an effectiveRedirectUri (for app redirects)
98+
if (effectiveRedirectUri) {
99+
await generateJWT(appData, appData.activeVersion!);
100+
} else {
101+
// Navigate to the app permissions page with full refresh to update sidebar
102+
window.location.href = `/user/appId/${appData.appId}`;
103+
}
108104
} catch (error) {
109105
setLocalError(error instanceof Error ? error.message : 'Failed to re-permit app');
110106
setIsConnectProcessing(false);

packages/apps/app-dashboard/src/components/user-dashboard/dashboard/UpdateVersionPage.tsx

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ export function UpdateVersionPage({
5454
useEffect(() => {
5555
if (redirectUrl && !localSuccess) {
5656
setLocalSuccess('Success! Redirecting to app...');
57-
setTimeout(() => {
58-
executeRedirect();
59-
}, 2000);
57+
executeRedirect();
6058
}
6159
}, [redirectUrl, localSuccess, executeRedirect]);
6260

@@ -120,18 +118,16 @@ export function UpdateVersionPage({
120118
});
121119

122120
setLocalStatus(null);
123-
// Show success state for 3 seconds, then redirect or reload
121+
// Show success state then redirect or reload
124122
setLocalSuccess('Version updated successfully!');
125-
setTimeout(async () => {
126-
setLocalSuccess(null);
127-
// Only generate JWT if there's a redirectUri (for app redirects)
128-
if (redirectUri) {
129-
await generateJWT(connectInfoMap.app, connectInfoMap.app.activeVersion!);
130-
} else {
131-
// Navigate to the app permissions page with full refresh to update sidebar
132-
window.location.href = `/user/appId/${connectInfoMap.app.appId}`;
133-
}
134-
}, 3000);
123+
setLocalSuccess(null);
124+
// Only generate JWT if there's a redirectUri (for app redirects)
125+
if (redirectUri) {
126+
await generateJWT(connectInfoMap.app, connectInfoMap.app.activeVersion!);
127+
} else {
128+
// Navigate to the app permissions page with full refresh to update sidebar
129+
window.location.href = `/user/appId/${connectInfoMap.app.appId}`;
130+
}
135131
} catch (error) {
136132
setLocalError(error instanceof Error ? error.message : 'Failed to update version');
137133
setLocalStatus(null);

packages/apps/app-dashboard/src/components/user-dashboard/dashboard/UserPermissionPage.tsx

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ export function AppPermissionPage({
6666
useEffect(() => {
6767
if (redirectUrl && !localSuccess) {
6868
setLocalSuccess('Success! Redirecting to app...');
69-
setTimeout(() => {
70-
executeRedirect();
71-
}, 2000);
69+
executeRedirect();
7270
}
7371
}, [redirectUrl, localSuccess, executeRedirect]);
7472

@@ -176,9 +174,7 @@ export function AppPermissionPage({
176174
if (!hasAnyChanges) {
177175
setLocalStatus(null);
178176
setLocalSuccess('Permissions are up to date.');
179-
setTimeout(() => {
180-
setLocalSuccess(null);
181-
}, 3000);
177+
setLocalSuccess(null);
182178
return;
183179
}
184180

@@ -211,17 +207,15 @@ export function AppPermissionPage({
211207
console.log('[UserPermissionPage] setAbilityPolicyParameters result:', result);
212208

213209
setLocalStatus(null);
214-
// Show success state for 3 seconds, then handle redirect or clear success
210+
// Show success state then handle redirect or clear success
215211
setLocalSuccess('Permissions granted successfully!');
216212

217213
// Generate JWT for redirect (useJwtRedirect will handle if there's a redirectUri)
218-
setTimeout(async () => {
219-
setLocalSuccess(null);
220-
// Only generate JWT if there's a redirectUri (for app redirects)
221-
if (redirectUri) {
222-
await generateJWT(connectInfoMap.app, Number(permittedVersion));
223-
}
224-
}, 3000);
214+
setLocalSuccess(null);
215+
// Only generate JWT if there's a redirectUri (for app redirects)
216+
if (redirectUri) {
217+
await generateJWT(connectInfoMap.app, Number(permittedVersion));
218+
}
225219
} catch (error) {
226220
setLocalError(error instanceof Error ? error.message : 'Failed to permit app');
227221
setLocalStatus(null);
@@ -279,10 +273,8 @@ export function AppPermissionPage({
279273
setLocalStatus(null);
280274
// Show success state until redirect
281275
setLocalSuccess('App unpermitted successfully!');
282-
setTimeout(() => {
283-
// Force the refresh for the sidebar to update
284-
window.location.href = `/user/apps`;
285-
}, 3000);
276+
// Force the refresh for the sidebar to update
277+
window.location.href = `/user/apps`;
286278
} catch (error) {
287279
setLocalError(error instanceof Error ? error.message : 'Failed to unpermit app');
288280
setLocalStatus(null);

0 commit comments

Comments
 (0)