Skip to content

Commit 9f44ed7

Browse files
fix(mosaic): reset connected account connect guard in finally
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent dbae7d7 commit 9f44ed7

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎packages/mosaic/src/features/user-profile/user-profile-connected-accounts-section/user-profile-connected-accounts-section.controller.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ export function useUserProfileConnectedAccountsController({
3232
const [pendingId, setPendingId] = useState<string>();
3333
const [connectErrors, setConnectErrors] = useState<Record<string, string>>({});
3434
const [reconnectErrors, setReconnectErrors] = useState<Record<string, string>>({});
35-
const inFlight = useRef<string | undefined>(undefined);
35+
const connecting = useRef(false);
3636

3737
const run = async (
3838
id: string,
3939
action: (id: string) => Promise<ConnectedAccountActionResult>,
4040
setErrors: typeof setConnectErrors,
4141
) => {
42-
if (inFlight.current) {
42+
if (connecting.current) {
4343
return;
4444
}
45-
inFlight.current = id;
45+
connecting.current = true;
4646
setPendingId(id);
4747
setErrors(({ [id]: _cleared, ...rest }) => rest);
4848

@@ -52,10 +52,10 @@ export function useUserProfileConnectedAccountsController({
5252
}
5353
} catch (error) {
5454
setErrors(current => ({ ...current, [id]: formatError(error) }));
55+
} finally {
56+
connecting.current = false;
57+
setPendingId(undefined);
5558
}
56-
57-
inFlight.current = undefined;
58-
setPendingId(undefined);
5959
};
6060

6161
return {

0 commit comments

Comments
 (0)