From fce6644e30e25cc9bc85d17048fa33ad5c4d7c93 Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Fri, 24 Jan 2025 15:22:40 +0000 Subject: [PATCH] Fix double fetching --- client/src/components/OAuthCallback.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/src/components/OAuthCallback.tsx b/client/src/components/OAuthCallback.tsx index 3887be1..4729e71 100644 --- a/client/src/components/OAuthCallback.tsx +++ b/client/src/components/OAuthCallback.tsx @@ -1,10 +1,18 @@ -import { useEffect } from 'react'; +import { useEffect, useRef } from 'react'; import { handleOAuthCallback } from '../lib/auth'; import { SESSION_KEYS } from '../lib/constants'; const OAuthCallback = () => { + const hasProcessedRef = useRef(false); + useEffect(() => { const handleCallback = async () => { + // Skip if we've already processed this callback + if (hasProcessedRef.current) { + return; + } + hasProcessedRef.current = true; + const params = new URLSearchParams(window.location.search); const code = params.get('code'); const serverUrl = sessionStorage.getItem(SESSION_KEYS.SERVER_URL);