Skip to content

Commit

Permalink
Fix bug in ai alert dialog after login
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjarling committed May 30, 2024
1 parent 27d7a57 commit 19242a8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions hooks/useGenerativeAISearchToggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ export default function useGenerativeAISearchToggle() {
// If the "ai" query param is present and the user is not logged in on
// initial load, show the dialog
useEffect(() => {
if (isAiQueryParam && !user?.isLoggedIn) {
setDialog((prevDialog) => ({ ...prevDialog, isOpen: true }));
if (!user) return;
if (isAiQueryParam) {
setDialog((prevDialog) => ({ ...prevDialog, isOpen: !user?.isLoggedIn }));
}
}, [isAiQueryParam, user?.isLoggedIn]);
}, [isAiQueryParam, user]);

function goToLocation() {
const currentUrl = `${window.location.origin}${router.asPath}`;
Expand Down

0 comments on commit 19242a8

Please sign in to comment.